Commit c2ac5f1d authored by Stan Hu's avatar Stan Hu

Merge branch '212566-foss-design-management-mailers-workers' into 'master'

Move Design Management mailers and workers to FOSS

See merge request gitlab-org/gitlab!31298
parents baac193a 63071618
......@@ -40,6 +40,18 @@ module Emails
mail_answer_note_thread(@snippet, @note, note_thread_options(recipient_id, reason))
end
def note_design_email(recipient_id, note_id, reason = nil)
setup_note_mail(note_id, recipient_id)
design = @note.noteable
@target_url = ::Gitlab::Routing.url_helpers.designs_project_issue_url(
@note.resource_parent,
design.issue,
note_target_url_query_params.merge(vueroute: design.filename)
)
mail_answer_note_thread(design, @note, note_thread_options(recipient_id, reason))
end
private
def note_target_url_options
......
......@@ -1011,6 +1011,13 @@
:resource_boundary: :unknown
:weight: 1
:idempotent:
- :name: design_management_new_version
:feature_category: :design_management
:has_external_dependencies:
:urgency: :low
:resource_boundary: :memory
:weight: 1
:idempotent:
- :name: detect_repository_languages
:feature_category: :source_code_management
:has_external_dependencies:
......
......@@ -11,18 +11,6 @@ module EE
@target_url = group_epic_url(*note_target_url_options)
mail_answer_note_thread(@epic, @note, note_thread_options(recipient_id, reason))
end
def note_design_email(recipient_id, note_id, reason = nil)
setup_note_mail(note_id, recipient_id)
design = @note.noteable
@target_url = ::Gitlab::Routing.url_helpers.designs_project_issue_url(
@note.resource_parent,
design.issue,
note_target_url_query_params.merge(vueroute: design.filename)
)
mail_answer_note_thread(design, @note, note_thread_options(recipient_id, reason))
end
end
end
end
......@@ -472,13 +472,6 @@
:resource_boundary: :cpu
:weight: 2
:idempotent:
- :name: design_management_new_version
:feature_category: :design_management
:has_external_dependencies:
:urgency: :low
:resource_boundary: :memory
:weight: 1
:idempotent:
- :name: elastic_batch_project_indexer
:feature_category: :global_search
:has_external_dependencies:
......
......@@ -71,29 +71,6 @@ describe Notify do
description: 'Awesome description')
end
describe '.note_design_email' do
let_it_be(:design) { create(:design, :with_file) }
let_it_be(:recipient) { create(:user) }
let_it_be(:note) do
create(:diff_note_on_design,
noteable: design,
note: "Hello #{recipient.to_reference}")
end
let(:header_name) { 'X-Gitlab-DesignManagement-Design-ID' }
let(:refer_to_design) do
have_attributes(subject: a_string_including(design.filename))
end
subject { described_class.note_design_email(recipient.id, note.id) }
it { is_expected.to have_header(header_name, design.id.to_s) }
it { is_expected.to have_body_text(design.filename) }
it { is_expected.to refer_to_design }
end
context 'for a project' do
context 'for service desk issues' do
before do
......
......@@ -712,6 +712,29 @@ describe Notify do
end
end
describe 'for design notes' do
let_it_be(:design) { create(:design, :with_file) }
let_it_be(:recipient) { create(:user) }
let_it_be(:note) do
create(:diff_note_on_design,
noteable: design,
note: "Hello #{recipient.to_reference}")
end
let(:header_name) { 'X-Gitlab-DesignManagement-Design-ID' }
let(:refer_to_design) do
have_attributes(subject: a_string_including(design.filename))
end
subject { described_class.note_design_email(recipient.id, note.id) }
it { is_expected.to have_header(header_name, design.id.to_s) }
it { is_expected.to have_body_text(design.filename) }
it { is_expected.to refer_to_design }
end
describe 'project was moved' do
let(:recipient) { user }
......
......@@ -3,6 +3,14 @@
require 'spec_helper'
describe DesignManagement::NewVersionWorker do
# TODO a number of these tests are being temporarily skipped unless run in EE,
# as we are in the process of moving Design Management to FOSS in 13.0
# in steps. In the current step the services have not yet been moved, and
# certain services are called within these tests:
# - `SystemNoteService`
# - `DesignManagement::GenerateImageVersionsService`
#
# See https://gitlab.com/gitlab-org/gitlab/-/issues/212566#note_327724283.
describe '#perform' do
let(:worker) { described_class.new }
......@@ -10,12 +18,16 @@ describe DesignManagement::NewVersionWorker do
let(:version_id) { -1 }
it 'does not create system notes' do
skip 'See https://gitlab.com/gitlab-org/gitlab/-/issues/212566#note_327724283' unless Gitlab.ee?
expect(SystemNoteService).not_to receive(:design_version_added)
worker.perform(version_id)
end
it 'does not invoke GenerateImageVersionsService' do
skip 'See https://gitlab.com/gitlab-org/gitlab/-/issues/212566#note_327724283' unless Gitlab.ee?
expect(DesignManagement::GenerateImageVersionsService).not_to receive(:new)
worker.perform(version_id)
......@@ -33,10 +45,14 @@ describe DesignManagement::NewVersionWorker do
let_it_be(:version) { create(:design_version, :with_lfs_file, designs_count: 2) }
it 'creates a system note' do
skip 'See https://gitlab.com/gitlab-org/gitlab/-/issues/212566#note_327724283' unless Gitlab.ee?
expect { worker.perform(version.id) }.to change { Note.system.count }.by(1)
end
it 'invokes GenerateImageVersionsService' do
skip 'See https://gitlab.com/gitlab-org/gitlab/-/issues/212566#note_327724283' unless Gitlab.ee?
expect_next_instance_of(DesignManagement::GenerateImageVersionsService) do |service|
expect(service).to receive(:execute)
end
......@@ -45,6 +61,8 @@ describe DesignManagement::NewVersionWorker do
end
it 'does not log anything' do
skip 'See https://gitlab.com/gitlab-org/gitlab/-/issues/212566#note_327724283' unless Gitlab.ee?
expect(Sidekiq.logger).not_to receive(:warn)
worker.perform(version.id)
......@@ -59,10 +77,14 @@ describe DesignManagement::NewVersionWorker do
end
it 'creates two system notes' do
skip 'See https://gitlab.com/gitlab-org/gitlab/-/issues/212566#note_327724283' unless Gitlab.ee?
expect { worker.perform(version.id) }.to change { Note.system.count }.by(2)
end
it 'calls design_version_added' do
skip 'See https://gitlab.com/gitlab-org/gitlab/-/issues/212566#note_327724283' unless Gitlab.ee?
expect(SystemNoteService).to receive(:design_version_added).with(version)
worker.perform(version.id)
......
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