diff --git a/slack-gamebot/app.rb b/slack-gamebot/app.rb index 6e88c2b..54c68ba 100644 --- a/slack-gamebot/app.rb +++ b/slack-gamebot/app.rb @@ -66,7 +66,7 @@ def check_subscribed_teams! Team.where(subscribed: true, :stripe_customer_id.ne => nil).each do |team| if team.stripe_customer.subscriptions.none? logger.info "No active subscriptions for #{team} (#{team.stripe_customer_id}), downgrading." - team.inform! 'Your subscription was canceled and your team has been downgraded. Thank you for being a customer!' + team.inform_admin! 'Your subscription was canceled and your team has been downgraded. Thank you for being a customer!' team.update_attributes!(subscribed: false) else team.stripe_customer.subscriptions.each do |subscription| diff --git a/spec/slack-gamebot/app_spec.rb b/spec/slack-gamebot/app_spec.rb index 2bbb44e..83c2f6a 100644 --- a/spec/slack-gamebot/app_spec.rb +++ b/spec/slack-gamebot/app_spec.rb @@ -56,7 +56,7 @@ expect_any_instance_of(Team).to receive(:inform_admin!).with("Your subscription to Plan ($29.99) is past due. #{team.update_cc_text}") subject.send(:check_subscribed_teams!) end - it 'notifies past due subscription' do + it 'notifies canceled subscription' do customer.subscriptions.data.first['status'] = 'canceled' expect(Stripe::Customer).to receive(:retrieve).and_return(customer) expect_any_instance_of(Team).to receive(:inform_admin!).with('Your subscription to Plan ($29.99) was canceled and your team has been downgraded. Thank you for being a customer!') @@ -66,7 +66,7 @@ it 'notifies no active subscriptions' do customer.subscriptions.data = [] expect(Stripe::Customer).to receive(:retrieve).and_return(customer) - expect_any_instance_of(Team).to receive(:inform!).with('Your subscription was canceled and your team has been downgraded. Thank you for being a customer!') + expect_any_instance_of(Team).to receive(:inform_admin!).with('Your subscription was canceled and your team has been downgraded. Thank you for being a customer!') subject.send(:check_subscribed_teams!) expect(team.reload.subscribed?).to be false end