Commit 22b80a11 authored by Patrick Derichs's avatar Patrick Derichs

Extract Zoom System Note Service

Also moving specs.
parent 1987c8a7
......@@ -317,11 +317,11 @@ module SystemNoteService
end
def zoom_link_added(issue, project, author)
create_note(NoteSummary.new(issue, project, author, _('added a Zoom call to this issue'), action: 'pinned_embed'))
::SystemNotes::ZoomService.new(noteable: issue, project: project, author: author).zoom_link_added
end
def zoom_link_removed(issue, project, author)
create_note(NoteSummary.new(issue, project, author, _('removed a Zoom call from this issue'), action: 'pinned_embed'))
::SystemNotes::ZoomService.new(noteable: issue, project: project, author: author).zoom_link_removed
end
private
......
# frozen_string_literal: true
module SystemNotes
class ZoomService < ::SystemNotes::BaseService
def zoom_link_added
create_note(NoteSummary.new(noteable, project, author, _('added a Zoom call to this issue'), action: 'pinned_embed'))
end
def zoom_link_removed
create_note(NoteSummary.new(noteable, project, author, _('removed a Zoom call from this issue'), action: 'pinned_embed'))
end
end
end
......@@ -271,26 +271,22 @@ describe SystemNoteService do
end
describe '.zoom_link_added' do
subject { described_class.zoom_link_added(issue, project, author) }
it_behaves_like 'a system note' do
let(:action) { 'pinned_embed' }
end
it 'calls ZoomService' do
expect_next_instance_of(::SystemNotes::ZoomService) do |service|
expect(service).to receive(:zoom_link_added)
end
it 'sets the zoom link added note text' do
expect(subject.note).to eq('added a Zoom call to this issue')
described_class.zoom_link_added(noteable, project, author)
end
end
describe '.zoom_link_removed' do
subject { described_class.zoom_link_removed(issue, project, author) }
it_behaves_like 'a system note' do
let(:action) { 'pinned_embed' }
end
it 'calls ZoomService' do
expect_next_instance_of(::SystemNotes::ZoomService) do |service|
expect(service).to receive(:zoom_link_removed)
end
it 'sets the zoom link removed note text' do
expect(subject.note).to eq('removed a Zoom call from this issue')
described_class.zoom_link_removed(noteable, project, author)
end
end
......
# frozen_string_literal: true
require 'spec_helper'
describe ::SystemNotes::ZoomService do
let_it_be(:project) { create(:project, :repository) }
let_it_be(:author) { create(:user) }
let(:noteable) { create(:issue, project: project) }
let(:service) { described_class.new(noteable: noteable, project: project, author: author) }
describe '#zoom_link_added' do
subject { service.zoom_link_added }
it_behaves_like 'a system note' do
let(:action) { 'pinned_embed' }
end
it 'sets the zoom link added note text' do
expect(subject.note).to eq('added a Zoom call to this issue')
end
end
describe '#zoom_link_removed' do
subject { service.zoom_link_removed }
it_behaves_like 'a system note' do
let(:action) { 'pinned_embed' }
end
it 'sets the zoom link removed note text' do
expect(subject.note).to eq('removed a Zoom call from this issue')
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