Skip to content

Commit e1658e7

Browse files
committed
Update email conf test file for DMPRoadmap
- Removed the 'A user attempts to sign in via the "Sign in with institutional or social ID"...' test which is specific to DMP Assistant functionality. - Removed hardcoding of I18n.default_locale = :'en-CA' - However, the current test config is preventing us from using the `I18n.default_locale` value that is specific to the app. This in turn is causing issues with I18n.t() using the desired locale. - #3511 seeks to remedy the above issues.
1 parent af00a22 commit e1658e7

File tree

1 file changed

+6
-63
lines changed

1 file changed

+6
-63
lines changed

spec/features/email_confirmation_spec.rb

Lines changed: 6 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -6,81 +6,24 @@
66
# (See `app/controllers/concerns/email_confirmation_handler.rb`)
77
# Here, we define "unconfirmable" as a user that is both unconfirmed and has no outstanding confirmation token
88
RSpec.describe 'Email Confirmation', type: :feature do
9-
before(:each) do
10-
@default_locale = I18n.default_locale
11-
I18n.default_locale = :'en-CA'
12-
end
13-
14-
after(:each) do
15-
I18n.default_locale = @default_locale
16-
end
17-
189
scenario 'A user attempts to sign in via the "Sign In" button. However, they are unconfirmable.', :js do
19-
# Setup
2010
user = create(:user, :unconfirmable)
21-
22-
# Actions
2311
sign_in(user)
24-
user.reload
25-
26-
# Expectations
27-
expectations_for_unconfirmable_user_after_sign_in_attempt(user)
28-
29-
# Actions
30-
sign_in(user)
31-
32-
# Expectations
33-
expect_request_new_confirmation_link_message
34-
end
3512

36-
scenario 'A user attempts to sign in via the "Sign in with institutional or social ID"
37-
button with an email that is not currently linked to any account. The chosen
38-
SSO email matches an existing user account email. However, they are unconfirmable.', :js do
39-
# Setup
40-
Rails.application.env_config['devise.mapping'] = Devise.mappings[:user]
41-
Rails.application.env_config['omniauth.auth'] = OmniAuth.config.mock_auth[:openid_connect]
42-
user = create(:user, :unconfirmable, email: OmniAuth.config.mock_auth[:openid_connect][:info][:email])
43-
44-
# Actions
45-
visit root_path
46-
click_link 'Sign in with institutional or social ID'
13+
# A flash notice is displayed informing the user that a confirmation email has been sent
14+
expect(page.text).to have_text(I18n.t('devise.registrations.signed_up_but_unconfirmed'))
15+
# reload the user to check confirmation values
4716
user.reload
4817

49-
# Expectations
50-
expectations_for_unconfirmable_user_after_sign_in_attempt(user)
51-
# An Identifier entry was not created
52-
expect(Identifier.count).to be_zero
53-
54-
# Actions
55-
click_link 'Sign in with institutional or social ID'
56-
57-
# Expectations
58-
expect_request_new_confirmation_link_message
59-
end
60-
61-
private
62-
63-
def expectations_for_unconfirmable_user_after_sign_in_attempt(user)
6418
# The user remains unconfirmed
6519
expect(user.confirmed?).to be(false)
6620
# A confirmation_token now exists
6721
expect(user.confirmation_token).to be_present
6822
# The user is not signed in
6923
expect(current_path).to eq(root_path)
70-
# The correct flash message was rendered
71-
expect_confirmation_link_has_been_sent_message
72-
end
7324

74-
def expect_confirmation_link_has_been_sent_message
75-
msg = 'A message with a confirmation link has been sent to your email address. ' \
76-
'Please open the link to activate your account. ' \
77-
'If you do not receive the confirmation email, please check your spam filter.'
78-
expect(page.text).to have_text(msg)
79-
end
80-
81-
def expect_request_new_confirmation_link_message
82-
msg = 'You need to confirm your account before continuing. ' \
83-
'(Click to request a new confirmation email)'
84-
expect(page.text).to have_text(msg)
25+
sign_in(user)
26+
# A flash warning is displayed informing the user that they have to confirm their email
27+
expect(page.text).to have_text(I18n.t('devise.failure.unconfirmed'))
8528
end
8629
end

0 commit comments

Comments
 (0)