File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2626%ul .questions
2727 = render :partial => " list" , :collection => collection, :as => :question
2828
29- = will_paginate
29+ = will_paginate(@questions, renderer: @support ? PrefixLinkRenderer.new('/support') : nil)
Original file line number Diff line number Diff line change 1+ Feature : Pagination for different types of questions
2+
3+ As a user of the site, I can view pages of different types of questions
4+
5+ Scenario : View support questions
6+ Given support questions exist
7+ When I visit the support questions page
8+ Then I should see a link to the next page of support questions
9+
10+ Scenario : View non-support questions
11+ Given questions exist
12+ When I visit the questions page
13+ Then I should see a link to the next page of questions
Original file line number Diff line number Diff line change @@ -76,3 +76,19 @@ def create_question_for(user)
7676 visit question_path ( @question )
7777 page . should_not have_content ( 'Delete' )
7878end
79+
80+ Given /^(\w *)\s ?questions exist$/ do |type |
81+ 30 . times do
82+ Question . create ( title : 'Test' , description : 'Test' ,
83+ support : type == 'support' ? true : false )
84+ end
85+ end
86+
87+ When /^I visit the (\w *)\s ?questions page$/ do |type |
88+ visit ( type == 'support' ? support_questions_path : questions_path )
89+ end
90+
91+ Then /^I should see a link to the next page of (\w *)\s ?questions$/ do |type |
92+ href = type == 'support' ? '/support/questions?page=2' : '/questions?page=2'
93+ page . should have_link '2' , href : href
94+ end
Original file line number Diff line number Diff line change 1+ class PrefixLinkRenderer < WillPaginate ::ActionView ::LinkRenderer
2+ def initialize ( prefix )
3+ @prefix = prefix
4+ super ( )
5+ end
6+
7+ protected
8+
9+ def url ( page )
10+ @prefix + super
11+ end
12+ end
You can’t perform that action at this time.
0 commit comments