summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/services/issuable/destroy_service_shared_examples.rb
blob: ccc287c10dea2d40884dbb9eefc0fec34e515ff8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# 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