diff options
Diffstat (limited to 'spec/support/shared_examples/boards/destroy_service_shared_examples.rb')
-rw-r--r-- | spec/support/shared_examples/boards/destroy_service_shared_examples.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/support/shared_examples/boards/destroy_service_shared_examples.rb b/spec/support/shared_examples/boards/destroy_service_shared_examples.rb new file mode 100644 index 00000000000..33bae3da44b --- /dev/null +++ b/spec/support/shared_examples/boards/destroy_service_shared_examples.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +RSpec.shared_examples 'board destroy service' do + describe '#execute' do + let(:parent_type) { parent.is_a?(Project) ? :project : :group } + let!(:board) { create(board_factory, parent_type => parent) } + + subject(:service) { described_class.new(parent, double) } + + context 'when there is more than one board' do + let!(:board2) { create(board_factory, parent_type => parent) } + + it 'destroys the board' do + create(board_factory, parent_type => parent) + + expect do + expect(service.execute(board)).to be_success + end.to change(boards, :count).by(-1) + end + end + + context 'when there is only one board' do + it 'does not remove board' do + expect do + expect(service.execute(board)).to be_error + end.not_to change(boards, :count) + end + end + end +end |