summaryrefslogtreecommitdiff
path: root/spec/services
diff options
context:
space:
mode:
authorFilipa Lacerda <filipa@gitlab.com>2017-11-24 15:51:15 +0000
committerFilipa Lacerda <filipa@gitlab.com>2017-11-24 15:51:15 +0000
commit54cf7dacdf3fac38161f0e962640543166715eb4 (patch)
treea7119b97d75578777c24e7a4bda66c196758081a /spec/services
parent0bee018631ae199ce87125c21379e1db2f56bf67 (diff)
parent7c1e54d58d7ee0308b865d9563f1dfeb54568e16 (diff)
downloadgitlab-ce-54cf7dacdf3fac38161f0e962640543166715eb4.tar.gz
Merge branch 'master' into list-multiple-clusters
* master: (53 commits) Updated timeago.js Prevent 500 error when inspecting job after trigger was removed Add classList polyfill for IE classList.toggle(.., force) Use feature flag instead of application settigns to control if method calls should be instrumented Rename wip to worker_id add missing schema entry and application settigns helper Use only real duration to measure method call performance via Prometheus check method timing threshold when observing method performance Add changelog for #15558 Reenable prometheus metrics Move prometheus middle ware to prometheus initialized. Fix WIP system note not being created Update CHANGELOG.md for 10.2.2 Fix hashed storage for attachments bugs Rename fetch_refs to refmap Clean up repository fetch and mirror methods Fix pulling and pushing using a personal access token with the sudo scope Allow password authentication to be disabled entirely Simplify the DB changes checklist Added Rubocop config for background migrations ...
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/issuable/common_system_notes_service_spec.rb43
-rw-r--r--spec/services/system_note_service_spec.rb36
2 files changed, 61 insertions, 18 deletions
diff --git a/spec/services/issuable/common_system_notes_service_spec.rb b/spec/services/issuable/common_system_notes_service_spec.rb
index 9f92b662be1..b8fa3e3d124 100644
--- a/spec/services/issuable/common_system_notes_service_spec.rb
+++ b/spec/services/issuable/common_system_notes_service_spec.rb
@@ -18,7 +18,18 @@ describe Issuable::CommonSystemNotesService do
note = Note.last
expect(note.note).to match(note_text)
- expect(note.noteable_type).to eq('Issue')
+ expect(note.noteable_type).to eq(issuable.class.name)
+ end
+ end
+
+ shared_examples 'WIP notes creation' do |wip_action|
+ subject { described_class.new(project, user).execute(issuable, []) }
+
+ it 'creates WIP toggle and title change notes' do
+ expect { subject }.to change { Note.count }.from(0).to(2)
+
+ expect(Note.first.note).to match("#{wip_action} as a **Work In Progress**")
+ expect(Note.second.note).to match('changed title')
end
end
@@ -45,5 +56,35 @@ describe Issuable::CommonSystemNotesService do
it_behaves_like 'system note creation', {}, 'changed milestone'
end
+
+ context 'with merge requests WIP note' do
+ context 'adding WIP note' do
+ let(:issuable) { create(:merge_request, title: "merge request") }
+
+ it_behaves_like 'system note creation', { title: "WIP merge request" }, 'marked as a **Work In Progress**'
+
+ context 'and changing title' do
+ before do
+ issuable.update_attribute(:title, "WIP changed title")
+ end
+
+ it_behaves_like 'WIP notes creation', 'marked'
+ end
+ end
+
+ context 'removing WIP note' do
+ let(:issuable) { create(:merge_request, title: "WIP merge request") }
+
+ it_behaves_like 'system note creation', { title: "merge request" }, 'unmarked as a **Work In Progress**'
+
+ context 'and changing title' do
+ before do
+ issuable.update_attribute(:title, "changed title")
+ end
+
+ it_behaves_like 'WIP notes creation', 'unmarked'
+ end
+ end
+ end
end
end
diff --git a/spec/services/system_note_service_spec.rb b/spec/services/system_note_service_spec.rb
index 0a6ab455abe..a918383ecd2 100644
--- a/spec/services/system_note_service_spec.rb
+++ b/spec/services/system_note_service_spec.rb
@@ -970,31 +970,33 @@ describe SystemNoteService do
end
end
- describe '.remove_merge_request_wip' do
- let(:noteable) { create(:issue, project: project, title: 'WIP: Lorem ipsum') }
+ describe '.handle_merge_request_wip' do
+ context 'adding wip note' do
+ let(:noteable) { create(:merge_request, source_project: project, title: 'WIP Lorem ipsum') }
- subject { described_class.remove_merge_request_wip(noteable, project, author) }
+ subject { described_class.handle_merge_request_wip(noteable, project, author) }
- it_behaves_like 'a system note' do
- let(:action) { 'title' }
- end
+ it_behaves_like 'a system note' do
+ let(:action) { 'title' }
+ end
- it 'sets the note text' do
- expect(subject.note).to eq 'unmarked as a **Work In Progress**'
+ it 'sets the note text' do
+ expect(subject.note).to eq 'marked as a **Work In Progress**'
+ end
end
- end
- describe '.add_merge_request_wip' do
- let(:noteable) { create(:issue, project: project, title: 'Lorem ipsum') }
+ context 'removing wip note' do
+ let(:noteable) { create(:merge_request, source_project: project, title: 'Lorem ipsum') }
- subject { described_class.add_merge_request_wip(noteable, project, author) }
+ subject { described_class.handle_merge_request_wip(noteable, project, author) }
- it_behaves_like 'a system note' do
- let(:action) { 'title' }
- end
+ it_behaves_like 'a system note' do
+ let(:action) { 'title' }
+ end
- it 'sets the note text' do
- expect(subject.note).to eq 'marked as a **Work In Progress**'
+ it 'sets the note text' do
+ expect(subject.note).to eq 'unmarked as a **Work In Progress**'
+ end
end
end