Commit a5263b58 authored by Lucas Zampieri's avatar Lucas Zampieri Committed by Bob Van Landuyt

Trigger webhooks when all discussions have been resolved

parent a21b037b
......@@ -6,6 +6,7 @@ module MergeRequests
return unless merge_request.discussions_resolved?
SystemNoteService.resolve_all_discussions(merge_request, project, current_user)
execute_hooks(merge_request, 'update')
notification_service.async.resolve_all_discussions(merge_request, current_user)
end
end
......
......@@ -7,6 +7,7 @@ module Gitlab
%i[
assignee_id
author_id
blocking_discussions_resolved
created_at
description
head_pipeline_id
......@@ -57,7 +58,8 @@ module Gitlab
human_time_estimate: merge_request.human_time_estimate,
assignee_ids: merge_request.assignee_ids,
assignee_id: merge_request.assignee_ids.first, # This key is deprecated
state: merge_request.state # This key is deprecated
state: merge_request.state, # This key is deprecated
blocking_discussions_resolved: merge_request.mergeable_discussions_state?
}
merge_request.attributes.with_indifferent_access.slice(*self.class.safe_hook_attributes)
......
......@@ -15,6 +15,7 @@ RSpec.describe Gitlab::HookData::MergeRequestBuilder do
assignee_id
assignee_ids
author_id
blocking_discussions_resolved
created_at
description
head_pipeline_id
......
......@@ -26,6 +26,12 @@ RSpec.describe MergeRequests::ResolvedDiscussionNotificationService do
subject.execute(merge_request)
end
it "doesn't send a webhook" do
expect_any_instance_of(MergeRequests::BaseService).not_to receive(:execute_hooks)
subject.execute(merge_request)
end
end
context "when all discussions are resolved" do
......@@ -44,6 +50,12 @@ RSpec.describe MergeRequests::ResolvedDiscussionNotificationService do
subject.execute(merge_request)
end
it "sends a webhook" do
expect_any_instance_of(MergeRequests::BaseService).to receive(:execute_hooks).with(merge_request, 'update')
subject.execute(merge_request)
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment