diff options
author | Jose Ivan Vargas <jvargas@gitlab.com> | 2017-10-06 17:15:44 -0500 |
---|---|---|
committer | Jose Ivan Vargas <jvargas@gitlab.com> | 2017-10-06 17:15:44 -0500 |
commit | 02838d5be2f899793ce5e026f0bb20c509697061 (patch) | |
tree | de3e125ca3f997bb94e079e2d2dbdc879d3dd7c6 /spec/controllers/dashboard/todos_controller_spec.rb | |
parent | 035bf5d4d5d3209286aa257cbd56ec6ce9e1afb9 (diff) | |
parent | 3cbab382f678cef273cde319aae55f050d27527d (diff) | |
download | gitlab-ce-02838d5be2f899793ce5e026f0bb20c509697061.tar.gz |
Merge branch 'master' into sh-headless-chrome-support
Diffstat (limited to 'spec/controllers/dashboard/todos_controller_spec.rb')
-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 |