From dad5b3ae3d771d56e8017eefb2832996de4f9b87 Mon Sep 17 00:00:00 2001 From: "jack.coggin" Date: Fri, 1 Dec 2023 15:47:51 +0000 Subject: [PATCH] add feature flag to redirect --- app/controllers/application_controller.rb | 6 +++++- app/controllers/users/sessions_controller.rb | 4 +++- config/application.rb | 5 +++++ .../confirmed_user/completing_registration_spec.rb | 9 ++++----- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7b9ba514a..3dd694581 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -20,7 +20,11 @@ def authenticate_registered_user! authenticate_user! unless user_signed_in? return true if current_user.registration_complete? - redirect_to edit_registration_terms_and_conditions_path, notice: 'Please complete registration' + if Rails.application.gov_one_login? + redirect_to edit_registration_terms_and_conditions_path, notice: 'Please complete registration' + else + redirect_to edit_registration_name_path, notice: 'Please complete registration' + end end def configure_permitted_parameters diff --git a/app/controllers/users/sessions_controller.rb b/app/controllers/users/sessions_controller.rb index a4db408cb..aeb2584a5 100644 --- a/app/controllers/users/sessions_controller.rb +++ b/app/controllers/users/sessions_controller.rb @@ -16,8 +16,10 @@ def after_sign_in_path_for(resource) end elsif resource.private_beta_registration_complete? static_path('new-registration') - else + elsif Rails.application.gov_one_login? edit_registration_terms_and_conditions_path + else + edit_registration_name_path end end end diff --git a/config/application.rb b/config/application.rb index 42c3e1478..8a0b7345f 100644 --- a/config/application.rb +++ b/config/application.rb @@ -101,6 +101,11 @@ def maintenance? Types::Params::Bool[ENV.fetch('MAINTENANCE', false)] end + # @return [Boolean] + def gov_one_login? + Types::Params::Bool[ENV.fetch('GOV_ONE_LOGIN', false)] + end + # @return [ActiveSupport::TimeWithZone] def public_beta_launch_date Time.zone.local(2023, 2, 9, 15, 0, 0) diff --git a/spec/system/confirmed_user/completing_registration_spec.rb b/spec/system/confirmed_user/completing_registration_spec.rb index bcd43c72b..105e843c9 100644 --- a/spec/system/confirmed_user/completing_registration_spec.rb +++ b/spec/system/confirmed_user/completing_registration_spec.rb @@ -1,15 +1,16 @@ require 'rails_helper' RSpec.describe 'Confirmed users completing registration' do - include_context 'with user' + before do + allow(Rails.application).to receive(:gov_one_login?).and_return(true) + end + include_context 'with user' let(:user) { create :user, :confirmed } it 'requires name and a setting type and email preferences and a complete' do expect(page).to have_text('Terms and conditions') - click_button 'Continue' - expect(page).to have_text('There is a problem') .and have_text('You must accept the terms and conditions and privacy policy to create an account.') @@ -60,14 +61,12 @@ expect(page).to have_text('What is your role?') .and have_text('Enter your job title.') - click_button 'Continue' expect(page).to have_text('There is a problem') .and have_text('Enter your job title.') fill_in 'Enter your job title.', with: 'user defined job title' - click_button 'Continue' expect(page).to have_text('Do you want to get email updates about this training course?')