From 99e747a331543999112e44fdc2b8b1411068424c Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Wed, 31 May 2023 12:09:00 +0200 Subject: [PATCH] Ensure subscriptions are not stubbed if testing for no subscription --- spec/plugin_helper.rb | 11 +++++++++++ .../custom_wizard/admin/admin_controller_spec.rb | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/spec/plugin_helper.rb b/spec/plugin_helper.rb index 5334c1fa..16585e16 100644 --- a/spec/plugin_helper.rb +++ b/spec/plugin_helper.rb @@ -12,3 +12,14 @@ def enable_subscription(type) CustomWizard::Subscription.stubs("#{type}?".to_sym).returns(true) CustomWizard::Subscription.any_instance.stubs("#{type}?".to_sym).returns(true) end + +def disable_subscriptions + %w[ + standard + business + community + ].each do |type| + CustomWizard::Subscription.stubs("#{type}?".to_sym).returns(false) + CustomWizard::Subscription.any_instance.stubs("#{type}?".to_sym).returns(false) + end +end diff --git a/spec/requests/custom_wizard/admin/admin_controller_spec.rb b/spec/requests/custom_wizard/admin/admin_controller_spec.rb index 6a7d721c..5e2b722c 100644 --- a/spec/requests/custom_wizard/admin/admin_controller_spec.rb +++ b/spec/requests/custom_wizard/admin/admin_controller_spec.rb @@ -14,6 +14,10 @@ describe CustomWizard::AdminController do end context "without a subscription" do + before do + disable_subscriptions + end + it "returns the right subscription details" do get "/admin/wizards.json" expect(response.parsed_body["subscribed"]).to eq(false)