diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
commit | 8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch) | |
tree | 544930fb309b30317ae9797a9683768705d664c4 /spec/services/system_notes/issuables_service_spec.rb | |
parent | 4b1de649d0168371549608993deac953eb692019 (diff) |
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'spec/services/system_notes/issuables_service_spec.rb')
-rw-r--r-- | spec/services/system_notes/issuables_service_spec.rb | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/spec/services/system_notes/issuables_service_spec.rb b/spec/services/system_notes/issuables_service_spec.rb index b70c5e899fc..96afca2f2cb 100644 --- a/spec/services/system_notes/issuables_service_spec.rb +++ b/spec/services/system_notes/issuables_service_spec.rb @@ -522,6 +522,91 @@ RSpec.describe ::SystemNotes::IssuablesService do end end + describe '#noteable_cloned' do + let(:new_project) { create(:project) } + let(:new_noteable) { create(:issue, project: new_project) } + + subject do + service.noteable_cloned(new_noteable, direction) + end + + shared_examples 'cross project mentionable' do + include MarkupHelper + + it 'contains cross reference to new noteable' do + expect(subject.note).to include cross_project_reference(new_project, new_noteable) + end + + it 'mentions referenced noteable' do + expect(subject.note).to include new_noteable.to_reference + end + + it 'mentions referenced project' do + expect(subject.note).to include new_project.full_path + end + end + + context 'cloned to' do + let(:direction) { :to } + + it_behaves_like 'cross project mentionable' + + it_behaves_like 'a system note' do + let(:action) { 'cloned' } + end + + it 'notifies about noteable being cloned to' do + expect(subject.note).to match('cloned to') + end + end + + context 'cloned from' do + let(:direction) { :from } + + it_behaves_like 'cross project mentionable' + + it_behaves_like 'a system note' do + let(:action) { 'cloned' } + end + + it 'notifies about noteable being cloned from' do + expect(subject.note).to match('cloned from') + end + end + + context 'invalid direction' do + let(:direction) { :invalid } + + it 'raises error' do + expect { subject }.to raise_error StandardError, /Invalid direction/ + end + end + + context 'metrics' do + context 'cloned from' do + let(:direction) { :from } + + it 'does not tracks usage' do + expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter) + .not_to receive(:track_issue_cloned_action).with(author: author) + + subject + end + end + + context 'cloned to' do + let(:direction) { :to } + + it 'tracks usage' do + expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter) + .to receive(:track_issue_cloned_action).with(author: author) + + subject + end + end + end + end + describe '#mark_duplicate_issue' do subject { service.mark_duplicate_issue(canonical_issue) } |