summaryrefslogtreecommitdiff
path: root/spec/mailers/notify_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/mailers/notify_spec.rb')
-rw-r--r--spec/mailers/notify_spec.rb218
1 files changed, 109 insertions, 109 deletions
diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb
index c045f85052c..64367ed9d80 100644
--- a/spec/mailers/notify_spec.rb
+++ b/spec/mailers/notify_spec.rb
@@ -16,34 +16,34 @@ describe Notify do
shared_examples 'a multiple recipients email' do
it 'is sent to the given recipient' do
- should deliver_to recipient.notification_email
+ is_expected.to deliver_to recipient.notification_email
end
end
shared_examples 'an email sent from GitLab' do
it 'is sent from GitLab' do
sender = subject.header[:from].addrs[0]
- sender.display_name.should eq('GitLab')
- sender.address.should eq(gitlab_sender)
+ expect(sender.display_name).to eq('GitLab')
+ expect(sender.address).to eq(gitlab_sender)
end
end
shared_examples 'an email starting a new thread' do |message_id_prefix|
it 'has a discussion identifier' do
- should have_header 'Message-ID', /<#{message_id_prefix}(.*)@#{Gitlab.config.gitlab.host}>/
- should have_header 'X-GitLab-Project', /#{project.name}/
+ is_expected.to have_header 'Message-ID', /<#{message_id_prefix}(.*)@#{Gitlab.config.gitlab.host}>/
+ is_expected.to have_header 'X-GitLab-Project', /#{project.name}/
end
end
shared_examples 'an answer to an existing thread' do |thread_id_prefix|
it 'has a subject that begins with Re: ' do
- should have_subject /^Re: /
+ is_expected.to have_subject /^Re: /
end
it 'has headers that reference an existing thread' do
- should have_header 'References', /<#{thread_id_prefix}(.*)@#{Gitlab.config.gitlab.host}>/
- should have_header 'In-Reply-To', /<#{thread_id_prefix}(.*)@#{Gitlab.config.gitlab.host}>/
- should have_header 'X-GitLab-Project', /#{project.name}/
+ is_expected.to have_header 'References', /<#{thread_id_prefix}(.*)@#{Gitlab.config.gitlab.host}>/
+ is_expected.to have_header 'In-Reply-To', /<#{thread_id_prefix}(.*)@#{Gitlab.config.gitlab.host}>/
+ is_expected.to have_header 'X-GitLab-Project', /#{project.name}/
end
end
@@ -58,30 +58,30 @@ describe Notify do
it_behaves_like 'an email sent from GitLab'
it 'is sent to the new user' do
- should deliver_to new_user.email
+ is_expected.to deliver_to new_user.email
end
it 'has the correct subject' do
- should have_subject /^Account was created for you$/i
+ is_expected.to have_subject /^Account was created for you$/i
end
it 'contains the new user\'s login name' do
- should have_body_text /#{new_user.email}/
+ is_expected.to have_body_text /#{new_user.email}/
end
it 'contains the password text' do
- should have_body_text /Click here to set your password/
+ is_expected.to have_body_text /Click here to set your password/
end
it 'includes a link for user to set password' do
params = "reset_password_token=#{token}"
- should have_body_text(
+ is_expected.to have_body_text(
%r{http://localhost(:\d+)?/users/password/edit\?#{params}}
)
end
it 'includes a link to the site' do
- should have_body_text /#{example_site_path}/
+ is_expected.to have_body_text /#{example_site_path}/
end
end
@@ -95,23 +95,23 @@ describe Notify do
it_behaves_like 'an email sent from GitLab'
it 'is sent to the new user' do
- should deliver_to new_user.email
+ is_expected.to deliver_to new_user.email
end
it 'has the correct subject' do
- should have_subject /^Account was created for you$/i
+ is_expected.to have_subject /^Account was created for you$/i
end
it 'contains the new user\'s login name' do
- should have_body_text /#{new_user.email}/
+ is_expected.to have_body_text /#{new_user.email}/
end
it 'should not contain the new user\'s password' do
- should_not have_body_text /password/
+ is_expected.not_to have_body_text /password/
end
it 'includes a link to the site' do
- should have_body_text /#{example_site_path}/
+ is_expected.to have_body_text /#{example_site_path}/
end
end
@@ -123,19 +123,19 @@ describe Notify do
it_behaves_like 'an email sent from GitLab'
it 'is sent to the new user' do
- should deliver_to key.user.email
+ is_expected.to deliver_to key.user.email
end
it 'has the correct subject' do
- should have_subject /^SSH key was added to your account$/i
+ is_expected.to have_subject /^SSH key was added to your account$/i
end
it 'contains the new ssh key title' do
- should have_body_text /#{key.title}/
+ is_expected.to have_body_text /#{key.title}/
end
it 'includes a link to ssh keys page' do
- should have_body_text /#{profile_keys_path}/
+ is_expected.to have_body_text /#{profile_keys_path}/
end
end
@@ -145,19 +145,19 @@ describe Notify do
subject { Notify.new_email_email(email.id) }
it 'is sent to the new user' do
- should deliver_to email.user.email
+ is_expected.to deliver_to email.user.email
end
it 'has the correct subject' do
- should have_subject /^Email was added to your account$/i
+ is_expected.to have_subject /^Email was added to your account$/i
end
it 'contains the new email address' do
- should have_body_text /#{email.email}/
+ is_expected.to have_body_text /#{email.email}/
end
it 'includes a link to emails page' do
- should have_body_text /#{profile_emails_path}/
+ is_expected.to have_body_text /#{profile_emails_path}/
end
end
@@ -170,12 +170,12 @@ describe Notify do
shared_examples 'an assignee email' do
it 'is sent as the author' do
sender = subject.header[:from].addrs[0]
- sender.display_name.should eq(current_user.name)
- sender.address.should eq(gitlab_sender)
+ expect(sender.display_name).to eq(current_user.name)
+ expect(sender.address).to eq(gitlab_sender)
end
it 'is sent to the assignee' do
- should deliver_to assignee.email
+ is_expected.to deliver_to assignee.email
end
end
@@ -190,11 +190,11 @@ describe Notify do
it_behaves_like 'an email starting a new thread', 'issue'
it 'has the correct subject' do
- should have_subject /#{project.name} \| #{issue.title} \(##{issue.iid}\)/
+ is_expected.to have_subject /#{project.name} \| #{issue.title} \(##{issue.iid}\)/
end
it 'contains a link to the new issue' do
- should have_body_text /#{project_issue_path project, issue}/
+ is_expected.to have_body_text /#{project_issue_path project, issue}/
end
end
@@ -202,7 +202,7 @@ describe Notify do
subject { Notify.new_issue_email(issue_with_description.assignee_id, issue_with_description.id) }
it 'contains the description' do
- should have_body_text /#{issue_with_description.description}/
+ is_expected.to have_body_text /#{issue_with_description.description}/
end
end
@@ -214,24 +214,24 @@ describe Notify do
it 'is sent as the author' do
sender = subject.header[:from].addrs[0]
- sender.display_name.should eq(current_user.name)
- sender.address.should eq(gitlab_sender)
+ expect(sender.display_name).to eq(current_user.name)
+ expect(sender.address).to eq(gitlab_sender)
end
it 'has the correct subject' do
- should have_subject /#{issue.title} \(##{issue.iid}\)/
+ is_expected.to have_subject /#{issue.title} \(##{issue.iid}\)/
end
it 'contains the name of the previous assignee' do
- should have_body_text /#{previous_assignee.name}/
+ is_expected.to have_body_text /#{previous_assignee.name}/
end
it 'contains the name of the new assignee' do
- should have_body_text /#{assignee.name}/
+ is_expected.to have_body_text /#{assignee.name}/
end
it 'contains a link to the issue' do
- should have_body_text /#{project_issue_path project, issue}/
+ is_expected.to have_body_text /#{project_issue_path project, issue}/
end
end
@@ -243,24 +243,24 @@ describe Notify do
it 'is sent as the author' do
sender = subject.header[:from].addrs[0]
- sender.display_name.should eq(current_user.name)
- sender.address.should eq(gitlab_sender)
+ expect(sender.display_name).to eq(current_user.name)
+ expect(sender.address).to eq(gitlab_sender)
end
it 'has the correct subject' do
- should have_subject /#{issue.title} \(##{issue.iid}\)/i
+ is_expected.to have_subject /#{issue.title} \(##{issue.iid}\)/i
end
it 'contains the new status' do
- should have_body_text /#{status}/i
+ is_expected.to have_body_text /#{status}/i
end
it 'contains the user name' do
- should have_body_text /#{current_user.name}/i
+ is_expected.to have_body_text /#{current_user.name}/i
end
it 'contains a link to the issue' do
- should have_body_text /#{project_issue_path project, issue}/
+ is_expected.to have_body_text /#{project_issue_path project, issue}/
end
end
@@ -278,23 +278,23 @@ describe Notify do
it_behaves_like 'an email starting a new thread', 'merge_request'
it 'has the correct subject' do
- should have_subject /#{merge_request.title} \(##{merge_request.iid}\)/
+ is_expected.to have_subject /#{merge_request.title} \(##{merge_request.iid}\)/
end
it 'contains a link to the new merge request' do
- should have_body_text /#{project_merge_request_path(project, merge_request)}/
+ is_expected.to have_body_text /#{project_merge_request_path(project, merge_request)}/
end
it 'contains the source branch for the merge request' do
- should have_body_text /#{merge_request.source_branch}/
+ is_expected.to have_body_text /#{merge_request.source_branch}/
end
it 'contains the target branch for the merge request' do
- should have_body_text /#{merge_request.target_branch}/
+ is_expected.to have_body_text /#{merge_request.target_branch}/
end
it 'has the correct message-id set' do
- should have_header 'Message-ID', "<merge_request_#{merge_request.id}@#{Gitlab.config.gitlab.host}>"
+ is_expected.to have_header 'Message-ID', "<merge_request_#{merge_request.id}@#{Gitlab.config.gitlab.host}>"
end
end
@@ -302,7 +302,7 @@ describe Notify do
subject { Notify.new_merge_request_email(merge_request_with_description.assignee_id, merge_request_with_description.id) }
it 'contains the description' do
- should have_body_text /#{merge_request_with_description.description}/
+ is_expected.to have_body_text /#{merge_request_with_description.description}/
end
end
@@ -314,24 +314,24 @@ describe Notify do
it 'is sent as the author' do
sender = subject.header[:from].addrs[0]
- sender.display_name.should eq(current_user.name)
- sender.address.should eq(gitlab_sender)
+ expect(sender.display_name).to eq(current_user.name)
+ expect(sender.address).to eq(gitlab_sender)
end
it 'has the correct subject' do
- should have_subject /#{merge_request.title} \(##{merge_request.iid}\)/
+ is_expected.to have_subject /#{merge_request.title} \(##{merge_request.iid}\)/
end
it 'contains the name of the previous assignee' do
- should have_body_text /#{previous_assignee.name}/
+ is_expected.to have_body_text /#{previous_assignee.name}/
end
it 'contains the name of the new assignee' do
- should have_body_text /#{assignee.name}/
+ is_expected.to have_body_text /#{assignee.name}/
end
it 'contains a link to the merge request' do
- should have_body_text /#{project_merge_request_path project, merge_request}/
+ is_expected.to have_body_text /#{project_merge_request_path project, merge_request}/
end
end
@@ -343,24 +343,24 @@ describe Notify do
it 'is sent as the author' do
sender = subject.header[:from].addrs[0]
- sender.display_name.should eq(current_user.name)
- sender.address.should eq(gitlab_sender)
+ expect(sender.display_name).to eq(current_user.name)
+ expect(sender.address).to eq(gitlab_sender)
end
it 'has the correct subject' do
- should have_subject /#{merge_request.title} \(##{merge_request.iid}\)/i
+ is_expected.to have_subject /#{merge_request.title} \(##{merge_request.iid}\)/i
end
it 'contains the new status' do
- should have_body_text /#{status}/i
+ is_expected.to have_body_text /#{status}/i
end
it 'contains the user name' do
- should have_body_text /#{current_user.name}/i
+ is_expected.to have_body_text /#{current_user.name}/i
end
it 'contains a link to the merge request' do
- should have_body_text /#{project_merge_request_path project, merge_request}/
+ is_expected.to have_body_text /#{project_merge_request_path project, merge_request}/
end
end
@@ -372,20 +372,20 @@ describe Notify do
it 'is sent as the merge author' do
sender = subject.header[:from].addrs[0]
- sender.display_name.should eq(merge_author.name)
- sender.address.should eq(gitlab_sender)
+ expect(sender.display_name).to eq(merge_author.name)
+ expect(sender.address).to eq(gitlab_sender)
end
it 'has the correct subject' do
- should have_subject /#{merge_request.title} \(##{merge_request.iid}\)/
+ is_expected.to have_subject /#{merge_request.title} \(##{merge_request.iid}\)/
end
it 'contains the new status' do
- should have_body_text /merged/i
+ is_expected.to have_body_text /merged/i
end
it 'contains a link to the merge request' do
- should have_body_text /#{project_merge_request_path project, merge_request}/
+ is_expected.to have_body_text /#{project_merge_request_path project, merge_request}/
end
end
end
@@ -399,15 +399,15 @@ describe Notify do
it_behaves_like 'an email sent from GitLab'
it 'has the correct subject' do
- should have_subject /Project was moved/
+ is_expected.to have_subject /Project was moved/
end
it 'contains name of project' do
- should have_body_text /#{project.name_with_namespace}/
+ is_expected.to have_body_text /#{project.name_with_namespace}/
end
it 'contains new user role' do
- should have_body_text /#{project.ssh_url_to_repo}/
+ is_expected.to have_body_text /#{project.ssh_url_to_repo}/
end
end
@@ -422,13 +422,13 @@ describe Notify do
it_behaves_like 'an email sent from GitLab'
it 'has the correct subject' do
- should have_subject /Access to project was granted/
+ is_expected.to have_subject /Access to project was granted/
end
it 'contains name of project' do
- should have_body_text /#{project.name}/
+ is_expected.to have_body_text /#{project.name}/
end
it 'contains new user role' do
- should have_body_text /#{project_member.human_access}/
+ is_expected.to have_body_text /#{project_member.human_access}/
end
end
@@ -437,29 +437,29 @@ describe Notify do
let(:note) { create(:note, project: project, author: note_author) }
before :each do
- Note.stub(:find).with(note.id).and_return(note)
+ allow(Note).to receive(:find).with(note.id).and_return(note)
end
shared_examples 'a note email' do
it 'is sent as the author' do
sender = subject.header[:from].addrs[0]
- sender.display_name.should eq(note_author.name)
- sender.address.should eq(gitlab_sender)
+ expect(sender.display_name).to eq(note_author.name)
+ expect(sender.address).to eq(gitlab_sender)
end
it 'is sent to the given recipient' do
- should deliver_to recipient.notification_email
+ is_expected.to deliver_to recipient.notification_email
end
it 'contains the message from the note' do
- should have_body_text /#{note.note}/
+ is_expected.to have_body_text /#{note.note}/
end
end
describe 'on a commit' do
let(:commit) { project.repository.commit }
- before(:each) { note.stub(:noteable).and_return(commit) }
+ before(:each) { allow(note).to receive(:noteable).and_return(commit) }
subject { Notify.note_commit_email(recipient.id, note.id) }
@@ -467,18 +467,18 @@ describe Notify do
it_behaves_like 'an answer to an existing thread', 'commits'
it 'has the correct subject' do
- should have_subject /#{commit.title} \(#{commit.short_id}\)/
+ is_expected.to have_subject /#{commit.title} \(#{commit.short_id}\)/
end
it 'contains a link to the commit' do
- should have_body_text commit.short_id
+ is_expected.to have_body_text commit.short_id
end
end
describe 'on a merge request' do
let(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
let(:note_on_merge_request_path) { project_merge_request_path(project, merge_request, anchor: "note_#{note.id}") }
- before(:each) { note.stub(:noteable).and_return(merge_request) }
+ before(:each) { allow(note).to receive(:noteable).and_return(merge_request) }
subject { Notify.note_merge_request_email(recipient.id, note.id) }
@@ -486,18 +486,18 @@ describe Notify do
it_behaves_like 'an answer to an existing thread', 'merge_request'
it 'has the correct subject' do
- should have_subject /#{merge_request.title} \(##{merge_request.iid}\)/
+ is_expected.to have_subject /#{merge_request.title} \(##{merge_request.iid}\)/
end
it 'contains a link to the merge request note' do
- should have_body_text /#{note_on_merge_request_path}/
+ is_expected.to have_body_text /#{note_on_merge_request_path}/
end
end
describe 'on an issue' do
let(:issue) { create(:issue, project: project) }
let(:note_on_issue_path) { project_issue_path(project, issue, anchor: "note_#{note.id}") }
- before(:each) { note.stub(:noteable).and_return(issue) }
+ before(:each) { allow(note).to receive(:noteable).and_return(issue) }
subject { Notify.note_issue_email(recipient.id, note.id) }
@@ -505,11 +505,11 @@ describe Notify do
it_behaves_like 'an answer to an existing thread', 'issue'
it 'has the correct subject' do
- should have_subject /#{issue.title} \(##{issue.iid}\)/
+ is_expected.to have_subject /#{issue.title} \(##{issue.iid}\)/
end
it 'contains a link to the issue note' do
- should have_body_text /#{note_on_issue_path}/
+ is_expected.to have_body_text /#{note_on_issue_path}/
end
end
end
@@ -525,15 +525,15 @@ describe Notify do
it_behaves_like 'an email sent from GitLab'
it 'has the correct subject' do
- should have_subject /Access to group was granted/
+ is_expected.to have_subject /Access to group was granted/
end
it 'contains name of project' do
- should have_body_text /#{group.name}/
+ is_expected.to have_body_text /#{group.name}/
end
it 'contains new user role' do
- should have_body_text /#{membership.human_access}/
+ is_expected.to have_body_text /#{membership.human_access}/
end
end
@@ -551,15 +551,15 @@ describe Notify do
it_behaves_like 'an email sent from GitLab'
it 'is sent to the new user' do
- should deliver_to 'new-email@mail.com'
+ is_expected.to deliver_to 'new-email@mail.com'
end
it 'has the correct subject' do
- should have_subject "Confirmation instructions"
+ is_expected.to have_subject "Confirmation instructions"
end
it 'includes a link to the site' do
- should have_body_text /#{example_site_path}/
+ is_expected.to have_body_text /#{example_site_path}/
end
end
@@ -574,28 +574,28 @@ describe Notify do
it 'is sent as the author' do
sender = subject.header[:from].addrs[0]
- sender.display_name.should eq(user.name)
- sender.address.should eq(gitlab_sender)
+ expect(sender.display_name).to eq(user.name)
+ expect(sender.address).to eq(gitlab_sender)
end
it 'is sent to recipient' do
- should deliver_to 'devs@company.name'
+ is_expected.to deliver_to 'devs@company.name'
end
it 'has the correct subject' do
- should have_subject /#{commits.length} new commits pushed to repository/
+ is_expected.to have_subject /#{commits.length} new commits pushed to repository/
end
it 'includes commits list' do
- should have_body_text /Change some files/
+ is_expected.to have_body_text /Change some files/
end
it 'includes diffs' do
- should have_body_text /def archive_formats_regex/
+ is_expected.to have_body_text /def archive_formats_regex/
end
it 'contains a link to the diff' do
- should have_body_text /#{diff_path}/
+ is_expected.to have_body_text /#{diff_path}/
end
end
@@ -610,28 +610,28 @@ describe Notify do
it 'is sent as the author' do
sender = subject.header[:from].addrs[0]
- sender.display_name.should eq(user.name)
- sender.address.should eq(gitlab_sender)
+ expect(sender.display_name).to eq(user.name)
+ expect(sender.address).to eq(gitlab_sender)
end
it 'is sent to recipient' do
- should deliver_to 'devs@company.name'
+ is_expected.to deliver_to 'devs@company.name'
end
it 'has the correct subject' do
- should have_subject /#{commits.first.title}/
+ is_expected.to have_subject /#{commits.first.title}/
end
it 'includes commits list' do
- should have_body_text /Change some files/
+ is_expected.to have_body_text /Change some files/
end
it 'includes diffs' do
- should have_body_text /def archive_formats_regex/
+ is_expected.to have_body_text /def archive_formats_regex/
end
it 'contains a link to the diff' do
- should have_body_text /#{diff_path}/
+ is_expected.to have_body_text /#{diff_path}/
end
end
end