@@ -27,6 +27,10 @@ module Rails
27
27
expect_template_result ( "{% paginate post.comments by 2 %}{{ paginate.current_offset }}{% endpaginate %}" , '0' , { 'post' => @post_drop } )
28
28
end
29
29
30
+ it '#current_page' do
31
+ expect_template_result ( "{% paginate post.comments by 2 %}{{ paginate.current_page }}{% endpaginate %}" , '1' , { 'post' => @post_drop } )
32
+ end
33
+
30
34
it '#page_size' do
31
35
expect_template_result ( "{% paginate post.comments by 2 %}{{ paginate.page_size }}{% endpaginate %}" , '2' , { 'post' => @post_drop } )
32
36
end
@@ -52,8 +56,26 @@ module Rails
52
56
end
53
57
end
54
58
59
+ context 'second_page' do
60
+ before ( :all ) { controller . params [ :page ] = 2 }
61
+ after ( :all ) { controller . params [ :page ] = nil }
62
+
63
+ it '#current_page' do
64
+ expect_template_result ( "{% paginate post.comments by 2 %}{{ paginate.current_page }}{% endpaginate %}" , '2' , { 'post' => @post_drop } )
65
+ end
66
+
67
+ it '#previous' do
68
+ expect_template_result ( "{% paginate post.comments by 2 %}{{ paginate.previous }}{% endpaginate %}" , %|{"title"=>"« Previous", "url"=>"/?page=1", "is_link"=>true}| , { 'post' => @post_drop } )
69
+ end
70
+
71
+ it '#next' do
72
+ expect_template_result ( "{% paginate post.comments by 2 %}{{ paginate.next }}{% endpaginate %}" , %|{"title"=>"Next »", "url"=>"/?page=3", "is_link"=>true}| , { 'post' => @post_drop } )
73
+ end
74
+ end
75
+
55
76
context 'last_page' do
56
77
before ( :all ) { controller . params [ :page ] = 3 }
78
+ after ( :all ) { controller . params [ :page ] = nil }
57
79
58
80
it 'returns the page size' do
59
81
expect_template_result ( "{% paginate post.comments by 2 %}{{ paginate.collection | size }}{% endpaginate %}" , '1' , { 'post' => @post_drop } )
@@ -67,6 +89,10 @@ module Rails
67
89
expect_template_result ( "{% paginate post.comments by 2 %}{{ paginate.current_offset }}{% endpaginate %}" , '4' , { 'post' => @post_drop } )
68
90
end
69
91
92
+ it '#current_page' do
93
+ expect_template_result ( "{% paginate post.comments by 2 %}{{ paginate.current_page }}{% endpaginate %}" , '3' , { 'post' => @post_drop } )
94
+ end
95
+
70
96
it '#page_size' do
71
97
expect_template_result ( "{% paginate post.comments by 2 %}{{ paginate.page_size }}{% endpaginate %}" , '2' , { 'post' => @post_drop } )
72
98
end
@@ -91,6 +117,44 @@ module Rails
91
117
expect_template_result ( "{% paginate post.comments by 2 %}{{ paginate.parts }}{% endpaginate %}" , %|{"title"=>1, "url"=>"/?page=1", "is_link"=>true}{"title"=>2, "url"=>"/?page=2", "is_link"=>true}{"title"=>3, "is_link"=>false, "hellip_break"=>false}| , { 'post' => @post_drop } )
92
118
end
93
119
end
120
+
121
+ context 'default_pagination' do
122
+ after ( :all ) { controller . params [ :page ] = nil }
123
+
124
+ it 'is in the first_page' do
125
+ controller . params [ :page ] = 1
126
+ expect_template_result ( "{% paginate post.comments by 2 %}{{ paginate | default_pagination }}{% endpaginate %}" , %|<span class=\" page current\" >1</span> <span class=\" page\" ><a href=\" /?page=2\" >2</a></span> <span class=\" page\" ><a href=\" /?page=3\" >3</a></span> <span class=\" next\" ><a href=\" /?page=2\" rel=\" next\" >Next »</a></span>| , { 'post' => @post_drop } )
127
+ end
128
+
129
+ it 'is in the second_page' do
130
+ controller . params [ :page ] = 2
131
+ expect_template_result ( "{% paginate post.comments by 2 %}{{ paginate | default_pagination }}{% endpaginate %}" , %|<span class=\" prev\" ><a href=\" /?page=1\" rel=\" prev\" >« Previous</a></span> <span class=\" page\" ><a href=\" /?page=1\" >1</a></span> <span class=\" page current\" >2</span> <span class=\" page\" ><a href=\" /?page=3\" >3</a></span> <span class=\" next\" ><a href=\" /?page=3\" rel=\" next\" >Next »</a></span>| , { 'post' => @post_drop } )
132
+ end
133
+
134
+ it 'is in the last_page' do
135
+ controller . params [ :page ] = 3
136
+ expect_template_result ( "{% paginate post.comments by 2 %}{{ paginate | default_pagination }}{% endpaginate %}" , %|<span class=\" prev\" ><a href=\" /?page=2\" rel=\" prev\" >« Previous</a></span> <span class=\" page\" ><a href=\" /?page=1\" >1</a></span> <span class=\" page\" ><a href=\" /?page=2\" >2</a></span> <span class=\" page current\" >3</span>| , { 'post' => @post_drop } )
137
+ end
138
+ end
139
+
140
+ context 'bootstrap_pagination' do
141
+ after ( :all ) { controller . params [ :page ] = nil }
142
+
143
+ it 'is in the first_page' do
144
+ controller . params [ :page ] = 1
145
+ expect_template_result ( "{% paginate post.comments by 2 %}{{ paginate | bootstrap_pagination }}{% endpaginate %}" , %|<nav><ul class="pagination "> <li class="disabled"><a href="#" aria-label="Previous"><span aria-hidden="true">« Previous</span></a></li> <li class="active"><a href="#">1</a></li> <li><a href="/?page=2">2</a></li> <li><a href="/?page=3">3</a></li> <li><a href="/?page=2" aria-label="Next"><span aria-hidden="true">Next »</span></a></li> </nav></ul>| , { 'post' => @post_drop } )
146
+ end
147
+
148
+ it 'is in the second_page' do
149
+ controller . params [ :page ] = 2
150
+ expect_template_result ( "{% paginate post.comments by 2 %}{{ paginate | bootstrap_pagination }}{% endpaginate %}" , %|<nav><ul class="pagination "> <li><a href="/?page=1" aria-label="Previous"><span aria-hidden="true">« Previous</span></a></li> <li><a href="/?page=1">1</a></li> <li class="active"><a href="#">2</a></li> <li><a href="/?page=3">3</a></li> <li><a href="/?page=3" aria-label="Next"><span aria-hidden="true">Next »</span></a></li> </nav></ul>| , { 'post' => @post_drop } )
151
+ end
152
+
153
+ it 'is in the last_page' do
154
+ controller . params [ :page ] = 3
155
+ expect_template_result ( "{% paginate post.comments by 2 %}{{ paginate | bootstrap_pagination }}{% endpaginate %}" , %|<nav><ul class="pagination "> <li><a href="/?page=2" aria-label="Previous"><span aria-hidden="true">« Previous</span></a></li> <li><a href="/?page=1">1</a></li> <li><a href="/?page=2">2</a></li> <li class="active"><a href="#">3</a></li> <li class="disabled"><a href="#" aria-label="Next"><span aria-hidden="true">Next »</span></a></li> </nav></ul>| , { 'post' => @post_drop } )
156
+ end
157
+ end
94
158
end
95
159
end
96
160
end
0 commit comments