Commit 1c48e1c8 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge two board destroy service spec

They're both EE only:

* ee/spec/services/boards/destroy_service_spec.rb
* spec/services/boards/destroy_service_spec.rb
parent f536efad
require 'spec_helper'
describe Boards::DestroyService, services: true do
describe Boards::DestroyService do
describe '#execute' do
let(:project) { create(:project) }
let(:group) { create(:group) }
let!(:board) { create(:board, group: group) }
subject(:service) { described_class.new(group, double) }
shared_examples 'remove the board' do |parent_name|
let(:parent) { public_send(parent_name) }
let!(:board) { create(:board, parent_name => parent) }
context 'when group have more than one board' do
it 'removes board from group' do
create(:board, group: group)
subject(:service) { described_class.new(parent, double) }
expect { service.execute(board) }.to change(group.boards, :count).by(-1)
context "when #{parent_name} have more than one board" do
it "removes board from #{parent_name}" do
create(:board, parent_name => parent)
expect { service.execute(board) }.to change(parent.boards, :count).by(-1)
end
end
end
context 'when group have one board' do
it 'does not remove board from group' do
expect { service.execute(board) }.not_to change(group.boards, :count)
context "when #{parent_name} have one board" do
it "does not remove board from #{parent_name}" do
expect { service.execute(board) }.not_to change(group.boards, :count)
end
end
end
it_behaves_like 'remove the board', :group
it_behaves_like 'remove the board', :project
end
end
require 'spec_helper'
describe Boards::DestroyService do
describe '#execute' do
let(:project) { create(:project) }
let!(:board) { create(:board, project: project) }
subject(:service) { described_class.new(project, double) }
context 'when project have more than one board' do
it 'removes board from project' do
create(:board, project: project)
expect { service.execute(board) }.to change(project.boards, :count).by(-1)
end
end
context 'when project have one board' do
it 'does not remove board from project' do
expect { service.execute(board) }.not_to change(project.boards, :count)
end
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