summaryrefslogtreecommitdiff
path: root/spec/services/quick_actions/interpret_service_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-05-11 12:12:30 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-05-11 12:12:30 +0000
commit0b54f87a31c23544ca5917bf772ce9c64a61562c (patch)
tree79d56df6750e84fd4a10205d9dcce293f7c5d491 /spec/services/quick_actions/interpret_service_spec.rb
parente348fb4c1b9eaf21655001dc4346ceb0c0c3d5b4 (diff)
downloadgitlab-ce-0b54f87a31c23544ca5917bf772ce9c64a61562c.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services/quick_actions/interpret_service_spec.rb')
-rw-r--r--spec/services/quick_actions/interpret_service_spec.rb123
1 files changed, 13 insertions, 110 deletions
diff --git a/spec/services/quick_actions/interpret_service_spec.rb b/spec/services/quick_actions/interpret_service_spec.rb
index 8a0c8f519b0..966782aca98 100644
--- a/spec/services/quick_actions/interpret_service_spec.rb
+++ b/spec/services/quick_actions/interpret_service_spec.rb
@@ -2127,116 +2127,8 @@ RSpec.describe QuickActions::InterpretService, feature_category: :team_planning
end
end
- context 'relate command' do
- let_it_be_with_refind(:group) { create(:group) }
-
- shared_examples 'relate command' do
- it 'relates issues' do
- service.execute(content, issue)
-
- expect(IssueLink.where(source: issue).map(&:target)).to match_array(issues_related)
- end
- end
-
- context 'user is member of group' do
- before do
- group.add_developer(developer)
- end
-
- context 'relate a single issue' do
- let(:other_issue) { create(:issue, project: project) }
- let(:issues_related) { [other_issue] }
- let(:content) { "/relate #{other_issue.to_reference}" }
-
- it_behaves_like 'relate command'
- end
-
- context 'relate multiple issues at once' do
- let(:second_issue) { create(:issue, project: project) }
- let(:third_issue) { create(:issue, project: project) }
- let(:issues_related) { [second_issue, third_issue] }
- let(:content) { "/relate #{second_issue.to_reference} #{third_issue.to_reference}" }
-
- it_behaves_like 'relate command'
- end
-
- context 'when quick action target is unpersisted' do
- let(:issue) { build(:issue, project: project) }
- let(:other_issue) { create(:issue, project: project) }
- let(:issues_related) { [other_issue] }
- let(:content) { "/relate #{other_issue.to_reference}" }
-
- it 'relates the issues after the issue is persisted' do
- service.execute(content, issue)
-
- issue.save!
-
- expect(IssueLink.where(source: issue).map(&:target)).to match_array(issues_related)
- end
- end
-
- context 'empty relate command' do
- let(:issues_related) { [] }
- let(:content) { '/relate' }
-
- it_behaves_like 'relate command'
- end
-
- context 'already having related issues' do
- let(:second_issue) { create(:issue, project: project) }
- let(:third_issue) { create(:issue, project: project) }
- let(:issues_related) { [second_issue, third_issue] }
- let(:content) { "/relate #{third_issue.to_reference(project)}" }
-
- before do
- create(:issue_link, source: issue, target: second_issue)
- end
-
- it_behaves_like 'relate command'
- end
-
- context 'cross project' do
- let(:another_group) { create(:group, :public) }
- let(:other_project) { create(:project, group: another_group) }
-
- before do
- another_group.add_developer(developer)
- end
-
- context 'relate a cross project issue' do
- let(:other_issue) { create(:issue, project: other_project) }
- let(:issues_related) { [other_issue] }
- let(:content) { "/relate #{other_issue.to_reference(project)}" }
-
- it_behaves_like 'relate command'
- end
-
- context 'relate multiple cross projects issues at once' do
- let(:second_issue) { create(:issue, project: other_project) }
- let(:third_issue) { create(:issue, project: other_project) }
- let(:issues_related) { [second_issue, third_issue] }
- let(:content) { "/relate #{second_issue.to_reference(project)} #{third_issue.to_reference(project)}" }
-
- it_behaves_like 'relate command'
- end
-
- context 'relate a non-existing issue' do
- let(:issues_related) { [] }
- let(:content) { "/relate imaginary##{non_existing_record_iid}" }
-
- it_behaves_like 'relate command'
- end
-
- context 'relate a private issue' do
- let(:private_project) { create(:project, :private) }
- let(:other_issue) { create(:issue, project: private_project) }
- let(:issues_related) { [] }
- let(:content) { "/relate #{other_issue.to_reference(project)}" }
-
- it_behaves_like 'relate command'
- end
- end
- end
+ it_behaves_like 'issues link quick action', :relate do
+ let(:user) { developer }
end
context 'invite_email command' do
@@ -2996,6 +2888,17 @@ RSpec.describe QuickActions::InterpretService, feature_category: :team_planning
end
end
end
+
+ describe 'relate command' do
+ let_it_be(:other_issue) { create(:issue, project: project) }
+ let(:content) { "/relate #{other_issue.to_reference}" }
+
+ it 'includes explain message' do
+ _, explanations = service.explain(content, issue)
+
+ expect(explanations).to eq(["Marks this issue as related to #{other_issue.to_reference}."])
+ end
+ end
end
describe '#available_commands' do