Commit 8ee53528 authored by Matthias Käppler's avatar Matthias Käppler

Merge branch 'issue_292253-follow_up_fixing_feature_flag_scope' into 'master'

Fix todos async delete feature flag actor

See merge request gitlab-org/gitlab!59651
parents 31871f08 979af49a
...@@ -17,13 +17,13 @@ module Issuable ...@@ -17,13 +17,13 @@ module Issuable
end end
def group_for(issuable) def group_for(issuable)
issuable.resource_parent issuable.resource_parent.group
end end
def delete_todos(issuable) def delete_todos(issuable)
group = group_for(issuable) actor = group_for(issuable)
if Feature.enabled?(:destroy_issuable_todos_async, group, default_enabled: :yaml) if Feature.enabled?(:destroy_issuable_todos_async, actor, default_enabled: :yaml)
TodosDestroyer::DestroyedIssuableWorker TodosDestroyer::DestroyedIssuableWorker
.perform_async(issuable.id, issuable.class.name) .perform_async(issuable.id, issuable.class.name)
else else
......
...@@ -9,13 +9,17 @@ RSpec.describe Issuable::DestroyService do ...@@ -9,13 +9,17 @@ RSpec.describe Issuable::DestroyService do
describe '#execute' do describe '#execute' do
context 'when destroying an epic' do context 'when destroying an epic' do
let(:issuable) { create(:epic) } let_it_be(:issuable) { create(:epic) }
let(:group) { issuable.group }
it 'records usage ping epic destroy event' do it 'records usage ping epic destroy event' do
expect(Gitlab::UsageDataCounters::EpicActivityUniqueCounter).to receive(:track_epic_destroyed).with(author: user) expect(Gitlab::UsageDataCounters::EpicActivityUniqueCounter).to receive(:track_epic_destroyed).with(author: user)
subject.execute(issuable) subject.execute(issuable)
end end
it_behaves_like 'service deleting todos'
end end
context 'when destroying other issuable type' do context 'when destroying other issuable type' do
......
...@@ -4,37 +4,12 @@ require 'spec_helper' ...@@ -4,37 +4,12 @@ require 'spec_helper'
RSpec.describe Issuable::DestroyService do RSpec.describe Issuable::DestroyService do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project, :public) } let(:group) { create(:group, :public) }
let(:project) { create(:project, :public, group: group) }
subject(:service) { described_class.new(project, user) } subject(:service) { described_class.new(project, user) }
describe '#execute' do describe '#execute' do
shared_examples_for 'service deleting todos' do
it 'destroys associated todos asynchronously' do
expect(TodosDestroyer::DestroyedIssuableWorker)
.to receive(:perform_async)
.with(issuable.id, issuable.class.name)
subject.execute(issuable)
end
context 'when destroy_issuable_todos_async feature is disabled' do
before do
stub_feature_flags(destroy_issuable_todos_async: false)
end
it 'destroy associated todos synchronously' do
expect_next_instance_of(TodosDestroyer::DestroyedIssuableWorker) do |worker|
expect(worker)
.to receive(:perform)
.with(issuable.id, issuable.class.name)
end
subject.execute(issuable)
end
end
end
context 'when issuable is an issue' do context 'when issuable is an issue' do
let!(:issue) { create(:issue, project: project, author: user, assignees: [user]) } let!(:issue) { create(:issue, project: project, author: user, assignees: [user]) }
......
# frozen_string_literal: true
shared_examples_for 'service deleting todos' do
before do
stub_feature_flags(destroy_issuable_todos_async: group)
end
it 'destroys associated todos asynchronously' do
expect(TodosDestroyer::DestroyedIssuableWorker)
.to receive(:perform_async)
.with(issuable.id, issuable.class.name)
subject.execute(issuable)
end
context 'when destroy_issuable_todos_async feature is disabled for group' do
before do
stub_feature_flags(destroy_issuable_todos_async: false)
end
it 'destroy associated todos synchronously' do
expect_next_instance_of(TodosDestroyer::DestroyedIssuableWorker) do |worker|
expect(worker)
.to receive(:perform)
.with(issuable.id, issuable.class.name)
end
subject.execute(issuable)
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