Extract EE specific files/lines for quick actions tests
We have the following files containing EE specific code. We should move them to ee/
spec/services/notes/quick_actions_service_spec.rb
diff --git a/spec/services/notes/quick_actions_service_spec.rb b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/services/notes/quick_actions_service_spec.rb
index 14d62763a5b..fbd808a3efc 100644
--- a/spec/services/notes/quick_actions_service_spec.rb
+++ b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/services/notes/quick_actions_service_spec.rb
@@ -171,7 +171,7 @@ describe Notes::QuickActionsService do
end
end
- context 'CE restriction for issue assignees' do
+ context 'Issue assignees' do
describe '/assign' do
let(:project) { create(:project) }
let(:maintainer) { create(:user).tap { |u| project.add_maintainer(u) } }
@@ -193,7 +193,7 @@ describe Notes::QuickActionsService do
_, command_params = service.extract_commands(note)
service.execute(command_params, note)
- expect(note.noteable.assignees.count).to eq(1)
+ expect(note.noteable.assignees.count).to eq(2)
end
end
end
spec/services/quick_actions/interpret_service_spec.rb
diff --git a/spec/services/quick_actions/interpret_service_spec.rb b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/services/quick_actions/interpret_service_spec.rb
index 938764f40b0..d001dca9261 100644
--- a/spec/services/quick_actions/interpret_service_spec.rb
+++ b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/services/quick_actions/interpret_service_spec.rb
@@ -15,6 +15,8 @@ describe QuickActions::InterpretService do
let(:service) { described_class.new(project, developer) }
before do
+ stub_licensed_features(multiple_issue_assignees: false)
+
project.add_developer(developer)
end
@@ -322,6 +324,23 @@ describe QuickActions::InterpretService do
end
end
+ shared_examples 'weight command' do
+ it 'populates weight: 5 if content contains /weight 5' do
+ _, updates = service.execute(content, issuable)
+
+ expect(updates).to eq(weight: 5)
+ end
+ end
+
+ shared_examples 'clear weight command' do
+ it 'populates weight: nil if content contains /clear_weight' do
+ issuable.update(weight: 5)
+ _, updates = service.execute(content, issuable)
+
+ expect(updates).to eq(weight: nil)
+ end
+ end
+
shared_examples 'duplicate command' do
it 'fetches issue and populates canonical_issue_id if content contains /duplicate issue_reference' do
issue_duplicate # populate the issue
@@ -465,6 +484,29 @@ describe QuickActions::InterpretService do
let(:issuable) { build(:merge_request, source_project: project) }
end
end
+
+ context 'not approved merge request can not be merged' do
+ before do
+ merge_request.target_project.update(approvals_before_merge: 1)
+ end
+
+ it_behaves_like 'empty command' do
+ let(:content) { "/merge" }
+ let(:issuable) { build(:merge_request, source_project: project) }
+ end
+ end
+
+ context 'approved merge request can be merged' do
+ before do
+ merge_request.update(approvals_before_merge: 1)
+ merge_request.approvals.create(user: developer)
+ end
+
+ it_behaves_like 'empty command' do
+ let(:content) { "/merge" }
+ let(:issuable) { build(:merge_request, source_project: project) }
+ end
+ end
end
it_behaves_like 'title command' do
@@ -827,6 +869,40 @@ describe QuickActions::InterpretService do
let(:issuable) { merge_request }
end
+ context 'issuable weights licensed' do
+ before do
+ stub_licensed_features(issue_weights: true)
+ end
+
+ it_behaves_like 'weight command' do
+ let(:content) { '/weight 5'}
+ let(:issuable) { issue }
+ end
+
+ it_behaves_like 'clear weight command' do
+ let(:content) { '/clear_weight' }
+ let(:issuable) { issue }
+ end
+ end
+
+ context 'issuable weights unlicensed' do
+ before do
+ stub_licensed_features(issue_weights: false)
+ end
+
+ it 'does not recognise /weight X' do
+ _, updates = service.execute('/weight 5', issue)
+
+ expect(updates).to be_empty
+ end
+
+ it 'does not recognise /clear_weight' do
+ _, updates = service.execute('/clear_weight', issue)
+
+ expect(updates).to be_empty
+ end
+ end
+
context '/todo' do
let(:content) { '/todo' }
@@ -1526,5 +1602,16 @@ describe QuickActions::InterpretService do
end
end
end
+
+ # EE-specific tests
+
+ describe 'weight command' do
+ let(:content) { '/weight 4' }
+
+ it 'includes the number' do
+ _, explanations = service.explain(content, issue)
+ expect(explanations).to eq(['Sets weight to 4.'])
+ end
+ end
end
end
Edited by Yorick Peterse