|
26 | 26 | expect(page).to have_current_path(plans_path) |
27 | 27 | end |
28 | 28 |
|
29 | | - scenario 'A user attempts to sign in via the "Sign in with your institutional credentials" |
30 | | - button. The email is linked to a user account, however the account is |
31 | | - unconfirmed and has no confirmation token.', :js do |
32 | | - user = create(:user, :unconfirmed_and_no_confirmation_token) |
33 | | - scheme = create(:identifier_scheme, :shibboleth) |
34 | | - # Mock the OmniAuth authentication hash for Shibboleth via OmniAuthHelper |
35 | | - OmniAuth.config.mock_auth[:shibboleth] = mock_auth_hash(user, scheme) |
36 | | - # Create a Shibboleth-related Identifier for the user |
37 | | - Identifier.create(identifier_scheme: scheme, |
38 | | - value: OmniAuth.config.mock_auth[:shibboleth].uid, |
39 | | - attrs: OmniAuth.config.mock_auth[:shibboleth], |
40 | | - identifiable: user) |
41 | | - |
42 | | - visit root_path |
43 | | - # Sign-in attempt #1 (user is unconfirmed and has no confirmation_token) |
44 | | - click_link SSO_SIGN_IN_BUTTON_TEXT |
45 | | - expectations_for_unconfirmed_user_with_no_confirmation_token_after_sign_in_attempt(user) |
| 29 | + describe 'Initial setup for shibboleth sign-in' do |
| 30 | + before do |
| 31 | + # Set up the user and identifier scheme |
| 32 | + @user = create(:user, :unconfirmed_and_no_confirmation_token) |
| 33 | + @scheme = create(:identifier_scheme, :shibboleth) |
46 | 34 |
|
47 | | - visit root_path |
48 | | - # Sign-in attempt #2 (user still unconfirmed but has a confirmation_token) |
49 | | - click_link SSO_SIGN_IN_BUTTON_TEXT |
50 | | - expectations_for_unconfirmed_user_with_confirmation_token_after_sign_in_attempt |
| 35 | + # Mock OmniAuth authentication hash for Shibboleth via OmniAuthHelper |
| 36 | + OmniAuth.config.mock_auth[:shibboleth] = mock_auth_hash(@user, @scheme) |
51 | 37 |
|
52 | | - # Sign-in attempt #3 (user is now confirmed) |
53 | | - user.confirm |
54 | | - click_link SSO_SIGN_IN_BUTTON_TEXT |
55 | | - # The user is signed in |
56 | | - expect(page).to have_current_path(plans_path) |
| 38 | + # Create the identifier for the user |
| 39 | + Identifier.create(identifier_scheme: @scheme, |
| 40 | + value: OmniAuth.config.mock_auth[:shibboleth].uid, |
| 41 | + attrs: OmniAuth.config.mock_auth[:shibboleth], |
| 42 | + identifiable: @user) |
| 43 | + end |
| 44 | + |
| 45 | + scenario 'A user attempts to sign in via the "Sign in with your institutional credentials" |
| 46 | + button. The email is linked to a user account, however the account is |
| 47 | + unconfirmed and has no confirmation token.', :js do |
| 48 | + visit root_path |
| 49 | + # Sign-in attempt #1 (user is unconfirmed and has no confirmation_token) |
| 50 | + click_link SSO_SIGN_IN_BUTTON_TEXT |
| 51 | + expectations_for_unconfirmed_user_with_no_confirmation_token_after_sign_in_attempt(@user) |
| 52 | + |
| 53 | + visit root_path |
| 54 | + # Sign-in attempt #2 (user still unconfirmed but has a confirmation_token) |
| 55 | + click_link SSO_SIGN_IN_BUTTON_TEXT |
| 56 | + expectations_for_unconfirmed_user_with_confirmation_token_after_sign_in_attempt |
| 57 | + |
| 58 | + # Sign-in attempt #3 (user is now confirmed) |
| 59 | + @user.confirm |
| 60 | + click_link SSO_SIGN_IN_BUTTON_TEXT |
| 61 | + # The user is signed in |
| 62 | + expect(page).to have_current_path(plans_path) |
| 63 | + end |
57 | 64 | end |
58 | 65 |
|
59 | 66 | scenario 'A user is unconfirmed but has no confirmation token. |
|
0 commit comments