views: factor out paginator component.
* Refactor the paginator into a ViewComponent.
* Fix inconsistent spacing between paginator items.
* Fix a bug where the sequential paginator generated the wrong next /
previous page links in the <link rel="{next|prev}"> tags in the <head>.
* Always include the final page as a hidden html element, so that it can
be unhidden with custom CSS.
* Make it easier to change the pagination window.
This commit is contained in:
@@ -22,32 +22,32 @@ class PostsControllerTest < ActionDispatch::IntegrationTest
|
||||
get posts_path(page: "a0")
|
||||
assert_response :success
|
||||
assert_select ".post-preview", count: 3
|
||||
assert_select "#paginator-prev", count: 0
|
||||
assert_select "#paginator-next", count: 1
|
||||
assert_select "a.paginator-prev", count: 0
|
||||
assert_select "a.paginator-next", count: 1
|
||||
end
|
||||
|
||||
should "work with page=b0" do
|
||||
get posts_path(page: "b0")
|
||||
assert_response :success
|
||||
assert_select ".post-preview", count: 0
|
||||
assert_select "#paginator-prev", count: 0
|
||||
assert_select "#paginator-next", count: 0
|
||||
assert_select "a.paginator-prev", count: 0
|
||||
assert_select "a.paginator-next", count: 0
|
||||
end
|
||||
|
||||
should "work with page=b100000" do
|
||||
get posts_path(page: "b100000")
|
||||
assert_response :success
|
||||
assert_select ".post-preview", count: 3
|
||||
assert_select "#paginator-prev", count: 1
|
||||
assert_select "#paginator-next", count: 0
|
||||
assert_select "a.paginator-prev", count: 1
|
||||
assert_select "a.paginator-next", count: 0
|
||||
end
|
||||
|
||||
should "work with page=a100000" do
|
||||
get posts_path(page: "a100000")
|
||||
assert_response :success
|
||||
assert_select ".post-preview", count: 0
|
||||
assert_select "#paginator-prev", count: 0
|
||||
assert_select "#paginator-next", count: 0
|
||||
assert_select "a.paginator-prev", count: 0
|
||||
assert_select "a.paginator-next", count: 0
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user