Skip to content
Browse files

custom finders now return persisted instances

  • Loading branch information...
1 parent a154bde commit ae511c53989523d481515a39858eda1a7206b542 @staugaard staugaard committed Jan 16, 2012
View
2 lib/chargify_api_ares/resources/coupon.rb
@@ -5,7 +5,7 @@ def self.find_all_by_product_family_id(product_family_id)
end
def self.find_by_product_family_id_and_code(product_family_id, code)
- Coupon.new get(:lookup, :product_family_id => product_family_id, :code => code)
+ Coupon.new(get(:lookup, :product_family_id => product_family_id, :code => code), true)
end
def usage
View
2 lib/chargify_api_ares/resources/customer.rb
@@ -1,7 +1,7 @@
module Chargify
class Customer < Base
def self.find_by_reference(reference)
- Customer.new get(:lookup, :reference => reference)
+ Customer.new(get(:lookup, :reference => reference), true)
end
class Subscription < Base
View
2 lib/chargify_api_ares/resources/product.rb
@@ -1,7 +1,7 @@
module Chargify
class Product < Base
def self.find_by_handle(handle)
- Product.new get(:lookup, :handle => handle)
+ Product.new(get(:lookup, :handle => handle), true)
end
protected
View
5 spec/resources/coupon_spec.rb
@@ -16,6 +16,11 @@
coupon = Chargify::Coupon.find_by_product_family_id_and_code(10, '20OFF')
coupon.should be_instance_of(Chargify::Coupon)
end
+
+ it 'is marked as persisted' do
+ coupon = Chargify::Coupon.find_by_product_family_id_and_code(10, '20OFF')
+ coupon.persisted?.should == true
+ end
end
context '.find_all_by_product_family_id' do
View
5 spec/resources/customer_spec.rb
@@ -17,6 +17,11 @@
customer = Chargify::Customer.find_by_reference('sigma')
customer.should be_instance_of(Chargify::Customer)
end
+
+ it 'is marked as persisted' do
+ customer = Chargify::Customer.find_by_reference('sigma')
+ customer.persisted?.should == true
+ end
end
context "#subscriptions" do
View
5 spec/resources/product_spec.rb
@@ -18,6 +18,11 @@
product = Chargify::Product.find_by_handle('green-money')
product.should be_instance_of(Chargify::Product)
end
+
+ it 'is marked as persisted' do
+ product = Chargify::Product.find_by_handle('green-money')
+ product.persisted?.should == true
+ end
end
end

0 comments on commit ae511c5

Please sign in to comment.
Something went wrong with that request. Please try again.