diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-10-05 22:01:06 +0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-10-11 17:39:04 +0300 |
commit | b4b8e0ec9405c4b5d17b53552612397e847e734d (patch) | |
tree | b7b69b7c70590272a6b13a256d2fa41b0b38b1af /spec/services | |
parent | 8b15e328a60f050d4ff24c0c7203461ae2724a30 (diff) |
Add Boards::ListService service to list project boards
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/boards/list_service_spec.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/services/boards/list_service_spec.rb b/spec/services/boards/list_service_spec.rb new file mode 100644 index 00000000000..dff33e4bcbb --- /dev/null +++ b/spec/services/boards/list_service_spec.rb @@ -0,0 +1,37 @@ +require 'spec_helper' + +describe Boards::ListService, services: true do + describe '#execute' do + let(:project) { create(:empty_project) } + + subject(:service) { described_class.new(project, double) } + + context 'when project does not have a board' do + it 'creates a new project board' do + expect { service.execute }.to change(project.boards, :count).by(1) + end + + it 'delegates the project board creation to Boards::CreateService' do + expect_any_instance_of(Boards::CreateService).to receive(:execute).once + + service.execute + end + end + + context 'when project has a board' do + before do + create(:board, project: project) + end + + it 'does not create a new board' do + expect { service.execute }.not_to change(project.boards, :count) + end + end + + it 'returns project boards' do + board = create(:board, project: project) + + expect(service.execute).to match_array [board] + end + end +end |