Check cluster listing logic instead of redirects

This commit is contained in:
Matija Čupić 2017-11-16 01:06:49 +01:00
parent b0a8840369
commit 98653ba6fa
No known key found for this signature in database
GPG Key ID: 4BAF84FFACD2E5DE
1 changed files with 15 additions and 3 deletions

View File

@ -13,17 +13,29 @@ describe Projects::ClustersController do
sign_in(user)
end
context 'when project has a cluster' do
context 'when project has one or more clusters' do
let(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:project) { cluster.project }
it { expect(go).to redirect_to(project_cluster_path(project, project.cluster)) }
it 'lists available clusters' do
go
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template(:index)
expect(assigns(:clusters)).to eq([cluster])
end
end
context 'when project does not have a cluster' do
let(:project) { create(:project) }
it { expect(go).to redirect_to(new_project_cluster_path(project)) }
it 'returns an empty state page' do
go
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template(:index)
expect(assigns(:clusters)).to eq([])
end
end
end