summaryrefslogtreecommitdiff
path: root/spec/services/discussions
diff options
context:
space:
mode:
Diffstat (limited to 'spec/services/discussions')
-rw-r--r--spec/services/discussions/resolve_service_spec.rb14
-rw-r--r--spec/services/discussions/unresolve_service_spec.rb29
2 files changed, 41 insertions, 2 deletions
diff --git a/spec/services/discussions/resolve_service_spec.rb b/spec/services/discussions/resolve_service_spec.rb
index 9cc27973bcb..a6e1bad30ce 100644
--- a/spec/services/discussions/resolve_service_spec.rb
+++ b/spec/services/discussions/resolve_service_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Discussions::ResolveService do
+RSpec.describe Discussions::ResolveService, feature_category: :code_review_workflow do
describe '#execute' do
let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { create(:user, developer_projects: [project]) }
@@ -46,6 +46,12 @@ RSpec.describe Discussions::ResolveService do
service.execute
end
+ it 'sends GraphQL triggers' do
+ expect(GraphqlTriggers).to receive(:merge_request_merge_status_updated).with(discussion.noteable)
+
+ service.execute
+ end
+
context 'with a project that requires all discussion to be resolved' do
before do
project.update!(only_allow_merge_if_all_discussions_are_resolved: true)
@@ -122,6 +128,12 @@ RSpec.describe Discussions::ResolveService do
service.execute
end
+
+ it 'does not send GraphQL triggers' do
+ expect(GraphqlTriggers).not_to receive(:merge_request_merge_status_updated).with(discussion.noteable)
+
+ service.execute
+ end
end
context 'when resolving a discussion' do
diff --git a/spec/services/discussions/unresolve_service_spec.rb b/spec/services/discussions/unresolve_service_spec.rb
index 0009239232c..e9f58e4e10e 100644
--- a/spec/services/discussions/unresolve_service_spec.rb
+++ b/spec/services/discussions/unresolve_service_spec.rb
@@ -2,7 +2,7 @@
require "spec_helper"
-RSpec.describe Discussions::UnresolveService do
+RSpec.describe Discussions::UnresolveService, feature_category: :code_review_workflow do
describe "#execute" do
let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { create(:user, developer_projects: [project]) }
@@ -29,5 +29,32 @@ RSpec.describe Discussions::UnresolveService do
service.execute
end
+
+ it "sends GraphQL triggers" do
+ expect(GraphqlTriggers).to receive(:merge_request_merge_status_updated).with(discussion.noteable)
+
+ service.execute
+ end
+
+ context "when there are existing unresolved discussions" do
+ before do
+ create(:diff_note_on_merge_request, noteable: merge_request, project: project).to_discussion
+ end
+
+ it "does not send a GraphQL triggers" do
+ expect(GraphqlTriggers).not_to receive(:merge_request_merge_status_updated)
+
+ service.execute
+ end
+ end
+
+ context "when the noteable is not a merge request" do
+ it "does not send a GraphQL triggers" do
+ expect(discussion).to receive(:for_merge_request?).and_return(false)
+ expect(GraphqlTriggers).not_to receive(:merge_request_merge_status_updated)
+
+ service.execute
+ end
+ end
end
end