diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-02-16 13:47:00 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-03-17 09:39:15 +0300 |
commit | 9882802a8b70e998ff6850a3d096b3b52730ab85 (patch) | |
tree | 69403cc0e54d37c8cafcf978f023f23ad351abf9 /spec | |
parent | 69b89d4ec8f9788dc11f30cdf1f782d316ab252c (diff) |
Improve system notes that are added when issue is moved
Diffstat (limited to 'spec')
-rw-r--r-- | spec/services/issues/move_service_spec.rb | 6 | ||||
-rw-r--r-- | spec/services/system_note_service_spec.rb | 51 |
2 files changed, 47 insertions, 10 deletions
diff --git a/spec/services/issues/move_service_spec.rb b/spec/services/issues/move_service_spec.rb index 25dacb2068b..569e155e617 100644 --- a/spec/services/issues/move_service_spec.rb +++ b/spec/services/issues/move_service_spec.rb @@ -20,7 +20,11 @@ describe Issues::MoveService, services: true do end it 'should add system note to old issue' do - expect(issue.notes.last.note).to match /This issue has been moved to/ + expect(issue.notes.last.note).to match /^Moved to/ + end + + it 'should add system note to new issue' do + expect(new_issue.notes.last.note).to match /^Moved from/ end end end diff --git a/spec/services/system_note_service_spec.rb b/spec/services/system_note_service_spec.rb index 9074d3dbe19..e0ae49ab37c 100644 --- a/spec/services/system_note_service_spec.rb +++ b/spec/services/system_note_service_spec.rb @@ -441,23 +441,56 @@ describe SystemNoteService, services: true do end end - describe '.issue_moved_to_another_project' do + describe '.noteable_moved' do + let(:new_project) { create(:project) } + let(:new_noteable) { create(:issue, project: new_project) } + subject do - described_class.issue_moved_to_another_project(noteable, project, new_project, author) + described_class.noteable_moved(direction, noteable, project, new_noteable, author) end - let(:new_project) { create(:project) } + shared_examples 'cross project mentionable' do + include GitlabMarkdownHelper + + it 'should contain cross reference to new noteable' do + expect(subject.note).to include cross_project_reference(new_project, new_noteable) + end + + it 'should mention referenced noteable' do + expect(subject.note).to include new_noteable.to_reference + end + + it 'should mention referenced project' do + expect(subject.note).to include new_project.to_reference + end + end + + context 'moved to' do + let(:direction) { :to } + + it_behaves_like 'cross project mentionable' - it 'should notify about issue being moved' do - expect(subject.note).to match /This issue has been moved to/ + it 'should notify about noteable being moved to' do + expect(subject.note).to match /Moved to/ + end end - it 'should mention destination project' do - expect(subject.note).to include new_project.to_reference + context 'moved from' do + let(:direction) { :from } + + it_behaves_like 'cross project mentionable' + + it 'should notify about noteable being moved from' do + expect(subject.note).to match /Moved from/ + end end - it 'should mention author of that change' do - expect(subject.note).to include author.to_reference + context 'invalid direction' do + let (:direction) { :invalid } + + it 'should raise error' do + expect { subject }.to raise_error StandardError, /Invalid direction/ + end end end |