Commit 3fba94ea authored by syasonik's avatar syasonik

Add system note support for publishing issues

Adds helper methods for generating system notes
which correspond to publishing an issue to an
associated status page application. These
notes are meant to be used in another MR.
parent 718a986d
......@@ -25,7 +25,8 @@ module EE
'designs_discussion_added' => 'doc-image',
'vulnerability_confirmed' => 'shield',
'vulnerability_dismissed' => 'cancel',
'vulnerability_resolved' => 'status_closed'
'vulnerability_resolved' => 'status_closed',
'published' => 'bullhorn'
}.freeze
override :system_note_icon_name
......
......@@ -5,7 +5,7 @@ module EE
extend ::Gitlab::Utils::Override
EE_ICON_TYPES = %w[
weight approved unapproved relate unrelate
weight approved unapproved relate unrelate published
epic_issue_added issue_added_to_epic epic_issue_removed issue_removed_from_epic
epic_issue_moved issue_changed_epic epic_date_changed relate_epic unrelate_epic
designs_added designs_modified designs_removed designs_discussion_added
......
......@@ -180,5 +180,9 @@ module EE
def change_vulnerability_state(noteable, author)
EE::SystemNotes::VulnerabilitiesService.new(noteable: noteable, project: noteable.project, author: author).change_vulnerability_state
end
def publish_issue_to_status_page(noteable, project, author)
::SystemNotes::IssuablesService.new(noteable: noteable, project: project, author: author).publish_issue_to_status_page
end
end
end
......@@ -60,6 +60,20 @@ module EE
create_note(NoteSummary.new(noteable, project, author, body, action: 'health_status'))
end
# Called when the an issue is published to a project's
# status page application
#
# Example Note text:
#
# "published this issue to the status page"
#
# Returns the created Note object
def publish_issue_to_status_page
body = 'published this issue to the status page'
create_note(NoteSummary.new(noteable, project, author, body, action: 'published'))
end
end
end
end
......@@ -104,4 +104,18 @@ describe ::SystemNotes::IssuablesService do
end
end
end
describe '#publish_issue_to_status_page' do
let_it_be(:noteable) { create(:issue, project: project) }
subject { service.publish_issue_to_status_page }
it_behaves_like 'a system note' do
let(:action) { 'published' }
end
it 'sets the note text' do
expect(subject.note).to eq 'published this issue to the status page'
end
end
end
......@@ -240,4 +240,14 @@ describe SystemNoteService do
described_class.change_vulnerability_state(noteable, author)
end
end
describe '.publish_issue_to_status_page' do
it 'calls IssuablesService' do
expect_next_instance_of(::SystemNotes::IssuablesService) do |service|
expect(service).to receive(:publish_issue_to_status_page)
end
described_class.publish_issue_to_status_page(noteable, project, author)
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