diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-08-16 07:07:25 +0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-08-17 18:58:59 +0300 |
commit | f77c47a51c8fef379b2dc9473545e53a28ec3c7f (patch) | |
tree | b46dd6074bae6822ada612246b50101898c2f18e /spec/services/boards/lists | |
parent | affed37065974991f4c578993d34ec1608560ad9 (diff) |
Remove lookup inside services to keep them consistent with other ones
Diffstat (limited to 'spec/services/boards/lists')
-rw-r--r-- | spec/services/boards/lists/destroy_service_spec.rb | 14 | ||||
-rw-r--r-- | spec/services/boards/lists/move_service_spec.rb | 44 |
2 files changed, 29 insertions, 29 deletions
diff --git a/spec/services/boards/lists/destroy_service_spec.rb b/spec/services/boards/lists/destroy_service_spec.rb index 3b887a55a97..6eff445feee 100644 --- a/spec/services/boards/lists/destroy_service_spec.rb +++ b/spec/services/boards/lists/destroy_service_spec.rb @@ -9,9 +9,9 @@ describe Boards::Lists::DestroyService, services: true do context 'when list type is label' do it 'removes list from board' do list = create(:list, board: board) - service = described_class.new(project, user, id: list.id) + service = described_class.new(project, user) - expect { service.execute }.to change(board.lists, :count).by(-1) + expect { service.execute(list) }.to change(board.lists, :count).by(-1) end it 'decrements position of higher lists' do @@ -21,7 +21,7 @@ describe Boards::Lists::DestroyService, services: true do staging = create(:list, board: board, position: 2) done = create(:done_list, board: board) - described_class.new(project, user, id: development.id).execute + described_class.new(project, user).execute(development) expect(backlog.reload.position).to be_nil expect(review.reload.position).to eq 0 @@ -32,16 +32,16 @@ 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, user, id: list.id) + service = described_class.new(project, user) - expect { service.execute }.not_to change(board.lists, :count) + expect { service.execute(list) }.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, user, id: list.id) + service = described_class.new(project, user) - expect { service.execute }.not_to change(board.lists, :count) + expect { service.execute(list) }.not_to change(board.lists, :count) end end end diff --git a/spec/services/boards/lists/move_service_spec.rb b/spec/services/boards/lists/move_service_spec.rb index 11de74a96a1..3e9b7d07fc6 100644 --- a/spec/services/boards/lists/move_service_spec.rb +++ b/spec/services/boards/lists/move_service_spec.rb @@ -15,90 +15,90 @@ 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, user, id: planning.id, position: nil) + service = described_class.new(project, user, position: nil) - service.execute + service.execute(planning) expect(current_list_positions).to eq [0, 1, 2, 3] end it 'keeps position of lists when new positon is equal to old position' do - service = described_class.new(project, user, id: planning.id, position: planning.position) + service = described_class.new(project, user, position: planning.position) - service.execute + service.execute(planning) expect(current_list_positions).to eq [0, 1, 2, 3] end it 'keeps position of lists when new positon is negative' do - service = described_class.new(project, user, id: planning.id, position: -1) + service = described_class.new(project, user, position: -1) - service.execute + service.execute(planning) expect(current_list_positions).to eq [0, 1, 2, 3] end it 'keeps position of lists when new positon is equal to number of labels lists' do - service = described_class.new(project, user, id: planning.id, position: board.lists.label.size) + service = described_class.new(project, user, position: board.lists.label.size) - service.execute + service.execute(planning) expect(current_list_positions).to eq [0, 1, 2, 3] end it 'keeps position of lists when new positon is greater than number of labels lists' do - service = described_class.new(project, user, id: planning.id, position: board.lists.label.size + 1) + service = described_class.new(project, user, position: board.lists.label.size + 1) - service.execute + service.execute(planning) expect(current_list_positions).to eq [0, 1, 2, 3] end it 'increments position of intermediate lists when new positon is equal to first position' do - service = described_class.new(project, user, id: staging.id, position: 0) + service = described_class.new(project, user, position: 0) - service.execute + service.execute(staging) expect(current_list_positions).to eq [1, 2, 3, 0] end it 'decrements position of intermediate lists when new positon is equal to last position' do - service = described_class.new(project, user, id: planning.id, position: board.lists.label.last.position) + service = described_class.new(project, user, position: board.lists.label.last.position) - service.execute + service.execute(planning) expect(current_list_positions).to eq [3, 0, 1, 2] end it 'decrements position of intermediate lists when new position is greater than old position' do - service = described_class.new(project, user, id: planning.id, position: 2) + service = described_class.new(project, user, position: 2) - service.execute + service.execute(planning) expect(current_list_positions).to eq [2, 0, 1, 3] end it 'increments position of intermediate lists when new position is lower than old position' do - service = described_class.new(project, user, id: staging.id, position: 1) + service = described_class.new(project, user, position: 1) - service.execute + service.execute(staging) expect(current_list_positions).to eq [0, 2, 3, 1] end end it 'keeps position of lists when list type is backlog' do - service = described_class.new(project, user, id: backlog.id, position: 2) + service = described_class.new(project, user, position: 2) - service.execute + service.execute(backlog) expect(current_list_positions).to eq [0, 1, 2, 3] end it 'keeps position of lists when list type is done' do - service = described_class.new(project, user, id: done.id, position: 2) + service = described_class.new(project, user, position: 2) - service.execute + service.execute(done) expect(current_list_positions).to eq [0, 1, 2, 3] end |