Skip to content

Commit

Permalink
add feature flag to redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
jack-coggin committed Dec 1, 2023
1 parent 28f80d5 commit dad5b3a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
6 changes: 5 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/users/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 4 additions & 5 deletions spec/system/confirmed_user/completing_registration_spec.rb
Original file line number Diff line number Diff line change
@@ -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.')

Expand Down Expand Up @@ -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?')
Expand Down

0 comments on commit dad5b3a

Please sign in to comment.