Commit b7f35360 authored by Matija Čupić's avatar Matija Čupić

Add specs JSON PUT #delete for ClustersController

parent 5fb8b2f7
...@@ -384,31 +384,61 @@ describe Projects::ClustersController do ...@@ -384,31 +384,61 @@ describe Projects::ClustersController do
sign_in(user) sign_in(user)
end end
context 'when update enabled' do context 'when format is json' do
let(:params) do context 'when update enabled' do
{ let(:params) do
cluster: { enabled: false } {
} cluster: { enabled: false }
end }
end
it "updates and redirects back to show page" do it "updates and redirects back to show page" do
go go_json
cluster.reload
expect(response).to have_http_status(:no_content)
end
context 'when cluster is being created' do
let(:cluster) { create(:cluster, :project, :providing_by_gcp) }
it "rejects changes" do
go_json
cluster.reload # head bad_request
expect(response).to redirect_to(project_cluster_path(project, project.cluster)) expect(response).to have_http_status(:bad_request)
expect(flash[:notice]).to eq('Cluster was successfully updated.') end
expect(cluster.enabled).to be_falsey end
end end
end
context 'when cluster is being created' do context 'when format is html' do
let(:cluster) { create(:cluster, :project, :providing_by_gcp) } context 'when update enabled' do
let(:params) do
{
cluster: { enabled: false }
}
end
it "rejects changes" do it "updates and redirects back to show page" do
go go
expect(response).to have_gitlab_http_status(:ok) cluster.reload
expect(response).to render_template(:show) expect(response).to redirect_to(project_cluster_path(project, project.cluster))
expect(cluster.enabled).to be_truthy expect(flash[:notice]).to eq('Cluster was successfully updated.')
expect(cluster.enabled).to be_falsey
end
context 'when cluster is being created' do
let(:cluster) { create(:cluster, :project, :providing_by_gcp) }
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 end
...@@ -436,6 +466,13 @@ describe Projects::ClustersController do ...@@ -436,6 +466,13 @@ describe Projects::ClustersController do
project_id: project, project_id: project,
id: cluster) id: cluster)
end end
def go_json
put :update, params.merge(namespace_id: project.namespace,
project_id: project,
id: cluster,
format: :json)
end
end end
describe 'delete update' do describe 'delete update' do
......
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