spec/integration/braintree/credit_card_spec.rb in braintree-2.1.0 vs spec/integration/braintree/credit_card_spec.rb in braintree-2.2.0
- old
+ new
@@ -516,11 +516,11 @@
updated_credit_card.token.should == credit_card.token
updated_credit_card.bin.should == Braintree::Test::CreditCardNumbers::MasterCard[0, 6]
updated_credit_card.last_4.should == Braintree::Test::CreditCardNumbers::MasterCard[-4..-1]
updated_credit_card.expiration_date.should == "06/2013"
updated_credit_card.cardholder_name.should == "New Holder"
- updated_credit_card.updated_at.between?(Time.now - 5, Time.now).should == true
+ updated_credit_card.updated_at.between?(Time.now - 60, Time.now).should == true
end
it "raises a ValidationsFailed if invalid" do
customer = Braintree::Customer.create!
credit_card = Braintree::CreditCard.create!(
@@ -684,23 +684,59 @@
end
describe "self.expired" do
it "finds expired payment methods, paginated" do
collection = Braintree::CreditCard.expired
- collection._approximate_size.should > 0
+ collection.maximum_size.should > 0
collection.all? { |pm| pm.expired?.should == true }
end
+
+ it "can iterate over all items" do
+ customer = Braintree::Customer.all.first
+
+ (110 - Braintree::CreditCard.expired.maximum_size).times do
+ Braintree::CreditCard.create!(
+ :customer_id => customer.id,
+ :number => Braintree::Test::CreditCardNumbers::Visa,
+ :expiration_date => "01/2010"
+ )
+ end
+
+ collection = Braintree::CreditCard.expired
+ collection.maximum_size.should > 100
+
+ credit_card_ids = collection.map {|c| c.token }.uniq.compact
+ credit_card_ids.size.should == collection.maximum_size
+ end
end
describe "self.expiring_between" do
it "finds payment methods expiring between the given dates" do
next_year = Time.now.year + 1
collection = Braintree::CreditCard.expiring_between(Time.mktime(next_year, 1), Time.mktime(next_year, 12))
- collection._approximate_size.should > 0
+ collection.maximum_size.should > 0
collection.all? { |pm| pm.expired?.should == false }
collection.all? { |pm| pm.expiration_year.should == next_year.to_s }
end
+
+ it "can iterate over all items" do
+ customer = Braintree::Customer.all.first
+
+ (110 - Braintree::CreditCard.expiring_between(Time.mktime(2010, 1, 1), Time.mktime(2010,3, 1)).maximum_size).times do
+ Braintree::CreditCard.create!(
+ :customer_id => customer.id,
+ :number => Braintree::Test::CreditCardNumbers::Visa,
+ :expiration_date => "01/2010"
+ )
+ end
+
+ collection = Braintree::CreditCard.expiring_between(Time.mktime(2010, 1, 1), Time.mktime(2010,3, 1))
+ collection.maximum_size.should > 100
+
+ credit_card_ids = collection.map {|c| c.token }.uniq.compact
+ credit_card_ids.size.should == collection.maximum_size
+ end
end
describe "self.find" do
it "finds the payment method with the given token" do
customer = Braintree::Customer.create.customer
@@ -965,10 +1001,10 @@
).should == credit_card
credit_card.bin.should == Braintree::Test::CreditCardNumbers::MasterCard[0, 6]
credit_card.last_4.should == Braintree::Test::CreditCardNumbers::MasterCard[-4..-1]
credit_card.expiration_date.should == "06/2013"
credit_card.cardholder_name.should == "New Holder"
- credit_card.updated_at.between?(Time.now - 5, Time.now).should == true
+ credit_card.updated_at.between?(Time.now - 60, Time.now).should == true
end
it "raises a ValidationsFailed if invalid" do
customer = Braintree::Customer.create!
credit_card = Braintree::CreditCard.create!(