BigW Consortium Gitlab

Add specs for cluster counters

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