Commit 42d87f90 authored by Matija Čupić's avatar Matija Čupić

Refactor pagination check into separate context

parent ea164796
...@@ -36,15 +36,22 @@ describe Projects::ClustersController do ...@@ -36,15 +36,22 @@ describe Projects::ClustersController do
expect(assigns(:inactive_count)).to eq(project.clusters.disabled.count) expect(assigns(:inactive_count)).to eq(project.clusters.disabled.count)
end end
it 'properly paginates' do context 'properly paginates' do
before do
PAGE_LIMIT = 20 PAGE_LIMIT = 20
project.clusters = create_list(:cluster, PAGE_LIMIT + 1, :provided_by_gcp, projects: [project]) project.clusters = create_list(:cluster, PAGE_LIMIT + 1, :provided_by_gcp, projects: [project])
end
it 'shows the first page' do
go go
expect(assigns(:clusters).count).to eq(PAGE_LIMIT)
end
expect(assigns(:clusters).count).to eq(20) it 'shows the second page' do
get :index, namespace_id: project.namespace, project_id: project, page: 2 get :index, namespace_id: project.namespace, project_id: project, page: 2
expect(assigns(:clusters).count).to eq(1) expect(assigns(:clusters).count).to eq(1)
end end
end
context 'when only enabled clusters are requested' do context 'when only enabled clusters are requested' do
it 'returns only enabled clusters' do it 'returns only enabled clusters' 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