|
201 | 201 | end
|
202 | 202 |
|
203 | 203 | it "cancels a stripe customer's subscription" do
|
204 |
| - plan = Stripe::Plan.create(id: 'the truth') |
| 204 | + Stripe::Plan.create(id: 'the truth') |
205 | 205 | customer = Stripe::Customer.create(id: 'test_customer_sub', card: 'tk')
|
206 | 206 | sub = customer.update_subscription({ :plan => 'the truth' })
|
207 | 207 |
|
208 | 208 | result = customer.cancel_subscription
|
209 |
| - expect(result.deleted).to eq(true) |
| 209 | + expect(result.status).to eq('canceled') |
| 210 | + expect(result.cancel_at_period_end).to be_false |
210 | 211 | expect(result.id).to eq(sub.id)
|
| 212 | + |
211 | 213 | customer = Stripe::Customer.retrieve('test_customer_sub')
|
212 |
| - expect(customer.subscription).to be_nil |
| 214 | + expect(customer.subscription).to_not be_nil |
| 215 | + expect(customer.subscription.id).to eq(result.id) |
| 216 | + end |
| 217 | + |
| 218 | + it "cancels a stripe customer's subscription at period end" do |
| 219 | + Stripe::Plan.create(id: 'the truth') |
| 220 | + customer = Stripe::Customer.create(id: 'test_customer_sub', card: 'tk') |
| 221 | + sub = customer.update_subscription({ :plan => 'the truth' }) |
| 222 | + |
| 223 | + result = customer.cancel_subscription(at_period_end: true) |
| 224 | + expect(result.status).to eq('active') |
| 225 | + expect(result.cancel_at_period_end).to be_true |
| 226 | + expect(result.id).to eq(sub.id) |
| 227 | + |
| 228 | + customer = Stripe::Customer.retrieve('test_customer_sub') |
| 229 | + expect(customer.subscription).to_not be_nil |
| 230 | + expect(customer.subscription.id).to eq(result.id) |
213 | 231 | end
|
214 | 232 |
|
215 | 233 | it "cannot update to a plan that does not exist" do
|
|
0 commit comments