diff --git a/spec/features/saml/authorization_confirmation_spec.rb b/spec/features/saml/authorization_confirmation_spec.rb index aa3422c0205..e06b27d4c2d 100644 --- a/spec/features/saml/authorization_confirmation_spec.rb +++ b/spec/features/saml/authorization_confirmation_spec.rb @@ -33,16 +33,45 @@ def create_user_and_remember_device user1 end - it 'confirms the user wants to continue to SP with signin email after signing in again' do - second_email = create(:email_address, user: user1) - sign_in_user(user1, second_email.email) + context 'when the user is already signed in with an email different from the one shared' do + context 'when email sharing feature is enabled' do + before do + allow(IdentityConfig.store) + .to receive(:feature_select_email_to_share_enabled).and_return(true) + end + + it 'confirms the user wants to continue to SP with the shared email' do + shared_email = user1.identities.first.email_address.email + second_email = create(:email_address, user: user1) + sign_in_user(user1, second_email.email) + + visit request_url + expect(current_url).to match(user_authorization_confirmation_path) + expect(page).to have_content shared_email + + continue_as(shared_email) + expect(current_url).to eq(complete_saml_url) + end + end - visit request_url - expect(current_url).to match(user_authorization_confirmation_path) - expect(page).to have_content second_email.email + context 'when email sharing feature is disabled' do + before do + allow(IdentityConfig.store) + .to receive(:feature_select_email_to_share_enabled).and_return(false) + end - continue_as(second_email.email) - expect(current_url).to eq(complete_saml_url) + it 'confirms the user wants to continue to SP with the signed in email' do + second_email = create(:email_address, user: user1) + sign_in_user(user1, second_email.email) + + visit request_url + expect(current_url).to match(user_authorization_confirmation_path) + expect(page).to have_content second_email.email + + continue_as(second_email.email) + expect(current_url).to eq(complete_saml_url) + end + end end it 'allows the user to switch accounts prior to continuing to the SP' do