Use ClustersFinder for setting counts
This commit is contained in:
parent
f81503a061
commit
4d75901c02
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue