diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-08-03 03:49:26 +0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-08-17 18:58:58 +0300 |
commit | aff7a2ef55b317b3e5c8d83f4e9ae9fc64f4fa8f (patch) | |
tree | 14f770901b7206e3d07849e902845086505753a8 /spec/services/boards | |
parent | 296bcbd6640ddeb06093c2505ed749be07362975 (diff) |
Extract base service class for boards related services
Diffstat (limited to 'spec/services/boards')
-rw-r--r-- | spec/services/boards/create_service_spec.rb | 2 | ||||
-rw-r--r-- | spec/services/boards/lists/create_service_spec.rb | 7 | ||||
-rw-r--r-- | spec/services/boards/lists/destroy_service_spec.rb | 9 | ||||
-rw-r--r-- | spec/services/boards/lists/move_service_spec.rb | 21 |
4 files changed, 21 insertions, 18 deletions
diff --git a/spec/services/boards/create_service_spec.rb b/spec/services/boards/create_service_spec.rb index e0ce580aa45..a1a4dd4c57c 100644 --- a/spec/services/boards/create_service_spec.rb +++ b/spec/services/boards/create_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Boards::CreateService, services: true do describe '#execute' do - subject(:service) { described_class.new(project) } + subject(:service) { described_class.new(project, double) } context 'when project does not have a board' do let(:project) { create(:empty_project, board: nil) } diff --git a/spec/services/boards/lists/create_service_spec.rb b/spec/services/boards/lists/create_service_spec.rb index 25c6d614229..27dd4185adb 100644 --- a/spec/services/boards/lists/create_service_spec.rb +++ b/spec/services/boards/lists/create_service_spec.rb @@ -4,9 +4,10 @@ describe Boards::Lists::CreateService, services: true do describe '#execute' do let(:project) { create(:project_with_board) } let(:board) { project.board } + let(:user) { create(:user) } let(:label) { create(:label, name: 'in-progress') } - subject(:service) { described_class.new(project, label_id: label.id) } + subject(:service) { described_class.new(project, user, label_id: label.id) } context 'when board lists is empty' do it 'creates a new list at beginning of the list' do @@ -31,7 +32,7 @@ describe Boards::Lists::CreateService, services: true do create(:list, board: board, position: 1) create(:list, board: board, position: 2) - list = described_class.new(project, label_id: label.id).execute + list = service.execute expect(list.position).to eq 3 end @@ -43,7 +44,7 @@ describe Boards::Lists::CreateService, services: true do create(:done_list, board: board) list1 = create(:list, board: board, position: 1) - list2 = described_class.new(project, label_id: label.id).execute + list2 = service.execute expect(list1.reload.position).to eq 1 expect(list2.reload.position).to eq 2 diff --git a/spec/services/boards/lists/destroy_service_spec.rb b/spec/services/boards/lists/destroy_service_spec.rb index 620f9df739f..4e382017c00 100644 --- a/spec/services/boards/lists/destroy_service_spec.rb +++ b/spec/services/boards/lists/destroy_service_spec.rb @@ -4,11 +4,12 @@ describe Boards::Lists::DestroyService, services: true do describe '#execute' do let(:project) { create(:project_with_board) } let(:board) { project.board } + let(:user) { create(:user) } context 'when list type is label' do it 'removes list from board' do list = create(:list, board: board) - service = described_class.new(project, id: list.id) + service = described_class.new(project, user, id: list.id) expect { service.execute }.to change(board.lists, :count).by(-1) end @@ -20,7 +21,7 @@ describe Boards::Lists::DestroyService, services: true do staging = create(:list, board: board, position: 3) done = create(:done_list, board: board) - described_class.new(project, id: development.id).execute + described_class.new(project, user, id: development.id).execute expect(backlog.reload.position).to be_nil expect(review.reload.position).to eq 1 @@ -31,14 +32,14 @@ describe Boards::Lists::DestroyService, services: true do it 'does not remove list from board when list type is backlog' do list = create(:backlog_list, board: board) - service = described_class.new(project, id: list.id) + service = described_class.new(project, user, id: list.id) expect { service.execute }.not_to change(board.lists, :count) end it 'does not remove list from board when list type is done' do list = create(:done_list, board: board) - service = described_class.new(project, id: list.id) + service = described_class.new(project, user, id: list.id) expect { service.execute }.not_to change(board.lists, :count) end diff --git a/spec/services/boards/lists/move_service_spec.rb b/spec/services/boards/lists/move_service_spec.rb index 54a0c33c5b8..aa93cbad7f4 100644 --- a/spec/services/boards/lists/move_service_spec.rb +++ b/spec/services/boards/lists/move_service_spec.rb @@ -4,6 +4,7 @@ describe Boards::Lists::MoveService, services: true do describe '#execute' do let(:project) { create(:project_with_board) } let(:board) { project.board } + let(:user) { create(:user) } let!(:backlog) { create(:backlog_list, board: board) } let!(:planning) { create(:list, board: board, position: 1) } @@ -14,7 +15,7 @@ describe Boards::Lists::MoveService, services: true do context 'when list type is set to label' do it 'keeps position of lists when new position is nil' do - service = described_class.new(project, { id: planning.id, position: nil }) + service = described_class.new(project, user, id: planning.id, position: nil) service.execute @@ -22,7 +23,7 @@ describe Boards::Lists::MoveService, services: true do end it 'keeps position of lists when new positon is equal to old position' do - service = described_class.new(project, { id: planning.id, position: 1 }) + service = described_class.new(project, user, id: planning.id, position: 1) service.execute @@ -30,7 +31,7 @@ describe Boards::Lists::MoveService, services: true do end it 'keeps position of lists when new positon is negative' do - service = described_class.new(project, { id: planning.id, position: -1 }) + service = described_class.new(project, user, id: planning.id, position: -1) service.execute @@ -38,7 +39,7 @@ describe Boards::Lists::MoveService, services: true do end it 'keeps position of lists when new positon is greater than number of labels lists' do - service = described_class.new(project, { id: planning.id, position: 6 }) + service = described_class.new(project, user, id: planning.id, position: 6) service.execute @@ -46,7 +47,7 @@ describe Boards::Lists::MoveService, services: true do end it 'increments position of intermediate lists when new positon is equal to first position' do - service = described_class.new(project, { id: staging.id, position: 1 }) + service = described_class.new(project, user, id: staging.id, position: 1) service.execute @@ -54,7 +55,7 @@ describe Boards::Lists::MoveService, services: true do end it 'decrements position of intermediate lists when new positon is equal to last position' do - service = described_class.new(project, { id: planning.id, position: 4 }) + service = described_class.new(project, user, id: planning.id, position: 4) service.execute @@ -62,7 +63,7 @@ describe Boards::Lists::MoveService, services: true do end it 'decrements position of intermediate lists when new position is greater than old position' do - service = described_class.new(project, { id: planning.id, position: 3 }) + service = described_class.new(project, user, id: planning.id, position: 3) service.execute @@ -70,7 +71,7 @@ describe Boards::Lists::MoveService, services: true do end it 'increments position of intermediate lists when new position is lower than old position' do - service = described_class.new(project, { id: staging.id, position: 2 }) + service = described_class.new(project, user, id: staging.id, position: 2) service.execute @@ -79,7 +80,7 @@ describe Boards::Lists::MoveService, services: true do end it 'keeps position of lists when list type is backlog' do - service = described_class.new(project, { id: backlog.id, position: 2 }) + service = described_class.new(project, user, id: backlog.id, position: 2) service.execute @@ -87,7 +88,7 @@ describe Boards::Lists::MoveService, services: true do end it 'keeps position of lists when list type is done' do - service = described_class.new(project, { id: done.id, position: 2 }) + service = described_class.new(project, user, id: done.id, position: 2) service.execute |