From 931c56f822c21e5f77743297603cfff5065eb772 Mon Sep 17 00:00:00 2001
From: Douwe Maan <douwe@gitlab.com>
Date: Tue, 17 Nov 2015 16:53:15 +0100
Subject: [PATCH] Add tests for merge request update.

---
 spec/services/issues/update_service_spec.rb         |  2 +-
 spec/services/merge_requests/update_service_spec.rb | 11 +++++++----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/spec/services/issues/update_service_spec.rb b/spec/services/issues/update_service_spec.rb
index 6a9053753c..f55527ee9a 100644
--- a/spec/services/issues/update_service_spec.rb
+++ b/spec/services/issues/update_service_spec.rb
@@ -36,7 +36,7 @@ describe Issues::UpdateService do
       it { expect(@issue.labels.count).to eq(1) }
       it { expect(@issue.labels.first.title).to eq('Bug') }
 
-      it 'should send email to user2 about assign of new issue and email to user about issue unassignment' do
+      it 'should send email to user2 about assign of new issue and email to user3 about issue unassignment' do
         deliveries = ActionMailer::Base.deliveries
         email = deliveries.last
         recipients = deliveries.last(2).map(&:to).flatten
diff --git a/spec/services/merge_requests/update_service_spec.rb b/spec/services/merge_requests/update_service_spec.rb
index c75173c145..2ed51d223b 100644
--- a/spec/services/merge_requests/update_service_spec.rb
+++ b/spec/services/merge_requests/update_service_spec.rb
@@ -3,7 +3,8 @@ require 'spec_helper'
 describe MergeRequests::UpdateService do
   let(:user) { create(:user) }
   let(:user2) { create(:user) }
-  let(:merge_request) { create(:merge_request, :simple, title: 'Old title') }
+  let(:user3) { create(:user) }
+  let(:merge_request) { create(:merge_request, :simple, title: 'Old title', assignee_id: user3.id) }
   let(:project) { merge_request.project }
   let(:label) { create(:label) }
 
@@ -47,9 +48,11 @@ describe MergeRequests::UpdateService do
                                with(@merge_request, 'update')
       end
 
-      it 'should send email to user2 about assign of new merge_request' do
-        email = ActionMailer::Base.deliveries.last
-        expect(email.to.first).to eq(user2.email)
+      it 'should send email to user2 about assign of new merge request and email to user3 about merge request unassignment' do
+        deliveries = ActionMailer::Base.deliveries
+        email = deliveries.last
+        recipients = deliveries.last(2).map(&:to).flatten
+        expect(recipients).to include(user2.email, user3.email)
         expect(email.subject).to include(merge_request.title)
       end
 
-- 
2.30.9