diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /spec/controllers/groups | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'spec/controllers/groups')
18 files changed, 125 insertions, 81 deletions
diff --git a/spec/controllers/groups/avatars_controller_spec.rb b/spec/controllers/groups/avatars_controller_spec.rb index 1229328000b..18b116831b2 100644 --- a/spec/controllers/groups/avatars_controller_spec.rb +++ b/spec/controllers/groups/avatars_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Groups::AvatarsController do +RSpec.describe Groups::AvatarsController do include ExternalAuthorizationServiceHelpers let(:user) { create(:user) } diff --git a/spec/controllers/groups/boards_controller_spec.rb b/spec/controllers/groups/boards_controller_spec.rb index b556af0eedc..66595c27531 100644 --- a/spec/controllers/groups/boards_controller_spec.rb +++ b/spec/controllers/groups/boards_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Groups::BoardsController do +RSpec.describe Groups::BoardsController do let(:group) { create(:group) } let(:user) { create(:user) } diff --git a/spec/controllers/groups/children_controller_spec.rb b/spec/controllers/groups/children_controller_spec.rb index a8921300e6b..e97fe50c468 100644 --- a/spec/controllers/groups/children_controller_spec.rb +++ b/spec/controllers/groups/children_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Groups::ChildrenController do +RSpec.describe Groups::ChildrenController do include ExternalAuthorizationServiceHelpers let(:group) { create(:group, :public) } diff --git a/spec/controllers/groups/clusters/applications_controller_spec.rb b/spec/controllers/groups/clusters/applications_controller_spec.rb index bab9e64cfdb..c1d170edce3 100644 --- a/spec/controllers/groups/clusters/applications_controller_spec.rb +++ b/spec/controllers/groups/clusters/applications_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Groups::Clusters::ApplicationsController do +RSpec.describe Groups::Clusters::ApplicationsController do include AccessMatchersForController def current_application diff --git a/spec/controllers/groups/clusters_controller_spec.rb b/spec/controllers/groups/clusters_controller_spec.rb index 1f2f6bd811b..6765cf0990a 100644 --- a/spec/controllers/groups/clusters_controller_spec.rb +++ b/spec/controllers/groups/clusters_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Groups::ClustersController do +RSpec.describe Groups::ClustersController do include AccessMatchersForController include GoogleApi::CloudPlatformHelpers @@ -47,6 +47,13 @@ describe Groups::ClustersController do expect(response).to match_response_schema('cluster_list') end + it 'sets the polling interval header for json requests' do + go(format: :json) + + expect(response).to have_gitlab_http_status(:ok) + expect(response.headers['Poll-Interval']).to eq("10000") + end + context 'when page is specified' do let(:last_page) { group.clusters.page.total_pages } let(:total_count) { group.clusters.page.total_count } diff --git a/spec/controllers/groups/group_links_controller_spec.rb b/spec/controllers/groups/group_links_controller_spec.rb index ca430414d17..07299382230 100644 --- a/spec/controllers/groups/group_links_controller_spec.rb +++ b/spec/controllers/groups/group_links_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Groups::GroupLinksController do +RSpec.describe Groups::GroupLinksController do let(:shared_with_group) { create(:group, :private) } let(:shared_group) { create(:group, :private) } let(:user) { create(:user) } diff --git a/spec/controllers/groups/group_members_controller_spec.rb b/spec/controllers/groups/group_members_controller_spec.rb index f69d0602404..85f1b247ee9 100644 --- a/spec/controllers/groups/group_members_controller_spec.rb +++ b/spec/controllers/groups/group_members_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Groups::GroupMembersController do +RSpec.describe Groups::GroupMembersController do include ExternalAuthorizationServiceHelpers let(:user) { create(:user) } diff --git a/spec/controllers/groups/imports_controller_spec.rb b/spec/controllers/groups/imports_controller_spec.rb new file mode 100644 index 00000000000..eb43a62b75b --- /dev/null +++ b/spec/controllers/groups/imports_controller_spec.rb @@ -0,0 +1,85 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Groups::ImportsController do + describe 'GET #show' do + let_it_be(:user) { create(:user) } + let_it_be(:group) { create(:group, :private) } + + context 'when the user has permission to view the group' do + before do + sign_in(user) + group.add_maintainer(user) + end + + context 'when the import is in progress' do + before do + create(:group_import_state, group: group) + end + + it 'renders the show template' do + get :show, params: { group_id: group } + + expect(response).to render_template :show + end + + it 'sets the flash notice' do + get :show, params: { group_id: group, continue: { to: '/', notice_now: 'In progress' } } + + expect(flash.now[:notice]).to eq 'In progress' + end + end + + context 'when the import has failed' do + before do + create(:group_import_state, :failed, group: group) + end + + it 'redirects to the new group path' do + get :show, params: { group_id: group } + + expect(response).to redirect_to new_group_path(group) + end + + it 'sets a flash error' do + get :show, params: { group_id: group } + + expect(flash[:alert]).to eq 'Failed to import group.' + end + end + + context 'when the import has finished' do + before do + create(:group_import_state, :finished, group: group) + end + + it 'redirects to the group page' do + get :show, params: { group_id: group } + + expect(response).to redirect_to group_path(group) + end + end + + context 'when there is no import state' do + it 'redirects to the group page' do + get :show, params: { group_id: group } + + expect(response).to redirect_to group_path(group) + end + end + end + + context 'when the user does not have permission to view the group' do + before do + sign_in(user) + end + + it 'returns a 404' do + get :show, params: { group_id: group } + + expect(response).to have_gitlab_http_status :not_found + end + end + end +end diff --git a/spec/controllers/groups/labels_controller_spec.rb b/spec/controllers/groups/labels_controller_spec.rb index 90f91a4ff72..20ee19b01d1 100644 --- a/spec/controllers/groups/labels_controller_spec.rb +++ b/spec/controllers/groups/labels_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Groups::LabelsController do +RSpec.describe Groups::LabelsController do let_it_be(:group) { create(:group) } let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project, namespace: group) } diff --git a/spec/controllers/groups/milestones_controller_spec.rb b/spec/controllers/groups/milestones_controller_spec.rb index afb950bc538..e47bb75af22 100644 --- a/spec/controllers/groups/milestones_controller_spec.rb +++ b/spec/controllers/groups/milestones_controller_spec.rb @@ -2,21 +2,13 @@ require 'spec_helper' -describe Groups::MilestonesController do +RSpec.describe Groups::MilestonesController do let(:group) { create(:group, :public) } let!(:project) { create(:project, :public, group: group) } let!(:project2) { create(:project, group: group) } let(:user) { create(:user) } let(:title) { '肯定不是中文的问题' } - let(:milestone) do - project_milestone = create(:milestone, project: project) - - GroupMilestone.build( - group, - [project], - project_milestone.title - ) - end + let(:milestone) { create(:milestone, project: project) } let(:milestone_path) { group_milestone_path(group, milestone.safe_title, title: milestone.title) } let(:milestone_params) do @@ -168,17 +160,16 @@ describe Groups::MilestonesController do context 'as JSON' do let!(:milestone) { create(:milestone, group: group, title: 'group milestone') } - let!(:legacy_milestone1) { create(:milestone, project: project, title: 'legacy') } - let!(:legacy_milestone2) { create(:milestone, project: project2, title: 'legacy') } + let!(:project_milestone1) { create(:milestone, project: project, title: 'same name') } + let!(:project_milestone2) { create(:milestone, project: project2, title: 'same name') } - it 'lists legacy group milestones and group milestones' do + it 'lists project and group milestones' do get :index, params: { group_id: group.to_param }, format: :json milestones = json_response - expect(milestones.count).to eq(2) - expect(milestones.first["title"]).to eq("group milestone") - expect(milestones.second["title"]).to eq("legacy") + expect(milestones.count).to eq(3) + expect(milestones.collect { |m| m['title'] }).to match_array(['same name', 'same name', 'group milestone']) expect(response).to have_gitlab_http_status(:ok) expect(response.content_type).to eq 'application/json' end @@ -191,8 +182,9 @@ describe Groups::MilestonesController do get :index, params: { group_id: group.to_param }, format: :json milestones = json_response - expect(milestones.count).to eq(3) - expect(milestones.second["title"]).to eq("subgroup milestone") + milestone_titles = milestones.map { |m| m['title'] } + expect(milestones.count).to eq(4) + expect(milestone_titles).to match_array(['same name', 'same name', 'group milestone', 'subgroup milestone']) end end @@ -218,31 +210,18 @@ describe Groups::MilestonesController do end describe '#show' do - let(:milestone1) { create(:milestone, project: project, title: 'legacy') } - let(:milestone2) { create(:milestone, project: project, title: 'legacy') } - let(:group_milestone) { create(:milestone, group: group) } + render_views - context 'when there is a title parameter' do - it 'searches for a legacy group milestone' do - expect(GroupMilestone).to receive(:build) - expect(Milestone).not_to receive(:find_by_iid) + let!(:group_milestone) { create(:milestone, group: group) } - get :show, params: { group_id: group.to_param, id: title, title: milestone1.safe_title } - end - end + it 'renders for a group milestone' do + get :show, params: { group_id: group.to_param, id: group_milestone.iid } - context 'when there is not a title parameter' do - it 'searches for a group milestone' do - expect(GlobalMilestone).not_to receive(:build) - expect(Milestone).to receive(:find_by_iid) - - get :show, params: { group_id: group.to_param, id: group_milestone.id } - end + expect(response).to have_gitlab_http_status(:ok) + expect(response.body).to include(group_milestone.title) end end - it_behaves_like 'milestone tabs' - describe "#create" do it "creates group milestone with Chinese title" do post :create, @@ -277,34 +256,6 @@ describe Groups::MilestonesController do expect(response).to redirect_to(group_milestone_path(group, milestone.iid)) expect(milestone.title).to eq("title changed") end - - context "legacy group milestones" do - let!(:milestone1) { create(:milestone, project: project, title: 'legacy milestone', description: "old description") } - let!(:milestone2) { create(:milestone, project: project2, title: 'legacy milestone', description: "old description") } - - it "updates only group milestones state" do - milestone_params[:title] = "title changed" - milestone_params[:description] = "description changed" - milestone_params[:state_event] = "close" - - put :update, - params: { - id: milestone1.title.to_slug.to_s, - group_id: group.to_param, - milestone: milestone_params, - title: milestone1.title - } - - expect(response).to redirect_to(group_milestone_path(group, milestone1.safe_title, title: milestone1.title)) - - [milestone1, milestone2].each do |milestone| - milestone.reload - expect(milestone.title).to eq("legacy milestone") - expect(milestone.description).to eq("old description") - expect(milestone.state).to eq("closed") - end - end - end end describe "#destroy" do diff --git a/spec/controllers/groups/registry/repositories_controller_spec.rb b/spec/controllers/groups/registry/repositories_controller_spec.rb index 7b78aeadbd8..ddac8fc5002 100644 --- a/spec/controllers/groups/registry/repositories_controller_spec.rb +++ b/spec/controllers/groups/registry/repositories_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Groups::Registry::RepositoriesController do +RSpec.describe Groups::Registry::RepositoriesController do let_it_be(:user) { create(:user) } let_it_be(:guest) { create(:user) } let_it_be(:group, reload: true) { create(:group) } @@ -17,6 +17,7 @@ describe Groups::Registry::RepositoriesController do before do stub_container_registry_config(enabled: true) + stub_container_registry_tags(repository: :any, tags: []) group.add_owner(user) group.add_guest(guest) sign_in(user) diff --git a/spec/controllers/groups/runners_controller_spec.rb b/spec/controllers/groups/runners_controller_spec.rb index bf556078eec..376cd569952 100644 --- a/spec/controllers/groups/runners_controller_spec.rb +++ b/spec/controllers/groups/runners_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Groups::RunnersController do +RSpec.describe Groups::RunnersController do let(:user) { create(:user) } let(:group) { create(:group) } let(:runner) { create(:ci_runner, :group, groups: [group]) } diff --git a/spec/controllers/groups/settings/ci_cd_controller_spec.rb b/spec/controllers/groups/settings/ci_cd_controller_spec.rb index 45d62a7e6cf..55c19de4aa1 100644 --- a/spec/controllers/groups/settings/ci_cd_controller_spec.rb +++ b/spec/controllers/groups/settings/ci_cd_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Groups::Settings::CiCdController do +RSpec.describe Groups::Settings::CiCdController do include ExternalAuthorizationServiceHelpers let(:group) { create(:group) } diff --git a/spec/controllers/groups/settings/integrations_controller_spec.rb b/spec/controllers/groups/settings/integrations_controller_spec.rb index 29c93c621bd..d079f3f077e 100644 --- a/spec/controllers/groups/settings/integrations_controller_spec.rb +++ b/spec/controllers/groups/settings/integrations_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Groups::Settings::IntegrationsController do +RSpec.describe Groups::Settings::IntegrationsController do let_it_be(:project) { create(:project) } let(:user) { create(:user) } let(:group) { create(:group) } diff --git a/spec/controllers/groups/settings/repository_controller_spec.rb b/spec/controllers/groups/settings/repository_controller_spec.rb index 9523d404538..6d0caf6d655 100644 --- a/spec/controllers/groups/settings/repository_controller_spec.rb +++ b/spec/controllers/groups/settings/repository_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Groups::Settings::RepositoryController do +RSpec.describe Groups::Settings::RepositoryController do include ExternalAuthorizationServiceHelpers let(:group) { create(:group) } diff --git a/spec/controllers/groups/shared_projects_controller_spec.rb b/spec/controllers/groups/shared_projects_controller_spec.rb index a31b5682ae0..dafce094b14 100644 --- a/spec/controllers/groups/shared_projects_controller_spec.rb +++ b/spec/controllers/groups/shared_projects_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Groups::SharedProjectsController do +RSpec.describe Groups::SharedProjectsController do def get_shared_projects(params = {}) get :index, params: params.reverse_merge(format: :json, group_id: group.full_path) end diff --git a/spec/controllers/groups/uploads_controller_spec.rb b/spec/controllers/groups/uploads_controller_spec.rb index 8abebd04e8b..ea6a5ce8841 100644 --- a/spec/controllers/groups/uploads_controller_spec.rb +++ b/spec/controllers/groups/uploads_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Groups::UploadsController do +RSpec.describe Groups::UploadsController do include WorkhorseHelpers let(:model) { create(:group, :public) } diff --git a/spec/controllers/groups/variables_controller_spec.rb b/spec/controllers/groups/variables_controller_spec.rb index d6c790ae7b8..e2a14165cb4 100644 --- a/spec/controllers/groups/variables_controller_spec.rb +++ b/spec/controllers/groups/variables_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Groups::VariablesController do +RSpec.describe Groups::VariablesController do include ExternalAuthorizationServiceHelpers let(:group) { create(:group) } |