summaryrefslogtreecommitdiff
path: root/spec/services/merge_requests/update_service_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/services/merge_requests/update_service_spec.rb')
-rw-r--r--spec/services/merge_requests/update_service_spec.rb56
1 files changed, 55 insertions, 1 deletions
diff --git a/spec/services/merge_requests/update_service_spec.rb b/spec/services/merge_requests/update_service_spec.rb
index 99703c7a8ec..104e63ccfee 100644
--- a/spec/services/merge_requests/update_service_spec.rb
+++ b/spec/services/merge_requests/update_service_spec.rb
@@ -53,7 +53,7 @@ describe MergeRequests::UpdateService, services: true do
it { expect(@merge_request.assignee).to eq(user2) }
it { expect(@merge_request).to be_closed }
it { expect(@merge_request.labels.count).to eq(1) }
- it { expect(@merge_request.labels.first.title).to eq('Bug') }
+ it { expect(@merge_request.labels.first.title).to eq(label.name) }
it { expect(@merge_request.target_branch).to eq('target') }
it 'should execute hooks with update action' do
@@ -176,6 +176,60 @@ describe MergeRequests::UpdateService, services: true do
end
end
+ context "when the merge request is relabeled" do
+ it "sends notifications for subscribers of newly added labels" do
+ subscriber, non_subscriber = create_list(:user, 2)
+ label.toggle_subscription(subscriber)
+ 2.times { label.toggle_subscription(non_subscriber) }
+
+ opts = { label_ids: [label.id] }
+
+ perform_enqueued_jobs do
+ @merge_request = MergeRequests::UpdateService.new(project, user, opts).execute(merge_request)
+ end
+
+ @merge_request.reload
+ should_email(subscriber)
+ should_not_email(non_subscriber)
+ end
+
+ it "does send notifications for existing labels" do
+ second_label = create(:label)
+ merge_request.labels << label
+ subscriber, non_subscriber = create_list(:user, 2)
+ label.toggle_subscription(subscriber)
+ 2.times { label.toggle_subscription(non_subscriber) }
+
+ opts = { label_ids: [label.id, second_label.id] }
+
+ perform_enqueued_jobs do
+ @merge_request = MergeRequests::UpdateService.new(project, user, opts).execute(merge_request)
+ end
+
+ @merge_request.reload
+ should_email(subscriber)
+ should_not_email(non_subscriber)
+ end
+
+ it "does not send notifications for removed labels" do
+ second_label = create(:label)
+ merge_request.labels << label
+ subscriber, non_subscriber = create_list(:user, 2)
+ label.toggle_subscription(subscriber)
+ 2.times { label.toggle_subscription(non_subscriber) }
+
+ opts = { label_ids: [second_label.id] }
+
+ perform_enqueued_jobs do
+ @merge_request = MergeRequests::UpdateService.new(project, user, opts).execute(merge_request)
+ end
+
+ @merge_request.reload
+ should_not_email(subscriber)
+ should_not_email(non_subscriber)
+ end
+ end
+
context 'when MergeRequest has tasks' do
before { update_merge_request({ description: "- [ ] Task 1\n- [ ] Task 2" }) }