summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorVinnie Okada <vokada@mrvinn.com>2015-05-13 22:21:34 -0600
committerVinnie Okada <vokada@mrvinn.com>2015-05-16 14:11:33 -0600
commit56e06b03bfb76a6fea263940cd4512276c3225c8 (patch)
tree392498aa7b21a91448f2a4bb7e19bc7e827f70f7 /spec
parentaf428b12598f06073327bc63d75d9c358c95067a (diff)
downloadgitlab-ce-56e06b03bfb76a6fea263940cd4512276c3225c8.tar.gz
Add tests for password reset token changes
Diffstat (limited to 'spec')
-rw-r--r--spec/mailers/notify_spec.rb57
1 files changed, 24 insertions, 33 deletions
diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb
index 4da91eea98c..37607b55eb1 100644
--- a/spec/mailers/notify_spec.rb
+++ b/spec/mailers/notify_spec.rb
@@ -5,6 +5,8 @@ describe Notify do
include EmailSpec::Matchers
include RepoHelpers
+ new_user_address = 'newguy@example.com'
+
let(:gitlab_sender_display_name) { Gitlab.config.gitlab.email_display_name }
let(:gitlab_sender) { Gitlab.config.gitlab.email_from }
let(:gitlab_sender_reply_to) { Gitlab.config.gitlab.email_reply_to }
@@ -55,18 +57,9 @@ describe Notify do
end
end
- describe 'for new users, the email' do
- let(:example_site_path) { root_path }
- let(:new_user) { create(:user, email: 'newguy@example.com', created_by_id: 1) }
-
- token = 'kETLwRaayvigPq_x3SNM'
-
- subject { Notify.new_user_email(new_user.id, token) }
-
- it_behaves_like 'an email sent from GitLab'
-
+ shared_examples 'a new user email' do |user_email, site_path|
it 'is sent to the new user' do
- is_expected.to deliver_to new_user.email
+ is_expected.to deliver_to user_email
end
it 'has the correct subject' do
@@ -74,9 +67,25 @@ describe Notify do
end
it 'contains the new user\'s login name' do
- is_expected.to have_body_text /#{new_user.email}/
+ is_expected.to have_body_text /#{user_email}/
end
+ it 'includes a link to the site' do
+ is_expected.to have_body_text /#{site_path}/
+ end
+ end
+
+ describe 'for new users, the email' do
+ let(:example_site_path) { root_path }
+ let(:new_user) { create(:user, email: new_user_address, created_by_id: 1) }
+
+ token = 'kETLwRaayvigPq_x3SNM'
+
+ subject { Notify.new_user_email(new_user.id, token) }
+
+ it_behaves_like 'an email sent from GitLab'
+ it_behaves_like 'a new user email', new_user_address
+
it 'contains the password text' do
is_expected.to have_body_text /Click here to set your password/
end
@@ -88,44 +97,26 @@ describe Notify do
)
end
- 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)
+ is_expected.to have_body_text(/\?user_email=.*%40.*/)
end
end
describe 'for users that signed up, the email' do
let(:example_site_path) { root_path }
- let(:new_user) { create(:user, email: 'newguy@example.com', password: "securePassword") }
+ let(:new_user) { create(:user, email: new_user_address, password: "securePassword") }
subject { Notify.new_user_email(new_user.id) }
it_behaves_like 'an email sent from GitLab'
-
- it 'is sent to the new user' do
- is_expected.to deliver_to new_user.email
- end
-
- it 'has the correct subject' do
- is_expected.to have_subject /^Account was created for you$/i
- end
-
- it 'contains the new user\'s login name' do
- is_expected.to have_body_text /#{new_user.email}/
- end
+ it_behaves_like 'a new user email', new_user_address
it 'should not contain the new user\'s password' do
is_expected.not_to have_body_text /password/
end
-
- it 'includes a link to the site' do
- is_expected.to have_body_text /#{example_site_path}/
- end
end
describe 'user added ssh key' do