diff options
author | Tiago Botelho <tiagonbotelho@hotmail.com> | 2016-12-20 21:52:09 +0300 |
---|---|---|
committer | Tiago Botelho <tiagonbotelho@hotmail.com> | 2016-12-22 02:53:24 +0300 |
commit | 805bbe889328bff55b49290294721405148cc980 (patch) | |
tree | 0beb7c9621db87d5f11928ca8231af8b1de21a6c /spec/controllers/dashboard | |
parent | 9b66aa6e04ab66af7ce11e26076ebf431ca938c5 (diff) |
adds specs for respective behaviour
Diffstat (limited to 'spec/controllers/dashboard')
-rw-r--r-- | spec/controllers/dashboard/todos_controller_spec.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/controllers/dashboard/todos_controller_spec.rb b/spec/controllers/dashboard/todos_controller_spec.rb new file mode 100644 index 00000000000..a8c08a6e87b --- /dev/null +++ b/spec/controllers/dashboard/todos_controller_spec.rb @@ -0,0 +1,36 @@ +require 'spec_helper' + +describe Dashboard::TodosController do + let(:user) { create(:user) } + let(:project) { create(:project) } + let(:todo_service) { TodoService.new } + + describe 'GET #index' do + before do + sign_in(user) + project.team << [user, :developer] + end + + context 'when using pagination' do + let(:last_page) { user.todos.page().total_pages } + let!(:issues) { create_list(:issue, 30, project: project, assignee: user) } + + before do + issues.each { |issue| todo_service.new_issue(issue, user) } + end + + it 'redirects to last_page if page number is larger than number of pages' do + get :index, page: (last_page + 1).to_param + + expect(response).to redirect_to(dashboard_todos_path(page: last_page)) + end + + it 'redirects to correspondent page' do + get :index, page: last_page + + expect(assigns(:todos).current_page).to eq(last_page) + expect(response).to have_http_status(200) + end + end + end +end |