summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarka Kadlecova <jarka@gitlab.com>2017-10-10 08:35:31 +0200
committerJarka Kadlecova <jarka@gitlab.com>2017-10-10 10:40:01 +0200
commitc31476728557fc1ef639e39f65783d9affaa3041 (patch)
treeaca5f6b73350b3f4786838f90e7cac0d8b1f6cfa
parentd6170ce4d8a0cbfd8552531c29163e44549222cf (diff)
downloadgitlab-ce-38941-lock-note-fix.tar.gz
Fix text for the merge request lock system note38941-lock-note-fix
-rw-r--r--app/services/system_note_service.rb2
-rw-r--r--spec/services/merge_requests/update_service_spec.rb4
-rw-r--r--spec/services/system_note_service_spec.rb38
3 files changed, 41 insertions, 3 deletions
diff --git a/app/services/system_note_service.rb b/app/services/system_note_service.rb
index 7b32e215c7f..a52dce6cb4b 100644
--- a/app/services/system_note_service.rb
+++ b/app/services/system_note_service.rb
@@ -593,7 +593,7 @@ module SystemNoteService
def discussion_lock(issuable, author)
action = issuable.discussion_locked? ? 'locked' : 'unlocked'
- body = "#{action} this issue"
+ body = "#{action} this #{issuable.class.to_s.titleize.downcase}"
create_note(NoteSummary.new(issuable, issuable.project, author, body, action: action))
end
diff --git a/spec/services/merge_requests/update_service_spec.rb b/spec/services/merge_requests/update_service_spec.rb
index 7257c359a7e..98409be4236 100644
--- a/spec/services/merge_requests/update_service_spec.rb
+++ b/spec/services/merge_requests/update_service_spec.rb
@@ -127,10 +127,10 @@ describe MergeRequests::UpdateService, :mailer do
end
it 'creates system note about discussion lock' do
- note = find_note('locked this issue')
+ note = find_note('locked this merge request')
expect(note).not_to be_nil
- expect(note.note).to eq 'locked this issue'
+ expect(note.note).to eq 'locked this merge request'
end
context 'when not including source branch removal options' do
diff --git a/spec/services/system_note_service_spec.rb b/spec/services/system_note_service_spec.rb
index b1241cd8d0b..cd473c1f388 100644
--- a/spec/services/system_note_service_spec.rb
+++ b/spec/services/system_note_service_spec.rb
@@ -1145,4 +1145,42 @@ describe SystemNoteService do
it { expect(subject.note).to eq "marked #{duplicate_issue.to_reference(project)} as a duplicate of this issue" }
end
end
+
+ describe '.discussion_lock' do
+ subject { described_class.discussion_lock(noteable, author) }
+
+ context 'discussion unlocked' do
+ it_behaves_like 'a system note' do
+ let(:action) { 'unlocked' }
+ end
+
+ it 'creates the note text correctly' do
+ [:issue, :merge_request].each do |type|
+ issuable = create(type)
+
+ expect(described_class.discussion_lock(issuable, author).note)
+ .to eq("unlocked this #{type.to_s.titleize.downcase}")
+ end
+ end
+ end
+
+ context 'discussion locked' do
+ before do
+ noteable.update_attribute(:discussion_locked, true)
+ end
+
+ it_behaves_like 'a system note' do
+ let(:action) { 'locked' }
+ end
+
+ it 'creates the note text correctly' do
+ [:issue, :merge_request].each do |type|
+ issuable = create(type, discussion_locked: true)
+
+ expect(described_class.discussion_lock(issuable, author).note)
+ .to eq("locked this #{type.to_s.titleize.downcase}")
+ end
+ end
+ end
+ end
end