diff --git a/spec/features/account/calculators_spec.rb b/spec/features/account/calculators_spec.rb index 6ba23b8f1..010855a82 100644 --- a/spec/features/account/calculators_spec.rb +++ b/spec/features/account/calculators_spec.rb @@ -7,7 +7,7 @@ let!(:napkin_calculator) { create(:calculator, en_name: "Napkin Calculator") } include_context :authorize_admin - include_context :show_constructor + include_context :enable_calculators_constructor it "visits admin page" do visit account_calculators_path diff --git a/spec/features/show_calculator_spec.rb b/spec/features/show_calculator_spec.rb index 2ac97e00a..5b8cdbcd1 100644 --- a/spec/features/show_calculator_spec.rb +++ b/spec/features/show_calculator_spec.rb @@ -4,7 +4,7 @@ describe "GET #show" do let(:calculator) { create(:calculator) } - include_context :show_constructor + include_context :enable_calculators_constructor before do allow(controller).to receive(:resource).and_return(calculator) diff --git a/spec/features/visit_login_spec.rb b/spec/features/visit_login_spec.rb index bca43b2d3..5c95d53bb 100644 --- a/spec/features/visit_login_spec.rb +++ b/spec/features/visit_login_spec.rb @@ -6,7 +6,7 @@ let(:user) { create(:user) } let(:calculator) { create(:calculator) } - include_context :show_constructor + include_context :enable_calculators_constructor it "when sign in with correct login and password" do allow_any_instance_of(ApplicationController) diff --git a/spec/requests/account/calculators_spec.rb b/spec/requests/account/calculators_spec.rb index f5608f007..c4f45a524 100644 --- a/spec/requests/account/calculators_spec.rb +++ b/spec/requests/account/calculators_spec.rb @@ -4,7 +4,7 @@ RSpec.describe "Account::CalculatorsController", type: :request do include_context :authorize_admin - include_context :show_constructor + include_context :enable_calculators_constructor let!(:calculator) { create(:calculator) } @@ -25,7 +25,7 @@ describe "GET #index" do context "when flipper is turned off" do - include_context :hide_constructor + include_context :disable_calculators_constructor it "raises routing error" do expect { get account_calculators_path }.to raise_error(ActionController::RoutingError) diff --git a/spec/requests/calculators_spec.rb b/spec/requests/calculators_spec.rb index 0f5e2f802..6e7b3c76c 100644 --- a/spec/requests/calculators_spec.rb +++ b/spec/requests/calculators_spec.rb @@ -5,11 +5,14 @@ RSpec.describe CalculatorsController, type: :request do let(:calculator) { create(:calculator) } - include_context :show_constructor + include_context :enable_calculators_constructor describe "GET #index" do context "when show_calculators_list feature is enabled" do include_context :show_calculators_list + before(:example, :disabled_constructor) do + include_context :disable_calculators_constructor + end it "renders the calculators index when show_calculators_list is enabled" do get calculators_path @@ -18,6 +21,14 @@ expect(response).to render_template(:index) expect(assigns(:calculators)).not_to be_nil end + + context 'and constructor flipper is disabled' do + include_context :disable_calculators_constructor + + it 'raises routing error' do + expect { get calculators_path }.to raise_error(ActionController::RoutingError) + end + end end context "when show_calculators_list feature is disabled" do diff --git a/spec/support/shared/context/feature_flags.rb b/spec/support/shared/context/feature_flags.rb index 50e45ed39..13a029c9f 100644 --- a/spec/support/shared/context/feature_flags.rb +++ b/spec/support/shared/context/feature_flags.rb @@ -26,14 +26,14 @@ end end -RSpec.shared_context :show_constructor do +RSpec.shared_context :enable_calculators_constructor do before do FeatureFlag.find_or_create_by!(name: "constructor_status") Flipper.enable(:constructor_status) end end -RSpec.shared_context :hide_constructor do +RSpec.shared_context :disable_calculators_constructor do before do FeatureFlag.find_or_create_by!(name: "constructor_status") Flipper.disable(:constructor_status)