diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-08-08 22:34:38 +0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-08-17 18:58:59 +0300 |
commit | 68cfdba7018172d502d4b98aad02e86d22a6a401 (patch) | |
tree | c67bf8442f366b5707f02790efa6b4614530f7a0 /spec/services/boards/lists | |
parent | e23d1706faa7fe100d5db3d2e4f83198f7bfa900 (diff) |
Add service to generate default board lists
Diffstat (limited to 'spec/services/boards/lists')
-rw-r--r-- | spec/services/boards/lists/generate_service_spec.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/services/boards/lists/generate_service_spec.rb b/spec/services/boards/lists/generate_service_spec.rb new file mode 100644 index 00000000000..9fd39122737 --- /dev/null +++ b/spec/services/boards/lists/generate_service_spec.rb @@ -0,0 +1,40 @@ +require 'spec_helper' + +describe Boards::Lists::GenerateService, services: true do + describe '#execute' do + let(:project) { create(:project_with_board) } + let(:board) { project.board } + let(:user) { create(:user) } + + subject(:service) { described_class.new(project, user) } + + context 'when board lists is empty' do + it 'creates the default lists' do + expect { service.execute }.to change(board.lists, :count).by(4) + end + end + + context 'when board lists is not empty' do + it 'does not creates the default lists' do + create(:list, board: board) + + expect { service.execute }.not_to change(board.lists, :count) + end + end + + context 'when project labels does not contains any list label' do + it 'creates labels' do + expect { service.execute }.to change(project.labels, :count).by(4) + end + end + + context 'when project labels contains some of list label' do + it 'creates the missing labels' do + create(:label, project: project, name: 'Development') + create(:label, project: project, name: 'Ready') + + expect { service.execute }.to change(project.labels, :count).by(2) + end + end + end +end |