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

Add specs for cluster counters

parent aec7bbf1
......@@ -14,15 +14,26 @@ describe Projects::ClustersController do
end
context 'when project has one or more clusters' do
let(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:project) { cluster.project }
let(:project) { create(:project) }
let(:clusters) { create_list(:cluster, 2, :provided_by_gcp, projects: [project]) }
before do
clusters.last.enabled = false
end
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])
expect(assigns(:clusters)).to eq(clusters)
end
it 'assigns counters to correct values' do
go
expect(assigns(:active_count)).to eq(project.clusters.enabled.count)
expect(assigns(:inactive_count)).to eq(project.clusters.disabled.count)
end
end
......@@ -36,6 +47,13 @@ describe Projects::ClustersController do
expect(response).to render_template(:index)
expect(assigns(:clusters)).to eq([])
end
it 'assigns counters to zero' do
go
expect(assigns(:active_count)).to eq(0)
expect(assigns(:inactive_count)).to eq(0)
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