diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-10-10 17:53:42 +0200 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-10-10 17:53:42 +0200 |
commit | 741fb49378abbf66fbd8d6ad27b94f1040bf3123 (patch) | |
tree | 6bc2393e7fd3d8733e0ef8a19c98bd16d2b4fdbd /spec/controllers/dashboard | |
parent | e678f312923faf9a702e19894175d4cb14f66b5b (diff) | |
parent | 9ac5338b8eb361927ad068486398b92acb0c287e (diff) | |
download | gitlab-ce-741fb49378abbf66fbd8d6ad27b94f1040bf3123.tar.gz |
Merge branch 'master' into bvl-group-trees
Diffstat (limited to 'spec/controllers/dashboard')
-rw-r--r-- | spec/controllers/dashboard/todos_controller_spec.rb | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/spec/controllers/dashboard/todos_controller_spec.rb b/spec/controllers/dashboard/todos_controller_spec.rb index c8c6b9f41bf..9df4ebf2fa0 100644 --- a/spec/controllers/dashboard/todos_controller_spec.rb +++ b/spec/controllers/dashboard/todos_controller_spec.rb @@ -57,7 +57,7 @@ describe Dashboard::TodosController do expect(response).to redirect_to(dashboard_todos_path(page: last_page)) end - it 'redirects to correspondent page' do + it 'goes to the correct page' do get :index, page: last_page expect(assigns(:todos).current_page).to eq(last_page) @@ -70,6 +70,30 @@ describe Dashboard::TodosController do expect(response).to redirect_to(dashboard_todos_path(page: last_page)) end + + context 'when providing no filters' do + it 'does not perform a query to get the page count, but gets that from the user' do + allow(controller).to receive(:current_user).and_return(user) + + expect(user).to receive(:todos_pending_count).and_call_original + + get :index, page: (last_page + 1).to_param, sort: :created_asc + + expect(response).to redirect_to(dashboard_todos_path(page: last_page, sort: :created_asc)) + end + end + + context 'when providing filters' do + it 'performs a query to get the correct page count' do + allow(controller).to receive(:current_user).and_return(user) + + expect(user).not_to receive(:todos_pending_count) + + get :index, page: (last_page + 1).to_param, project_id: project.id + + expect(response).to redirect_to(dashboard_todos_path(page: last_page, project_id: project.id)) + end + end end end |