spec/integration/braintree/subscription_spec.rb in braintree-2.3.1 vs spec/integration/braintree/subscription_spec.rb in braintree-2.4.0
- old
+ new
@@ -129,10 +129,21 @@
)
result.subscription.trial_period.should == false
end
+ it "doesn't create a transaction if there's a trial period" do
+ result = Braintree::Subscription.create(
+ :payment_method_token => @credit_card.token,
+ :plan_id => TrialPlan[:id]
+ )
+
+ result.subscription.transactions.size.should == 0
+ end
+ end
+
+ context "no trial period" do
it "creates a transaction if no trial period" do
result = Braintree::Subscription.create(
:payment_method_token => @credit_card.token,
:plan_id => TriallessPlan[:id]
)
@@ -142,17 +153,20 @@
result.subscription.transactions.first.amount.should == TriallessPlan[:price]
result.subscription.transactions.first.type.should == Braintree::Transaction::Type::Sale
result.subscription.transactions.first.subscription_id.should == result.subscription.id
end
- it "doesn't create a transaction if there's a trial period" do
+ it "does not create the subscription and returns the transaction if the transaction is not successful" do
result = Braintree::Subscription.create(
:payment_method_token => @credit_card.token,
- :plan_id => TrialPlan[:id]
+ :plan_id => TriallessPlan[:id],
+ :price => Braintree::Test::TransactionAmounts::Decline
)
- result.subscription.transactions.size.should == 0
+ result.success?.should be_false
+ result.transaction.status.should == Braintree::Transaction::Status::ProcessorDeclined
+ result.message.should == "Do Not Honor"
end
end
context "price" do
it "defaults to the plan's price" do
@@ -225,10 +239,9 @@
:trial_duration_unit => nil
)
result.success?.should == false
result.errors.for(:subscription).on(:trial_duration_unit)[0].message.should == "Trial Duration Unit is invalid."
end
-
end
end
describe "self.find" do
it "finds a subscription" do