diff options
author | Vinnie Okada <vokada@mrvinn.com> | 2015-04-26 22:04:33 -0600 |
---|---|---|
committer | Vinnie Okada <vokada@mrvinn.com> | 2015-05-16 14:03:07 -0600 |
commit | 0bfab084a811d7dad1f1929ee7b5c2bc59015173 (patch) | |
tree | da3c6e696e22b3d9e377f956c1adbec4380a3e97 /spec | |
parent | 35729671fb3a123ddeb7b2b1cda446fd661bd4e6 (diff) | |
download | gitlab-ce-0bfab084a811d7dad1f1929ee7b5c2bc59015173.tar.gz |
Explain reset token expiration in emails
Tell new users when their password reset token expires and provide a
link to get a new one.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/helpers/emails_helper_spec.rb | 46 | ||||
-rw-r--r-- | spec/mailers/notify_spec.rb | 5 |
2 files changed, 51 insertions, 0 deletions
diff --git a/spec/helpers/emails_helper_spec.rb b/spec/helpers/emails_helper_spec.rb new file mode 100644 index 00000000000..7a3e38d7e63 --- /dev/null +++ b/spec/helpers/emails_helper_spec.rb @@ -0,0 +1,46 @@ +require 'spec_helper' + +describe EmailsHelper do + describe 'password_reset_token_valid_time' do + def validate_time_string(time_limit, expected_string) + Devise.reset_password_within = time_limit + expect(password_reset_token_valid_time).to eq(expected_string) + end + + context 'when time limit is less than 2 hours' do + it 'should display the time in hours using a singular unit' do + validate_time_string(1.hour, '1 hour') + end + end + + context 'when time limit is 2 or more hours' do + it 'should display the time in hours using a plural unit' do + validate_time_string(2.hours, '2 hours') + end + end + + context 'when time limit contains fractions of an hour' do + it 'should round down to the nearest hour' do + validate_time_string(96.minutes, '1 hour') + end + end + + context 'when time limit is 24 or more hours' do + it 'should display the time in days using a singular unit' do + validate_time_string(24.hours, '1 day') + end + end + + context 'when time limit is 2 or more days' do + it 'should display the time in days using a plural unit' do + validate_time_string(2.days, '2 days') + end + end + + context 'when time limit contains fractions of a day' do + it 'should round down to the nearest day' do + validate_time_string(57.hours, '2 days') + end + end + end +end diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index dbcf7286e45..4da91eea98c 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -91,6 +91,11 @@ describe Notify do it 'includes a link to the site' do is_expected.to have_body_text /#{example_site_path}/ end + + it 'explains the reset link expiration' do + is_expected.to have_body_text(/This link is valid for \d+ (hours?|days?)/) + is_expected.to have_body_text(new_user_password_url) + end end |