summaryrefslogtreecommitdiff
path: root/spec/services/system_notes
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-12-20 13:37:47 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-12-20 13:37:47 +0000
commitaee0a117a889461ce8ced6fcf73207fe017f1d99 (patch)
tree891d9ef189227a8445d83f35c1b0fc99573f4380 /spec/services/system_notes
parent8d46af3258650d305f53b819eabf7ab18d22f59e (diff)
downloadgitlab-ce-aee0a117a889461ce8ced6fcf73207fe017f1d99.tar.gz
Add latest changes from gitlab-org/gitlab@14-6-stable-eev14.6.0-rc42
Diffstat (limited to 'spec/services/system_notes')
-rw-r--r--spec/services/system_notes/commit_service_spec.rb2
-rw-r--r--spec/services/system_notes/issuables_service_spec.rb78
2 files changed, 58 insertions, 22 deletions
diff --git a/spec/services/system_notes/commit_service_spec.rb b/spec/services/system_notes/commit_service_spec.rb
index bd6b3ec953a..0399603980d 100644
--- a/spec/services/system_notes/commit_service_spec.rb
+++ b/spec/services/system_notes/commit_service_spec.rb
@@ -57,7 +57,7 @@ RSpec.describe SystemNotes::CommitService do
end
context 'with multiple existing commits' do
- let(:old_commits) { noteable.commits[3..-1] }
+ let(:old_commits) { noteable.commits[3..] }
context 'with oldrev' do
let(:oldrev) { noteable.commits[2].id }
diff --git a/spec/services/system_notes/issuables_service_spec.rb b/spec/services/system_notes/issuables_service_spec.rb
index fd481aa6ddb..7e53e66303b 100644
--- a/spec/services/system_notes/issuables_service_spec.rb
+++ b/spec/services/system_notes/issuables_service_spec.rb
@@ -199,6 +199,42 @@ RSpec.describe ::SystemNotes::IssuablesService do
end
end
+ describe '#request_attention' do
+ subject { service.request_attention(user) }
+
+ let(:user) { create(:user) }
+
+ it_behaves_like 'a system note' do
+ let(:action) { 'attention_requested' }
+ end
+
+ context 'when attention requested' do
+ it_behaves_like 'a note with overridable created_at'
+
+ it 'sets the note text' do
+ expect(subject.note).to eq "requested attention from @#{user.username}"
+ end
+ end
+ end
+
+ describe '#remove_attention_request' do
+ subject { service.remove_attention_request(user) }
+
+ let(:user) { create(:user) }
+
+ it_behaves_like 'a system note' do
+ let(:action) { 'attention_request_removed' }
+ end
+
+ context 'when attention request is removed' do
+ it_behaves_like 'a note with overridable created_at'
+
+ it 'sets the note text' do
+ expect(subject.note).to eq "removed attention request from @#{user.username}"
+ end
+ end
+ end
+
describe '#change_title' do
let(:noteable) { create(:issue, project: project, title: 'Lorem ipsum') }
@@ -274,9 +310,9 @@ RSpec.describe ::SystemNotes::IssuablesService do
describe '#cross_reference' do
let(:service) { described_class.new(noteable: noteable, author: author) }
- let(:mentioner) { create(:issue, project: project) }
+ let(:mentioned_in) { create(:issue, project: project) }
- subject { service.cross_reference(mentioner) }
+ subject { service.cross_reference(mentioned_in) }
it_behaves_like 'a system note' do
let(:action) { 'cross_reference' }
@@ -314,35 +350,35 @@ RSpec.describe ::SystemNotes::IssuablesService do
describe 'note_body' do
context 'cross-project' do
let(:project2) { create(:project, :repository) }
- let(:mentioner) { create(:issue, project: project2) }
+ let(:mentioned_in) { create(:issue, project: project2) }
context 'from Commit' do
- let(:mentioner) { project2.repository.commit }
+ let(:mentioned_in) { project2.repository.commit }
it 'references the mentioning commit' do
- expect(subject.note).to eq "mentioned in commit #{mentioner.to_reference(project)}"
+ expect(subject.note).to eq "mentioned in commit #{mentioned_in.to_reference(project)}"
end
end
context 'from non-Commit' do
it 'references the mentioning object' do
- expect(subject.note).to eq "mentioned in issue #{mentioner.to_reference(project)}"
+ expect(subject.note).to eq "mentioned in issue #{mentioned_in.to_reference(project)}"
end
end
end
context 'within the same project' do
context 'from Commit' do
- let(:mentioner) { project.repository.commit }
+ let(:mentioned_in) { project.repository.commit }
it 'references the mentioning commit' do
- expect(subject.note).to eq "mentioned in commit #{mentioner.to_reference}"
+ expect(subject.note).to eq "mentioned in commit #{mentioned_in.to_reference}"
end
end
context 'from non-Commit' do
it 'references the mentioning object' do
- expect(subject.note).to eq "mentioned in issue #{mentioner.to_reference}"
+ expect(subject.note).to eq "mentioned in issue #{mentioned_in.to_reference}"
end
end
end
@@ -350,14 +386,14 @@ RSpec.describe ::SystemNotes::IssuablesService do
context 'with external issue' do
let(:noteable) { ExternalIssue.new('JIRA-123', project) }
- let(:mentioner) { project.commit }
+ let(:mentioned_in) { project.commit }
it 'queues a background worker' do
expect(Integrations::CreateExternalCrossReferenceWorker).to receive(:perform_async).with(
project.id,
'JIRA-123',
'Commit',
- mentioner.id,
+ mentioned_in.id,
author.id
)
@@ -716,28 +752,28 @@ RSpec.describe ::SystemNotes::IssuablesService do
end
describe '#cross_reference_disallowed?' do
- context 'when mentioner is not a MergeRequest' do
+ context 'when mentioned_in is not a MergeRequest' do
it 'is falsey' do
- mentioner = noteable.dup
+ mentioned_in = noteable.dup
- expect(service.cross_reference_disallowed?(mentioner)).to be_falsey
+ expect(service.cross_reference_disallowed?(mentioned_in)).to be_falsey
end
end
- context 'when mentioner is a MergeRequest' do
- let(:mentioner) { create(:merge_request, :simple, source_project: project) }
- let(:noteable) { project.commit }
+ context 'when mentioned_in is a MergeRequest' do
+ let(:mentioned_in) { create(:merge_request, :simple, source_project: project) }
+ let(:noteable) { project.commit }
it 'is truthy when noteable is in commits' do
- expect(mentioner).to receive(:commits).and_return([noteable])
+ expect(mentioned_in).to receive(:commits).and_return([noteable])
- expect(service.cross_reference_disallowed?(mentioner)).to be_truthy
+ expect(service.cross_reference_disallowed?(mentioned_in)).to be_truthy
end
it 'is falsey when noteable is not in commits' do
- expect(mentioner).to receive(:commits).and_return([])
+ expect(mentioned_in).to receive(:commits).and_return([])
- expect(service.cross_reference_disallowed?(mentioner)).to be_falsey
+ expect(service.cross_reference_disallowed?(mentioned_in)).to be_falsey
end
end