Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorPierre de La Morinerie <pierre@capitainetrain.com>2014-03-24 18:11:35 +0400
committerPierre de La Morinerie <pierre@capitainetrain.com>2014-03-24 18:11:35 +0400
commit65f5496e0210be96b4803f655d1a4c94ef1e07fe (patch)
treec38347e40b1982ebbe2599ff40df5cc3dea8cf92 /spec
parent36ea864504854558c0dd3f626177a638022c312d (diff)
Fix the merge notification email not being sent
The 'author_id_of_changes' attribute is not persisted in the database. As we retrieve the merge request from the DB just before sending the email, this attribute was always nil. Also there was no tests for the merge notification code - tests have been added. Fix #6605
Diffstat (limited to 'spec')
-rw-r--r--spec/mailers/notify_spec.rb24
-rw-r--r--spec/services/notification_service_spec.rb6
2 files changed, 27 insertions, 3 deletions
diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb
index f990ed659b8..22d60429ccd 100644
--- a/spec/mailers/notify_spec.rb
+++ b/spec/mailers/notify_spec.rb
@@ -229,6 +229,7 @@ describe Notify do
end
context 'for merge requests' do
+ let(:merge_author) { create(:user) }
let(:merge_request) { create(:merge_request, author: current_user, assignee: assignee, source_project: project, target_project: project) }
let(:merge_request_with_description) { create(:merge_request, author: current_user, assignee: assignee, source_project: project, target_project: project, description: Faker::Lorem.sentence) }
@@ -288,7 +289,30 @@ describe Notify do
it 'contains a link to the merge request' do
should have_body_text /#{project_merge_request_path project, merge_request}/
end
+ end
+
+ describe 'that are merged' do
+ subject { Notify.merged_merge_request_email(recipient.id, merge_request.id, merge_author.id) }
+
+ it_behaves_like 'a multiple recipients email'
+
+ 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)
+ end
+
+ it 'has the correct subject' do
+ should have_subject /#{merge_request.title} \(!#{merge_request.iid}\)/
+ end
+ it 'contains the new status' do
+ should 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}/
+ end
end
end
end
diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb
index 077ad8b6e12..59c17d6e4d7 100644
--- a/spec/services/notification_service_spec.rb
+++ b/spec/services/notification_service_spec.rb
@@ -233,15 +233,15 @@ describe NotificationService do
should_email(@u_watcher.id)
should_not_email(@u_participating.id)
should_not_email(@u_disabled.id)
- notification.merge_mr(merge_request)
+ notification.merge_mr(merge_request, @u_disabled)
end
def should_email(user_id)
- Notify.should_receive(:merged_merge_request_email).with(user_id, merge_request.id)
+ Notify.should_receive(:merged_merge_request_email).with(user_id, merge_request.id, @u_disabled.id)
end
def should_not_email(user_id)
- Notify.should_not_receive(:merged_merge_request_email).with(user_id, merge_request.id)
+ Notify.should_not_receive(:merged_merge_request_email).with(user_id, merge_request.id, @u_disabled.id)
end
end
end