diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-10-06 22:20:21 +0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-10-11 17:39:04 +0300 |
commit | e46a4aabd925e0182c31976b5d28c38b9a8a0872 (patch) | |
tree | 8400151d252bb7d2bb7010be56c5bef196d5b311 /spec/services | |
parent | 95a5cc9285a8583988ece697ebdb948730b5db55 (diff) |
Update Boards::CreateService to handle with the has_many association
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/boards/create_service_spec.rb | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/spec/services/boards/create_service_spec.rb b/spec/services/boards/create_service_spec.rb index a1a4dd4c57c..fde807cc410 100644 --- a/spec/services/boards/create_service_spec.rb +++ b/spec/services/boards/create_service_spec.rb @@ -2,33 +2,31 @@ require 'spec_helper' describe Boards::CreateService, 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 - let(:project) { create(:empty_project, board: nil) } - it 'creates a new board' do expect { service.execute }.to change(Board, :count).by(1) end it 'creates default lists' do - service.execute + board = service.execute - expect(project.board.lists.size).to eq 2 - expect(project.board.lists.first).to be_backlog - expect(project.board.lists.last).to be_done + expect(board.lists.size).to eq 2 + expect(board.lists.first).to be_backlog + expect(board.lists.last).to be_done end end context 'when project has a board' do - let!(:project) { create(:project_with_board) } - - it 'does not create a new board' do - expect { service.execute }.not_to change(Board, :count) + before do + create(:board, project: project) end - it 'does not create board lists' do - expect { service.execute }.not_to change(project.board.lists, :count) + it 'does not create a new board' do + expect { service.execute }.not_to change(project.boards, :count) end end end |