summaryrefslogtreecommitdiff
path: root/spec/controllers
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2017-12-05 13:29:41 +0100
committerKamil Trzcinski <ayufan@ayufan.eu>2017-12-05 13:29:41 +0100
commit9429514e303bdceee0621b5c4bf02ad8ca0a7add (patch)
treea7bc5cc425601c4ea73ff9a9be90eebc21a93b17 /spec/controllers
parentb9d8d85e20af046c7dbe11c69fd3252f0486b9b2 (diff)
parent3138fcdcd70fd30fea74deff537b9836d6c94d21 (diff)
downloadgitlab-ce-9429514e303bdceee0621b5c4bf02ad8ca0a7add.tar.gz
Merge branch '35616-move-k8-to-cluster-page' into cluster-page-with-list-clusters
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/projects/clusters/gcp_controller_spec.rb2
-rw-r--r--spec/controllers/projects/clusters/user_controller_spec.rb2
-rw-r--r--spec/controllers/projects/clusters_controller_spec.rb38
-rw-r--r--spec/controllers/projects_controller_spec.rb21
4 files changed, 41 insertions, 22 deletions
diff --git a/spec/controllers/projects/clusters/gcp_controller_spec.rb b/spec/controllers/projects/clusters/gcp_controller_spec.rb
index e0fe291e724..bb5ef7bb365 100644
--- a/spec/controllers/projects/clusters/gcp_controller_spec.rb
+++ b/spec/controllers/projects/clusters/gcp_controller_spec.rb
@@ -16,7 +16,7 @@ describe Projects::Clusters::GcpController do
end
context 'when omniauth has been configured' do
- let(:key) { 'secere-key' }
+ let(:key) { 'secret-key' }
let(:session_key_for_redirect_uri) do
GoogleApi::CloudPlatform::Client.session_key_for_redirect_uri(key)
diff --git a/spec/controllers/projects/clusters/user_controller_spec.rb b/spec/controllers/projects/clusters/user_controller_spec.rb
index 06a9c50c5cc..22005e0dc66 100644
--- a/spec/controllers/projects/clusters/user_controller_spec.rb
+++ b/spec/controllers/projects/clusters/user_controller_spec.rb
@@ -58,7 +58,7 @@ describe Projects::Clusters::UserController do
project.add_master(user)
sign_in(user)
end
-
+
context 'when creates a cluster' do
it 'creates a new cluster' do
expect(ClusterProvisionWorker).to receive(:perform_async)
diff --git a/spec/controllers/projects/clusters_controller_spec.rb b/spec/controllers/projects/clusters_controller_spec.rb
index 9ff0b745073..806e33e0e4e 100644
--- a/spec/controllers/projects/clusters_controller_spec.rb
+++ b/spec/controllers/projects/clusters_controller_spec.rb
@@ -181,7 +181,7 @@ describe Projects::ClustersController do
end
describe 'PUT update' do
- context 'Managed' do
+ context 'when cluster is provided by GCP' do
let(:cluster) { create(:cluster, :provided_by_gcp, projects: [project]) }
let(:user) { create(:user) }
@@ -207,7 +207,7 @@ describe Projects::ClustersController do
go
cluster.reload
- expect(response).to redirect_to(namespace_project_cluster_path(project.namespace, project, project.cluster))
+ expect(response).to redirect_to(project_cluster_path(project, project.cluster))
expect(flash[:notice]).to eq('Cluster was successfully updated.')
expect(cluster.enabled).to be_falsey
end
@@ -232,7 +232,7 @@ describe Projects::ClustersController do
end
end
- context 'User' do
+ context 'when cluster is provided by user' do
let(:cluster) { create(:cluster, :provided_by_user, projects: [project]) }
let(:user) { create(:user) }
@@ -317,7 +317,7 @@ describe Projects::ClustersController do
end
describe 'security' do
- set(:cluster) { create(:cluster, :providing_by_gcp, projects: [project]) }
+ set(:cluster) { create(:cluster, :provided_by_gcp, projects: [project]) }
let(:params) do
{ cluster: { enabled: false } }
@@ -335,8 +335,8 @@ describe Projects::ClustersController do
def go
put :update, params.merge(namespace_id: project.namespace,
- project_id: project,
- id: cluster)
+ project_id: project,
+ id: cluster)
end
def go_json
@@ -356,7 +356,7 @@ describe Projects::ClustersController do
sign_in(user)
end
- context 'GCP' do
+ context 'when cluster is provided by GCP' do
context 'when cluster is created' do
let!(:cluster) { create(:cluster, :provided_by_gcp, projects: [project]) }
@@ -366,7 +366,7 @@ describe Projects::ClustersController do
.and change { Clusters::Platforms::Kubernetes.count }.by(-1)
.and change { Clusters::Providers::Gcp.count }.by(-1)
- expect(response).to redirect_to(namespace_project_clusters_path(project.namespace, project))
+ expect(response).to redirect_to(project_clusters_path(project))
expect(flash[:notice]).to eq('Cluster integration was successfully removed.')
end
end
@@ -379,25 +379,23 @@ describe Projects::ClustersController do
.to change { Clusters::Cluster.count }.by(-1)
.and change { Clusters::Providers::Gcp.count }.by(-1)
- expect(response).to redirect_to(namespace_project_clusters_path(project.namespace, project))
+ expect(response).to redirect_to(project_clusters_path(project))
expect(flash[:notice]).to eq('Cluster integration was successfully removed.')
end
end
end
- context 'User' do
- context 'when provider is user' do
- let!(:cluster) { create(:cluster, :provided_by_user, projects: [project]) }
+ context 'when cluster is provided by user' do
+ let!(:cluster) { create(:cluster, :provided_by_user, projects: [project]) }
- it "destroys and redirects back to clusters list" do
- expect { go }
- .to change { Clusters::Cluster.count }.by(-1)
- .and change { Clusters::Platforms::Kubernetes.count }.by(-1)
- .and change { Clusters::Providers::Gcp.count }.by(0)
+ it "destroys and redirects back to clusters list" do
+ expect { go }
+ .to change { Clusters::Cluster.count }.by(-1)
+ .and change { Clusters::Platforms::Kubernetes.count }.by(-1)
+ .and change { Clusters::Providers::Gcp.count }.by(0)
- expect(response).to redirect_to(namespace_project_clusters_path(project.namespace, project))
- expect(flash[:notice]).to eq('Cluster integration was successfully removed.')
- end
+ expect(response).to redirect_to(project_clusters_path(project))
+ expect(flash[:notice]).to eq('Cluster integration was successfully removed.')
end
end
end
diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb
index e7ab714c550..e4b2bbb7c51 100644
--- a/spec/controllers/projects_controller_spec.rb
+++ b/spec/controllers/projects_controller_spec.rb
@@ -261,6 +261,27 @@ describe ProjectsController do
expect(response).to redirect_to(namespace_project_path)
end
end
+
+ context 'when the project is forked and has a repository', :request_store do
+ let(:public_project) { create(:project, :public, :repository) }
+ let(:other_user) { create(:user) }
+
+ render_views
+
+ before do
+ # View the project as a user that does not have any rights
+ sign_in(other_user)
+
+ fork_project(public_project)
+ end
+
+ it 'does not increase the number of queries when the project is forked' do
+ expected_query = /#{public_project.fork_network.find_forks_in(other_user.namespace).to_sql}/
+
+ expect { get(:show, namespace_id: public_project.namespace, id: public_project) }
+ .not_to exceed_query_limit(1).for_query(expected_query)
+ end
+ end
end
describe "#update" do