diff options
author | Thong Kuah <tkuah@gitlab.com> | 2018-10-15 16:37:51 +1300 |
---|---|---|
committer | Thong Kuah <tkuah@gitlab.com> | 2018-11-01 18:38:36 +1300 |
commit | 5b3c096c9e0c9e8e7e1cb35c1b9e347995b948f5 (patch) | |
tree | f0e4934cd4bbf59d670ff8911e64d94602907259 /spec | |
parent | 5a953741820b78492333e1543062a5c222694d8c (diff) | |
download | gitlab-ce-5b3c096c9e0c9e8e7e1cb35c1b9e347995b948f5.tar.gz |
Convert clusters to use a top-level controller
In preparation so that we can create both cluster attached to project
and cluster attached to group.
- Move ClustersController to top level
- Move Clusters::ApplicationsController to top-level too
- Creates a Clusters::BaseController to share common functions
- Do not rely on @project ivar. Anything could set the ivar.
- Fix Vue page components due to new data-page value
Because of the controller change we have gone from
`projects:clusters:new` to `clusters:new`, so we need to update the file
location of the page components. There is somewhere a function that will
convert data-page to a file location.
On that note, projects/clusters/gcp/new/, translate to
Projects::Clusters::Gcp#new doesn't exist so replace that with
clusters/create_gcp/ and clusters/create_user/
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/clusters/applications_controller_spec.rb (renamed from spec/controllers/projects/clusters/applications_controller_spec.rb) | 4 | ||||
-rw-r--r-- | spec/controllers/clusters_controller_spec.rb (renamed from spec/controllers/projects/clusters_controller_spec.rb) | 37 | ||||
-rw-r--r-- | spec/features/projects/clusters/gcp_spec.rb | 6 | ||||
-rw-r--r-- | spec/features/projects/clusters/user_spec.rb | 2 |
4 files changed, 31 insertions, 18 deletions
diff --git a/spec/controllers/projects/clusters/applications_controller_spec.rb b/spec/controllers/clusters/applications_controller_spec.rb index 9e17e392d3d..12846795f3e 100644 --- a/spec/controllers/projects/clusters/applications_controller_spec.rb +++ b/spec/controllers/clusters/applications_controller_spec.rb @@ -1,6 +1,8 @@ +# frozen_string_literal: true + require 'spec_helper' -describe Projects::Clusters::ApplicationsController do +describe Clusters::ApplicationsController do include AccessMatchersForController def current_application diff --git a/spec/controllers/projects/clusters_controller_spec.rb b/spec/controllers/clusters_controller_spec.rb index 9201332c5c8..459157e4ad1 100644 --- a/spec/controllers/projects/clusters_controller_spec.rb +++ b/spec/controllers/clusters_controller_spec.rb @@ -1,6 +1,8 @@ +# frozen_string_literal: true + require 'spec_helper' -describe Projects::ClustersController do +describe ClustersController do include AccessMatchersForController include GoogleApi::CloudPlatformHelpers @@ -218,9 +220,9 @@ describe Projects::ClustersController do describe 'security' do before do allow_any_instance_of(described_class) - .to receive(:token_in_session).and_return('token') + .to receive(:token_in_session).and_return('token') allow_any_instance_of(described_class) - .to receive(:expires_at_in_session).and_return(1.hour.since.to_i.to_s) + .to receive(:expires_at_in_session).and_return(1.hour.since.to_i.to_s) allow_any_instance_of(GoogleApi::CloudPlatform::Client) .to receive(:projects_zones_clusters_create) do OpenStruct.new( @@ -322,10 +324,11 @@ describe Projects::ClustersController do let(:cluster) { create(:cluster, :providing_by_gcp, projects: [project]) } def go - get :status, namespace_id: project.namespace, - project_id: project, - id: cluster, - format: :json + get :status, + namespace_id: project.namespace, + project_id: project, + id: cluster, + format: :json end describe 'functionality' do @@ -359,9 +362,10 @@ describe Projects::ClustersController do let(:cluster) { create(:cluster, :provided_by_gcp, projects: [project]) } def go - get :show, namespace_id: project.namespace, - project_id: project, - id: cluster + get :show, + namespace_id: project.namespace, + project_id: project, + id: cluster end describe 'functionality' do @@ -530,9 +534,10 @@ describe Projects::ClustersController do let!(:cluster) { create(:cluster, :provided_by_gcp, :production_environment, projects: [project]) } def go - delete :destroy, namespace_id: project.namespace, - project_id: project, - id: cluster + delete :destroy, + namespace_id: project.namespace, + project_id: project, + id: cluster end describe 'functionality' do @@ -591,4 +596,10 @@ describe Projects::ClustersController do it { expect { go }.to be_denied_for(:external) } end end + + context 'no project_id param' do + it 'does not respond to any action without project_id param' do + expect { get :index }.to raise_error(ActionController::UrlGenerationError) + end + end end diff --git a/spec/features/projects/clusters/gcp_spec.rb b/spec/features/projects/clusters/gcp_spec.rb index 8b92b9fc869..e9f230b2be0 100644 --- a/spec/features/projects/clusters/gcp_spec.rb +++ b/spec/features/projects/clusters/gcp_spec.rb @@ -9,16 +9,16 @@ describe 'Gcp Cluster', :js do before do project.add_maintainer(user) gitlab_sign_in(user) - allow(Projects::ClustersController).to receive(:STATUS_POLLING_INTERVAL) { 100 } + allow(ClustersController).to receive(:STATUS_POLLING_INTERVAL) { 100 } end context 'when user has signed with Google' do let(:project_id) { 'test-project-1234' } before do - allow_any_instance_of(Projects::ClustersController) + allow_any_instance_of(ClustersController) .to receive(:token_in_session).and_return('token') - allow_any_instance_of(Projects::ClustersController) + allow_any_instance_of(ClustersController) .to receive(:expires_at_in_session).and_return(1.hour.since.to_i.to_s) end diff --git a/spec/features/projects/clusters/user_spec.rb b/spec/features/projects/clusters/user_spec.rb index 9ae1dba60b5..b8bc7f490a6 100644 --- a/spec/features/projects/clusters/user_spec.rb +++ b/spec/features/projects/clusters/user_spec.rb @@ -9,7 +9,7 @@ describe 'User Cluster', :js do before do project.add_maintainer(user) gitlab_sign_in(user) - allow(Projects::ClustersController).to receive(:STATUS_POLLING_INTERVAL) { 100 } + allow(ClustersController).to receive(:STATUS_POLLING_INTERVAL) { 100 } end context 'when user does not have a cluster and visits cluster index page' do |