summaryrefslogtreecommitdiff
path: root/spec/services
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2017-11-03 16:41:50 +0900
committerShinya Maeda <shinya@gitlab.com>2017-11-03 16:41:50 +0900
commit6ebe6792de24528a2052b77018b6c1d17ef5e17b (patch)
tree6333afc5777c88c9c631a1a8841dd9bc1d043a16 /spec/services
parent3602c0b9874c6b93e6cf55e1cb0238951784604d (diff)
parentd51ad1ea6407d3cb9eafd9fc891c7348b10b108f (diff)
downloadgitlab-ce-6ebe6792de24528a2052b77018b6c1d17ef5e17b.tar.gz
Merge branch 'master' into refactor-clusters
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/issuable/common_system_notes_service_spec.rb49
1 files changed, 49 insertions, 0 deletions
diff --git a/spec/services/issuable/common_system_notes_service_spec.rb b/spec/services/issuable/common_system_notes_service_spec.rb
new file mode 100644
index 00000000000..9f92b662be1
--- /dev/null
+++ b/spec/services/issuable/common_system_notes_service_spec.rb
@@ -0,0 +1,49 @@
+require 'spec_helper'
+
+describe Issuable::CommonSystemNotesService do
+ let(:user) { create(:user) }
+ let(:project) { create(:project) }
+ let(:issuable) { create(:issue) }
+
+ shared_examples 'system note creation' do |update_params, note_text|
+ subject { described_class.new(project, user).execute(issuable, [])}
+
+ before do
+ issuable.assign_attributes(update_params)
+ issuable.save
+ end
+
+ it 'creates 1 system note with the correct content' do
+ expect { subject }.to change { Note.count }.from(0).to(1)
+
+ note = Note.last
+ expect(note.note).to match(note_text)
+ expect(note.noteable_type).to eq('Issue')
+ end
+ end
+
+ describe '#execute' do
+ it_behaves_like 'system note creation', { title: 'New title' }, 'changed title'
+ it_behaves_like 'system note creation', { description: 'New description' }, 'changed the description'
+ it_behaves_like 'system note creation', { discussion_locked: true }, 'locked this issue'
+ it_behaves_like 'system note creation', { time_estimate: 5 }, 'changed time estimate'
+
+ context 'when new label is added' do
+ before do
+ label = create(:label, project: project)
+ issuable.labels << label
+ end
+
+ it_behaves_like 'system note creation', {}, /added ~\w+ label/
+ end
+
+ context 'when new milestone is assigned' do
+ before do
+ milestone = create(:milestone, project: project)
+ issuable.milestone_id = milestone.id
+ end
+
+ it_behaves_like 'system note creation', {}, 'changed milestone'
+ end
+ end
+end