Commit f50d8079 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'ccr/weight_1481' into 'master'

Backport of 1481-changing-weight-values-should-trigger-system-notes

See merge request gitlab-org/gitlab-ce!18699
parents e1f6400f 1019dff2
...@@ -18,7 +18,6 @@ module IssuableActions ...@@ -18,7 +18,6 @@ module IssuableActions
def update def update
@issuable = update_service.execute(issuable) # rubocop:disable Gitlab/ModuleWithInstanceVariables @issuable = update_service.execute(issuable) # rubocop:disable Gitlab/ModuleWithInstanceVariables
respond_to do |format| respond_to do |format|
format.html do format.html do
recaptcha_check_if_spammable { render :edit } recaptcha_check_if_spammable { render :edit }
......
...@@ -17,7 +17,11 @@ class SystemNoteMetadata < ActiveRecord::Base ...@@ -17,7 +17,11 @@ class SystemNoteMetadata < ActiveRecord::Base
].freeze ].freeze
validates :note, presence: true validates :note, presence: true
validates :action, inclusion: ICON_TYPES, allow_nil: true validates :action, inclusion: { in: :icon_types }, allow_nil: true
belongs_to :note belongs_to :note
def icon_types
ICON_TYPES
end
end end
...@@ -24,7 +24,7 @@ describe Gitlab::IncomingEmail do ...@@ -24,7 +24,7 @@ describe Gitlab::IncomingEmail do
end end
describe 'self.supports_wildcard?' do describe 'self.supports_wildcard?' do
context 'address contains the wildard placeholder' do context 'address contains the wildcard placeholder' do
before do before do
stub_incoming_email_setting(address: 'replies+%{key}@example.com') stub_incoming_email_setting(address: 'replies+%{key}@example.com')
end end
...@@ -49,7 +49,7 @@ describe Gitlab::IncomingEmail do ...@@ -49,7 +49,7 @@ describe Gitlab::IncomingEmail do
stub_incoming_email_setting(address: nil) stub_incoming_email_setting(address: nil)
end end
it 'returns that wildard is not supported' do it 'returns that wildcard is not supported' do
expect(described_class.supports_wildcard?).to be_falsey expect(described_class.supports_wildcard?).to be_falsey
end end
end end
......
...@@ -5,34 +5,6 @@ describe Issuable::CommonSystemNotesService do ...@@ -5,34 +5,6 @@ describe Issuable::CommonSystemNotesService do
let(:project) { create(:project) } let(:project) { create(:project) }
let(:issuable) { create(:issue) } 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(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
describe '#execute' do describe '#execute' do
it_behaves_like 'system note creation', { title: 'New title' }, 'changed title' 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', { description: 'New description' }, 'changed the description'
......
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(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
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