@@ -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
@@ -54,6 +58,11 @@ module Rails
54
58
55
59
context 'second_page' do
56
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
57
66
58
67
it '#previous' do
59
68
expect_template_result ( "{% paginate post.comments by 2 %}{{ paginate.previous }}{% endpaginate %}" , %|{"title"=>"« Previous", "url"=>"/?page=1", "is_link"=>true}| , { 'post' => @post_drop } )
@@ -66,6 +75,7 @@ module Rails
66
75
67
76
context 'last_page' do
68
77
before ( :all ) { controller . params [ :page ] = 3 }
78
+ after ( :all ) { controller . params [ :page ] = nil }
69
79
70
80
it 'returns the page size' do
71
81
expect_template_result ( "{% paginate post.comments by 2 %}{{ paginate.collection | size }}{% endpaginate %}" , '1' , { 'post' => @post_drop } )
@@ -79,6 +89,10 @@ module Rails
79
89
expect_template_result ( "{% paginate post.comments by 2 %}{{ paginate.current_offset }}{% endpaginate %}" , '4' , { 'post' => @post_drop } )
80
90
end
81
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
+
82
96
it '#page_size' do
83
97
expect_template_result ( "{% paginate post.comments by 2 %}{{ paginate.page_size }}{% endpaginate %}" , '2' , { 'post' => @post_drop } )
84
98
end
@@ -103,6 +117,44 @@ module Rails
103
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 } )
104
118
end
105
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
106
158
end
107
159
end
108
160
end
0 commit comments