Commit 445a4109 authored by Shinya Maeda's avatar Shinya Maeda

Clean up clusters_controller_spec.rb

parent a5109c69
...@@ -120,7 +120,7 @@ describe Projects::ClustersController do ...@@ -120,7 +120,7 @@ describe Projects::ClustersController do
end end
describe 'PUT update' do 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(:cluster) { create(:cluster, :provided_by_gcp, projects: [project]) }
let(:user) { create(:user) } let(:user) { create(:user) }
...@@ -171,7 +171,7 @@ describe Projects::ClustersController do ...@@ -171,7 +171,7 @@ describe Projects::ClustersController do
end end
end end
context 'User' do context 'when cluster is provided by user' do
let(:cluster) { create(:cluster, :provided_by_user, projects: [project]) } let(:cluster) { create(:cluster, :provided_by_user, projects: [project]) }
let(:user) { create(:user) } let(:user) { create(:user) }
...@@ -203,23 +203,11 @@ describe Projects::ClustersController do ...@@ -203,23 +203,11 @@ describe Projects::ClustersController do
expect(cluster.name).to eq('my-new-cluster-name') expect(cluster.name).to eq('my-new-cluster-name')
expect(cluster.platform_kubernetes.namespace).to eq('my-namespace') expect(cluster.platform_kubernetes.namespace).to eq('my-namespace')
end end
context 'when cluster is being created' do
let(:cluster) { create(:cluster, :providing_by_gcp, projects: [project]) }
it "rejects changes" do
go
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template(:show)
expect(cluster.enabled).to be_truthy
end
end
end end
end end
describe 'security' do describe 'security' do
set(:cluster) { create(:cluster, :providing_by_gcp, projects: [project]) } set(:cluster) { create(:cluster, :provided_by_gcp, projects: [project]) }
let(:params) do let(:params) do
{ cluster: { enabled: false } } { cluster: { enabled: false } }
...@@ -251,7 +239,7 @@ describe Projects::ClustersController do ...@@ -251,7 +239,7 @@ describe Projects::ClustersController do
sign_in(user) sign_in(user)
end end
context 'GCP' do context 'when cluster is provided by GCP' do
context 'when cluster is created' do context 'when cluster is created' do
let!(:cluster) { create(:cluster, :provided_by_gcp, projects: [project]) } let!(:cluster) { create(:cluster, :provided_by_gcp, projects: [project]) }
...@@ -280,19 +268,17 @@ describe Projects::ClustersController do ...@@ -280,19 +268,17 @@ describe Projects::ClustersController do
end end
end end
context 'User' do context 'when cluster is provided by user' do
context 'when provider is user' do let!(:cluster) { create(:cluster, :provided_by_user, projects: [project]) }
let!(:cluster) { create(:cluster, :provided_by_user, projects: [project]) }
it "destroys and redirects back to clusters list" do it "destroys and redirects back to clusters list" do
expect { go } expect { go }
.to change { Clusters::Cluster.count }.by(-1) .to change { Clusters::Cluster.count }.by(-1)
.and change { Clusters::Platforms::Kubernetes.count }.by(-1) .and change { Clusters::Platforms::Kubernetes.count }.by(-1)
.and change { Clusters::Providers::Gcp.count }.by(0) .and change { Clusters::Providers::Gcp.count }.by(0)
expect(response).to redirect_to(project_clusters_path(project)) expect(response).to redirect_to(project_clusters_path(project))
expect(flash[:notice]).to eq('Cluster integration was successfully removed.') expect(flash[:notice]).to eq('Cluster integration was successfully removed.')
end
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment