Commit 6fba4972 authored by Peter Leitzen's avatar Peter Leitzen

Publish status page on emoji add

parent 81fd784b
......@@ -16,7 +16,7 @@ module AwardEmojis
award = awardable.award_emoji.create(name: name, user: current_user)
if award.persisted?
TodoService.new.new_award_emoji(todoable, current_user) if todoable
after_create(award)
success(award: award)
else
error(award.errors.full_messages, award: award)
......@@ -25,6 +25,10 @@ module AwardEmojis
private
def after_create(award)
TodoService.new.new_award_emoji(todoable, current_user) if todoable
end
def todoable
strong_memoize(:todoable) do
case awardable
......@@ -40,3 +44,5 @@ module AwardEmojis
end
end
end
AwardEmojis::AddService.prepend_if_ee('EE::AwardEmojis::AddService')
# frozen_string_literal: true
module EE
module AwardEmojis
module AddService
extend ::Gitlab::Utils::Override
private
override :after_create
def after_create(award)
super
StatusPage.trigger_publish(project, current_user, award)
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
describe AwardEmojis::AddService do
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project) }
let_it_be(:awardable) { create(:note_on_issue, project: project) }
let(:name) { 'thumbsup' }
subject(:service) { described_class.new(awardable, name, user) }
describe '#execute' do
describe 'publish to status page' do
let(:execute) { service.execute }
let(:issue_id) { awardable.noteable_id }
context 'when adding succeeds' do
context 'with recognized emoji' do
let(:name) { StatusPage::AWARD_EMOJI }
include_examples 'trigger status page publish'
end
context 'with unrecognized emoji' do
let(:name) { 'x' }
include_examples 'no trigger status page publish'
end
end
context 'when adding fails' do
let(:name) { '' }
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