diff options
Diffstat (limited to 'spec/services/boards')
-rw-r--r-- | spec/services/boards/destroy_service_spec.rb | 23 | ||||
-rw-r--r-- | spec/services/boards/issues/move_service_spec.rb | 1 | ||||
-rw-r--r-- | spec/services/boards/lists/list_service_spec.rb | 46 | ||||
-rw-r--r-- | spec/services/boards/lists/update_service_spec.rb | 41 |
4 files changed, 40 insertions, 71 deletions
diff --git a/spec/services/boards/destroy_service_spec.rb b/spec/services/boards/destroy_service_spec.rb new file mode 100644 index 00000000000..cd6df832547 --- /dev/null +++ b/spec/services/boards/destroy_service_spec.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Boards::DestroyService do + context 'with project board' do + let_it_be(:parent) { create(:project) } + + let(:boards) { parent.boards } + let(:board_factory) { :board } + + it_behaves_like 'board destroy service' + end + + context 'with group board' do + let_it_be(:parent) { create(:group) } + + let(:boards) { parent.boards } + let(:board_factory) { :board } + + it_behaves_like 'board destroy service' + end +end diff --git a/spec/services/boards/issues/move_service_spec.rb b/spec/services/boards/issues/move_service_spec.rb index 01a3ec72987..3a25f13762c 100644 --- a/spec/services/boards/issues/move_service_spec.rb +++ b/spec/services/boards/issues/move_service_spec.rb @@ -62,6 +62,7 @@ RSpec.describe Boards::Issues::MoveService do let_it_be(:testing) { create(:group_label, group: group, name: 'Testing') } let_it_be(:list1) { create(:list, board: board1, label: development, position: 0) } let_it_be(:list2) { create(:list, board: board1, label: testing, position: 1) } + let(:params) { { board_id: board1.id, from_list_id: list1.id, to_list_id: list2.id } } before do diff --git a/spec/services/boards/lists/list_service_spec.rb b/spec/services/boards/lists/list_service_spec.rb index 21619abf6aa..0c8a8dc7329 100644 --- a/spec/services/boards/lists/list_service_spec.rb +++ b/spec/services/boards/lists/list_service_spec.rb @@ -8,46 +8,32 @@ RSpec.describe Boards::Lists::ListService do describe '#execute' do let(:service) { described_class.new(parent, user) } - shared_examples 'hidden lists' do - let!(:list) { create(:list, board: board, label: label) } - - context 'when hide_backlog_list is true' do - it 'hides backlog list' do - board.update!(hide_backlog_list: true) - - expect(service.execute(board)).to match_array([board.closed_list, list]) - end - end - - context 'when hide_closed_list is true' do - it 'hides closed list' do - board.update!(hide_closed_list: true) - - expect(service.execute(board)).to match_array([board.backlog_list, list]) - end - end - end - context 'when board parent is a project' do - let(:project) { create(:project) } - let(:board) { create(:board, project: project) } - let(:label) { create(:label, project: project) } - let!(:list) { create(:list, board: board, label: label) } + let_it_be(:project) { create(:project) } + let_it_be_with_reload(:board) { create(:board, project: project) } + let_it_be(:label) { create(:label, project: project) } + let_it_be(:list) { create(:list, board: board, label: label) } + let_it_be(:unrelated_list) { create(:list) } + let(:parent) { project } it_behaves_like 'lists list service' - it_behaves_like 'hidden lists' end context 'when board parent is a group' do - let(:group) { create(:group) } - let(:board) { create(:board, group: group) } - let(:label) { create(:group_label, group: group) } - let!(:list) { create(:list, board: board, label: label) } + let_it_be(:group) { create(:group) } + let_it_be_with_reload(:board) { create(:board, group: group) } + let_it_be(:label) { create(:group_label, group: group) } + let_it_be(:list) { create(:list, board: board, label: label) } + let_it_be(:unrelated_list) { create(:list) } + let(:parent) { group } it_behaves_like 'lists list service' - it_behaves_like 'hidden lists' + end + + def create_backlog_list(board) + create(:backlog_list, board: board) end end end diff --git a/spec/services/boards/lists/update_service_spec.rb b/spec/services/boards/lists/update_service_spec.rb index cdc7784469a..10fed9b7aac 100644 --- a/spec/services/boards/lists/update_service_spec.rb +++ b/spec/services/boards/lists/update_service_spec.rb @@ -6,47 +6,6 @@ RSpec.describe Boards::Lists::UpdateService do let(:user) { create(:user) } let!(:list) { create(:list, board: board, position: 0) } - shared_examples 'moving list' do - context 'when user can admin list' do - it 'calls Lists::MoveService to update list position' do - board.resource_parent.add_developer(user) - - expect(Boards::Lists::MoveService).to receive(:new).with(board.resource_parent, user, params).and_call_original - expect_any_instance_of(Boards::Lists::MoveService).to receive(:execute).with(list) - - service.execute(list) - end - end - - context 'when user cannot admin list' do - it 'does not call Lists::MoveService to update list position' do - expect(Boards::Lists::MoveService).not_to receive(:new) - - service.execute(list) - end - end - end - - shared_examples 'updating list preferences' do - context 'when user can read list' do - it 'updates list preference for user' do - board.resource_parent.add_guest(user) - - service.execute(list) - - expect(list.preferences_for(user).collapsed).to eq(true) - end - end - - context 'when user cannot read list' do - it 'does not update list preference for user' do - service.execute(list) - - expect(list.preferences_for(user).collapsed).to be_nil - end - end - end - describe '#execute' do let(:service) { described_class.new(board.resource_parent, user, params) } |