diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-24 15:09:37 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-24 15:09:37 +0300 |
commit | 6f15c2c2723dbe14e907379b75201e2ef70a48d3 (patch) | |
tree | f917af54164003d021a4af518ced7271978c5537 /spec/controllers | |
parent | 7a8d983c19c9fe14e7c0b8b6256b8cbacbff1959 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/boards/lists_controller_spec.rb | 11 | ||||
-rw-r--r-- | spec/controllers/groups_controller_spec.rb | 54 |
2 files changed, 30 insertions, 35 deletions
diff --git a/spec/controllers/boards/lists_controller_spec.rb b/spec/controllers/boards/lists_controller_spec.rb index c72d9e5053a..9b09f46d17e 100644 --- a/spec/controllers/boards/lists_controller_spec.rb +++ b/spec/controllers/boards/lists_controller_spec.rb @@ -260,6 +260,17 @@ RSpec.describe Boards::ListsController do end end + context 'with an error service response' do + it 'returns an unprocessable entity response' do + allow(Boards::Lists::DestroyService).to receive(:new) + .and_return(double(execute: ServiceResponse.error(message: 'error'))) + + remove_board_list user: user, board: board, list: planning + + expect(response).to have_gitlab_http_status(:unprocessable_entity) + end + end + def remove_board_list(user:, board:, list:) sign_in(user) diff --git a/spec/controllers/groups_controller_spec.rb b/spec/controllers/groups_controller_spec.rb index 35d8c0b7c6d..9a3df819656 100644 --- a/spec/controllers/groups_controller_spec.rb +++ b/spec/controllers/groups_controller_spec.rb @@ -2,18 +2,18 @@ require 'spec_helper' -RSpec.describe GroupsController do +RSpec.describe GroupsController, factory_default: :keep do include ExternalAuthorizationServiceHelpers - let(:user) { create(:user) } - let(:admin) { create(:admin) } - let(:group) { create(:group, :public) } - let(:project) { create(:project, namespace: group) } - let!(:group_member) { create(:group_member, group: group, user: user) } - let!(:owner) { group.add_owner(create(:user)).user } - let!(:maintainer) { group.add_maintainer(create(:user)).user } - let!(:developer) { group.add_developer(create(:user)).user } - let!(:guest) { group.add_guest(create(:user)).user } + let_it_be_with_refind(:group) { create_default(:group, :public) } + let_it_be_with_refind(:project) { create(:project, namespace: group) } + let_it_be(:user) { create(:user) } + let_it_be(:admin) { create(:admin) } + let_it_be(:group_member) { create(:group_member, group: group, user: user) } + let_it_be(:owner) { group.add_owner(create(:user)).user } + let_it_be(:maintainer) { group.add_maintainer(create(:user)).user } + let_it_be(:developer) { group.add_developer(create(:user)).user } + let_it_be(:guest) { group.add_guest(create(:user)).user } shared_examples 'member with ability to create subgroups' do it 'renders the new page' do @@ -57,7 +57,6 @@ RSpec.describe GroupsController do describe 'GET #show' do before do sign_in(user) - project end let(:format) { :html } @@ -82,7 +81,6 @@ RSpec.describe GroupsController do describe 'GET #details' do before do sign_in(user) - project end let(:format) { :html } @@ -131,12 +129,9 @@ RSpec.describe GroupsController do end describe 'GET #activity' do - render_views - context 'as json' do before do sign_in(user) - project end it 'includes events from all projects in group and subgroups', :sidekiq_might_not_need_inline do @@ -157,10 +152,6 @@ RSpec.describe GroupsController do end context 'when user has no permission to see the event' do - let(:user) { create(:user) } - let(:group) { create(:group) } - let(:project) { create(:project, group: group) } - let(:project_with_restricted_access) do create(:project, :public, issues_access_level: ProjectFeature::PRIVATE, group: group) end @@ -552,8 +543,6 @@ RSpec.describe GroupsController do end context 'when there is a conflicting group path' do - render_views - let!(:conflict_group) { create(:group, path: SecureRandom.hex(12) ) } let!(:old_name) { group.name } @@ -794,6 +783,7 @@ RSpec.describe GroupsController do context 'when transferring to a subgroup goes right' do let(:new_parent_group) { create(:group, :public) } + let(:group) { create(:group, :public) } let!(:group_member) { create(:group_member, :owner, group: group, user: user) } let!(:new_parent_group_member) { create(:group_member, :owner, group: new_parent_group, user: user) } @@ -805,11 +795,8 @@ RSpec.describe GroupsController do } end - it 'returns a notice' do + it 'returns a notice and redirects to the new path' do expect(flash[:notice]).to eq("Group '#{group.name}' was successfully transferred.") - end - - it 'redirects to the new path' do expect(response).to redirect_to("/#{new_parent_group.path}/#{group.path}") end end @@ -826,17 +813,15 @@ RSpec.describe GroupsController do } end - it 'returns a notice' do + it 'returns a notice and redirects to the new path' do expect(flash[:notice]).to eq("Group '#{group.name}' was successfully transferred.") - end - - it 'redirects to the new path' do expect(response).to redirect_to("/#{group.path}") end end context 'When the transfer goes wrong' do let(:new_parent_group) { create(:group, :public) } + let(:group) { create(:group, :public) } let!(:group_member) { create(:group_member, :owner, group: group, user: user) } let!(:new_parent_group_member) { create(:group_member, :owner, group: new_parent_group, user: user) } @@ -850,17 +835,15 @@ RSpec.describe GroupsController do } end - it 'returns an alert' do + it 'returns an alert and redirects to the current path' do expect(flash[:alert]).to eq "Transfer failed: namespace directory cannot be moved" - end - - it 'redirects to the current path' do expect(response).to redirect_to(edit_group_path(group)) end end context 'when the user is not allowed to transfer the group' do let(:new_parent_group) { create(:group, :public) } + let(:group) { create(:group, :public) } let!(:group_member) { create(:group_member, :guest, group: group, user: user) } let!(:new_parent_group_member) { create(:group_member, :guest, group: new_parent_group, user: user) } @@ -879,6 +862,7 @@ RSpec.describe GroupsController do context 'transferring when a project has container images' do let(:group) { create(:group, :public, :nested) } + let(:project) { create(:project, namespace: group) } let!(:group_member) { create(:group_member, :owner, group: group, user: user) } before do @@ -979,6 +963,8 @@ RSpec.describe GroupsController do end context 'when there is no file available to download' do + let(:admin) { create(:admin) } + before do sign_in(admin) end @@ -1149,9 +1135,7 @@ RSpec.describe GroupsController do describe "GET #activity as JSON" do include DesignManagementTestHelpers - render_views - let(:project) { create(:project, :public, group: group) } let(:other_project) { create(:project, :public, group: group) } def get_activity |