Commit ec96648f authored by Jan Provaznik's avatar Jan Provaznik

Merge branch '210524-auto_resolve_prometheus_alert-methods-from-ee-to-ce' into 'master'

Move #auto_resolve_prometheus_alert methods from EE to CE

Closes #210524

See merge request gitlab-org/gitlab!27335
parents 28f33dcf 41559a1a
......@@ -241,6 +241,10 @@ module SystemNoteService
def zoom_link_removed(issue, project, author)
::SystemNotes::ZoomService.new(noteable: issue, project: project, author: author).zoom_link_removed
end
def auto_resolve_prometheus_alert(noteable, project, author)
::SystemNotes::IssuablesService.new(noteable: noteable, project: project, author: author).auto_resolve_prometheus_alert
end
end
SystemNoteService.prepend_if_ee('EE::SystemNoteService')
......@@ -288,6 +288,12 @@ module SystemNotes
create_note(NoteSummary.new(noteable, project, author, body, action: 'closed'))
end
def auto_resolve_prometheus_alert
body = 'automatically closed this issue because the alert resolved.'
create_note(NoteSummary.new(noteable, project, author, body, action: 'closed'))
end
private
def cross_reference_note_content(gfm_reference)
......
......@@ -159,9 +159,5 @@ module EE
def abort_add_to_merge_train_when_pipeline_succeeds(noteable, project, author, reason)
EE::SystemNotes::MergeTrainService.new(noteable: noteable, project: project, author: author).abort_add_when_pipeline_succeeds(reason)
end
def auto_resolve_prometheus_alert(noteable, project, author)
::SystemNotes::IssuablesService.new(noteable: noteable, project: project, author: author).auto_resolve_prometheus_alert
end
end
end
......@@ -44,12 +44,6 @@ module EE
create_note(NoteSummary.new(noteable, project, author, body, action: 'weight'))
end
def auto_resolve_prometheus_alert
body = 'automatically closed this issue because the alert resolved.'
create_note(NoteSummary.new(noteable, project, author, body, action: 'closed'))
end
end
end
end
......@@ -74,16 +74,4 @@ describe ::SystemNotes::IssuablesService do
end
end
end
describe '#auto_resolve_prometheus_alert' do
subject { service.auto_resolve_prometheus_alert }
it_behaves_like 'a system note' do
let(:action) { 'closed' }
end
it 'creates the expected system note' do
expect(subject.note).to eq('automatically closed this issue because the alert resolved.')
end
end
end
......@@ -220,14 +220,4 @@ describe SystemNoteService do
described_class.abort_add_to_merge_train_when_pipeline_succeeds(noteable, project, author, message)
end
end
describe '.auto_resolve_prometheus_alert' do
it 'calls IssuableService' do
expect_next_instance_of(::SystemNotes::IssuablesService) do |service|
expect(service).to receive(:auto_resolve_prometheus_alert)
end
described_class.auto_resolve_prometheus_alert(noteable, project, author)
end
end
end
......@@ -625,4 +625,14 @@ describe SystemNoteService do
described_class.discussion_lock(issuable, double)
end
end
describe '.auto_resolve_prometheus_alert' do
it 'calls IssuableService' do
expect_next_instance_of(::SystemNotes::IssuablesService) do |service|
expect(service).to receive(:auto_resolve_prometheus_alert)
end
described_class.auto_resolve_prometheus_alert(noteable, project, author)
end
end
end
......@@ -654,4 +654,16 @@ describe ::SystemNotes::IssuablesService do
.to eq('resolved the corresponding error and closed the issue.')
end
end
describe '#auto_resolve_prometheus_alert' do
subject { service.auto_resolve_prometheus_alert }
it_behaves_like 'a system note' do
let(:action) { 'closed' }
end
it 'creates the expected system note' do
expect(subject.note).to eq('automatically closed this issue because the alert resolved.')
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