Commit 4d75901c authored by Matija Čupić's avatar Matija Čupić

Use ClustersFinder for setting counts

parent f81503a0
......@@ -9,10 +9,9 @@ class Projects::ClustersController < Projects::ApplicationController
def index
@scope = params[:scope] || 'all'
clusters = ClustersFinder.new(project, current_user, @scope).execute
@clusters = clusters.page(params[:page])
@active_count = project.clusters.enabled.count
@inactive_count = project.clusters.disabled.count
@clusters = ClustersFinder.new(project, current_user, @scope).execute.page(params[:page])
@active_count = ClustersFinder.new(project, current_user, :active).execute.count
@inactive_count = ClustersFinder.new(project, current_user, :inactive).execute.count
@all_count = @active_count + @inactive_count
end
......
......@@ -17,9 +17,8 @@ describe Projects::ClustersController do
context 'when project has one or more clusters' do
let(:project) { create(:project) }
let(:enabled_cluster) { create(:cluster, :provided_by_gcp, projects: [project]) }
let(:disabled_cluster) { create(:cluster, :disabled, :provided_by_gcp, projects: [project]) }
let!(:enabled_cluster) { create(:cluster, :provided_by_gcp, projects: [project]) }
let!(:disabled_cluster) { create(:cluster, :disabled, :provided_by_gcp, projects: [project]) }
it 'lists available clusters' do
go
......@@ -31,8 +30,8 @@ describe Projects::ClustersController do
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)
expect(assigns(:active_count)).to eq(1)
expect(assigns(:inactive_count)).to eq(1)
end
context 'when page is specified' 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