Commit 8a480473 authored by Peter Leitzen's avatar Peter Leitzen

Publish status page on note update

parent fc00774e
......@@ -81,3 +81,5 @@ module Notes
end
end
end
Notes::UpdateService.prepend_if_ee('EE::Notes::UpdateService')
# frozen_string_literal: true
module EE
module Notes
module UpdateService
extend ::Gitlab::Utils::Override
override :execute
def execute(note)
updated_note = super
if updated_note&.errors&.empty?
StatusPage.trigger_publish(project, current_user, updated_note)
end
updated_note
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
describe Notes::UpdateService do
let_it_be(:project) { create(:project) }
let_it_be(:user) { create(:user) }
let_it_be(:note, refind: true) do
create(:note_on_issue, project: project, author: user)
end
subject(:service) { described_class.new(project, user, opts) }
describe '#execute' do
let(:opts) { { note: note_text } }
describe 'publish to status page' do
let(:execute) { service.execute(note) }
let(:issue_id) { note.noteable_id }
let(:emoji_name) { StatusPage::AWARD_EMOJI }
before do
create(:award_emoji, user: user, name: emoji_name, awardable: note)
end
context 'for text-only update' do
let(:note_text) { 'text' }
include_examples 'trigger status page publish'
context 'without recognized emoji' do
let(:emoji_name) { 'thumbsup' }
include_examples 'no trigger status page publish'
end
end
context 'for quick action only update' do
let(:note_text) { "/todo\n" }
include_examples 'trigger status page publish'
end
context 'when update fails' do
let(:note_text) { '' }
include_examples 'no trigger status page publish'
end
end
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