Browse Source

Revert has_many due to ActiveResource version

Christian Joudrey 11 years ago
parent
commit
e852af586b

+ 3 - 1
lib/shopify_api/resources/customer_saved_search.rb

@@ -2,6 +2,8 @@ require 'shopify_api/resources/customer'
 
 module ShopifyAPI
   class CustomerSavedSearch < Base
-    has_many :customers, :class_name => ShopifyAPI::Customer
+    def customers(params = {})
+      Customer.find(:all, :params => params.merge({ :customer_saved_search_id => self.id }))
+    end
   end
 end

+ 7 - 0
test/customer_saved_search_test.rb

@@ -12,6 +12,13 @@ class CustomerSavedSearchTest < Test::Unit::TestCase
     assert_equal 112223902, @customer_saved_search.customers.first.id
   end
 
+  def test_get_customers_from_customer_saved_search_with_params
+    fake 'customers.json?customer_saved_search_id=8899730&limit=1', :body => load_fixture('customer_saved_search_customers'), :extension => false
+    customers = @customer_saved_search.customers(:limit => 1)
+    assert_equal 1, customers.length
+    assert_equal 112223902, customers.first.id
+  end
+
   private
   def load_customer_saved_search
     fake 'customer_saved_searches/8899730', :body => load_fixture('customer_saved_search')