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 ...@@ -6,6 +6,7 @@ module MergeRequests
return unless merge_request.discussions_resolved? return unless merge_request.discussions_resolved?
SystemNoteService.resolve_all_discussions(merge_request, project, current_user) SystemNoteService.resolve_all_discussions(merge_request, project, current_user)
execute_hooks(merge_request, 'update')
notification_service.async.resolve_all_discussions(merge_request, current_user) notification_service.async.resolve_all_discussions(merge_request, current_user)
end end
end end
......
...@@ -7,6 +7,7 @@ module Gitlab ...@@ -7,6 +7,7 @@ module Gitlab
%i[ %i[
assignee_id assignee_id
author_id author_id
blocking_discussions_resolved
created_at created_at
description description
head_pipeline_id head_pipeline_id
...@@ -57,7 +58,8 @@ module Gitlab ...@@ -57,7 +58,8 @@ module Gitlab
human_time_estimate: merge_request.human_time_estimate, human_time_estimate: merge_request.human_time_estimate,
assignee_ids: merge_request.assignee_ids, assignee_ids: merge_request.assignee_ids,
assignee_id: merge_request.assignee_ids.first, # This key is deprecated 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) merge_request.attributes.with_indifferent_access.slice(*self.class.safe_hook_attributes)
......
...@@ -15,6 +15,7 @@ RSpec.describe Gitlab::HookData::MergeRequestBuilder do ...@@ -15,6 +15,7 @@ RSpec.describe Gitlab::HookData::MergeRequestBuilder do
assignee_id assignee_id
assignee_ids assignee_ids
author_id author_id
blocking_discussions_resolved
created_at created_at
description description
head_pipeline_id head_pipeline_id
......
...@@ -26,6 +26,12 @@ RSpec.describe MergeRequests::ResolvedDiscussionNotificationService do ...@@ -26,6 +26,12 @@ RSpec.describe MergeRequests::ResolvedDiscussionNotificationService do
subject.execute(merge_request) subject.execute(merge_request)
end 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 end
context "when all discussions are resolved" do context "when all discussions are resolved" do
...@@ -44,6 +50,12 @@ RSpec.describe MergeRequests::ResolvedDiscussionNotificationService do ...@@ -44,6 +50,12 @@ RSpec.describe MergeRequests::ResolvedDiscussionNotificationService do
subject.execute(merge_request) subject.execute(merge_request)
end 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 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