Merge branch 'jivl-remove-comma-from-weight-system-notes' into 'master'

Remove comma from weight system notes

Closes #6372

See merge request gitlab-org/gitlab-ee!5854
parents c492706d 204adab2
......@@ -11,6 +11,24 @@ module EE
noteable.is_a?(Epic)
end
# Remove with https://gitlab.com/gitlab-org/gitlab-ee/issues/6347
def note
raw_note = super
return raw_note unless system? && system_note_metadata&.action == 'weight'
raw_note.delete(',')
end
# Remove with https://gitlab.com/gitlab-org/gitlab-ee/issues/6347
def note_html
raw_note_html = super
return raw_note_html unless system? && system_note_metadata&.action == 'weight'
raw_note_html.delete(',')
end
override :for_project_noteable?
def for_project_noteable?
!for_epic? && super
......
......@@ -21,7 +21,7 @@ module EE
# Returns the created Note object
def change_weight_note(noteable, project, author)
body = noteable.weight ? "changed weight to **#{noteable.weight}**," : 'removed the weight'
body = noteable.weight ? "changed weight to **#{noteable.weight}**" : 'removed the weight'
create_note(NoteSummary.new(noteable, project, author, body, action: 'weight'))
end
......
---
title: Remove the comma from the weight system notes
merge_request: 5854
author:
type: changed
require 'spec_helper'
describe EE::Note do
# Remove with https://gitlab.com/gitlab-org/gitlab-ee/issues/6347
describe "#note and #note_html overrides for weight" do
using RSpec::Parameterized::TableSyntax
where(:system, :action, :result) do
false | nil | 'this, had, some, commas, originally'
true | nil | 'this, had, some, commas, originally'
true | 'relate' | 'this, had, some, commas, originally'
true | 'weight' | 'this had some commas originally'
end
with_them do
let(:note) { create(:note, system: system, note: 'this, had, some, commas, originally') }
before do
create(:system_note_metadata, action: action, note: note) if action
end
it 'returns the right raw note' do
expect(note.note).to eq(result)
end
it 'returns the right HTML' do
expect(note.note_html).to eq("<p dir=\"auto\">#{result}</p>")
end
end
end
end
......@@ -6,7 +6,7 @@ describe Issuable::CommonSystemNotesService do
let(:issuable) { create(:issue) }
describe '#execute' do
it_behaves_like 'system note creation', { weight: 5 }, 'changed weight to **5**,'
it_behaves_like 'system note creation', { weight: 5 }, 'changed weight to **5**'
context 'when issuable is an epic' do
let(:timestamp) { Time.now }
......
......@@ -47,7 +47,7 @@ describe SystemNoteService do
end
it 'sets the note text' do
expect(subject.note).to eq "changed weight to **4**,"
expect(subject.note).to eq "changed weight to **4**"
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment