kaminari-rails4 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +7 -0
  2. data/.document +5 -0
  3. data/.gemtest +0 -0
  4. data/.gitignore +9 -0
  5. data/.rspec +2 -0
  6. data/.travis.yml +16 -0
  7. data/CHANGELOG +351 -0
  8. data/Gemfile +4 -0
  9. data/MIT-LICENSE +20 -0
  10. data/README.rdoc +300 -0
  11. data/Rakefile +42 -0
  12. data/app/helpers/kaminari_helper.rb +5 -0
  13. data/app/views/kaminari/_first_page.html.erb +11 -0
  14. data/app/views/kaminari/_first_page.html.haml +9 -0
  15. data/app/views/kaminari/_first_page.html.slim +10 -0
  16. data/app/views/kaminari/_gap.html.erb +8 -0
  17. data/app/views/kaminari/_gap.html.haml +8 -0
  18. data/app/views/kaminari/_gap.html.slim +9 -0
  19. data/app/views/kaminari/_last_page.html.erb +11 -0
  20. data/app/views/kaminari/_last_page.html.haml +9 -0
  21. data/app/views/kaminari/_last_page.html.slim +10 -0
  22. data/app/views/kaminari/_next_page.html.erb +11 -0
  23. data/app/views/kaminari/_next_page.html.haml +9 -0
  24. data/app/views/kaminari/_next_page.html.slim +10 -0
  25. data/app/views/kaminari/_page.html.erb +12 -0
  26. data/app/views/kaminari/_page.html.haml +10 -0
  27. data/app/views/kaminari/_page.html.slim +11 -0
  28. data/app/views/kaminari/_paginator.html.erb +23 -0
  29. data/app/views/kaminari/_paginator.html.haml +18 -0
  30. data/app/views/kaminari/_paginator.html.slim +19 -0
  31. data/app/views/kaminari/_prev_page.html.erb +11 -0
  32. data/app/views/kaminari/_prev_page.html.haml +9 -0
  33. data/app/views/kaminari/_prev_page.html.slim +10 -0
  34. data/config/locales/kaminari.yml +19 -0
  35. data/gemfiles/active_record_30.gemfile +7 -0
  36. data/gemfiles/active_record_31.gemfile +7 -0
  37. data/gemfiles/active_record_32.gemfile +10 -0
  38. data/gemfiles/active_record_40.gemfile +8 -0
  39. data/gemfiles/data_mapper_12.gemfile +15 -0
  40. data/gemfiles/mongo_mapper.gemfile +10 -0
  41. data/gemfiles/mongoid_24.gemfile +7 -0
  42. data/gemfiles/mongoid_30.gemfile +12 -0
  43. data/gemfiles/sinatra.gemfile +13 -0
  44. data/kaminari.gemspec +36 -0
  45. data/lib/generators/kaminari/config_generator.rb +16 -0
  46. data/lib/generators/kaminari/templates/kaminari_config.rb +10 -0
  47. data/lib/generators/kaminari/views_generator.rb +118 -0
  48. data/lib/kaminari.rb +38 -0
  49. data/lib/kaminari/config.rb +51 -0
  50. data/lib/kaminari/engine.rb +4 -0
  51. data/lib/kaminari/grape.rb +4 -0
  52. data/lib/kaminari/helpers/action_view_extension.rb +151 -0
  53. data/lib/kaminari/helpers/paginator.rb +186 -0
  54. data/lib/kaminari/helpers/sinatra_helpers.rb +144 -0
  55. data/lib/kaminari/helpers/tags.rb +95 -0
  56. data/lib/kaminari/hooks.rb +33 -0
  57. data/lib/kaminari/models/active_record_extension.rb +22 -0
  58. data/lib/kaminari/models/active_record_model_extension.rb +20 -0
  59. data/lib/kaminari/models/active_record_relation_methods.rb +29 -0
  60. data/lib/kaminari/models/array_extension.rb +58 -0
  61. data/lib/kaminari/models/configuration_methods.rb +48 -0
  62. data/lib/kaminari/models/data_mapper_collection_methods.rb +15 -0
  63. data/lib/kaminari/models/data_mapper_extension.rb +48 -0
  64. data/lib/kaminari/models/mongo_mapper_extension.rb +18 -0
  65. data/lib/kaminari/models/mongoid_criteria_methods.rb +23 -0
  66. data/lib/kaminari/models/mongoid_extension.rb +33 -0
  67. data/lib/kaminari/models/page_scope_methods.rb +70 -0
  68. data/lib/kaminari/models/plucky_criteria_methods.rb +18 -0
  69. data/lib/kaminari/railtie.rb +7 -0
  70. data/lib/kaminari/sinatra.rb +5 -0
  71. data/lib/kaminari/version.rb +3 -0
  72. data/spec/config/config_spec.rb +91 -0
  73. data/spec/fake_app/active_record/config.rb +3 -0
  74. data/spec/fake_app/active_record/models.rb +57 -0
  75. data/spec/fake_app/data_mapper/config.rb +1 -0
  76. data/spec/fake_app/data_mapper/models.rb +27 -0
  77. data/spec/fake_app/mongo_mapper/config.rb +2 -0
  78. data/spec/fake_app/mongo_mapper/models.rb +9 -0
  79. data/spec/fake_app/mongoid/config.rb +16 -0
  80. data/spec/fake_app/mongoid/models.rb +22 -0
  81. data/spec/fake_app/rails_app.rb +56 -0
  82. data/spec/fake_app/sinatra_app.rb +22 -0
  83. data/spec/fake_gem.rb +4 -0
  84. data/spec/helpers/action_view_extension_spec.rb +262 -0
  85. data/spec/helpers/helpers_spec.rb +135 -0
  86. data/spec/helpers/sinatra_helpers_spec.rb +170 -0
  87. data/spec/helpers/tags_spec.rb +140 -0
  88. data/spec/models/active_record/active_record_relation_methods_spec.rb +47 -0
  89. data/spec/models/active_record/default_per_page_spec.rb +32 -0
  90. data/spec/models/active_record/max_pages_spec.rb +23 -0
  91. data/spec/models/active_record/max_per_page_spec.rb +32 -0
  92. data/spec/models/active_record/scopes_spec.rb +242 -0
  93. data/spec/models/array_spec.rb +150 -0
  94. data/spec/models/data_mapper/data_mapper_spec.rb +179 -0
  95. data/spec/models/mongo_mapper/mongo_mapper_spec.rb +84 -0
  96. data/spec/models/mongoid/mongoid_spec.rb +126 -0
  97. data/spec/requests/users_spec.rb +53 -0
  98. data/spec/spec_helper.rb +33 -0
  99. data/spec/spec_helper_for_sinatra.rb +33 -0
  100. data/spec/support/database_cleaner.rb +16 -0
  101. data/spec/support/matchers.rb +52 -0
  102. metadata +300 -0
@@ -0,0 +1,16 @@
1
+ # Ensure we use 'syck' instead of 'psych' in 1.9.2
2
+ # RubyGems >= 1.5.0 uses 'psych' on 1.9.2, but
3
+ # Psych does not yet support YAML 1.1 merge keys.
4
+ # Merge keys is often used in mongoid.yml
5
+ # See: http://redmine.ruby-lang.org/issues/show/4300
6
+ if RUBY_VERSION >= '1.9.2'
7
+ YAML::ENGINE.yamler = 'syck'
8
+ end
9
+
10
+ Mongoid.configure do |config|
11
+ if Mongoid::VERSION =~ /^3/
12
+ config.sessions = {:default => {:hosts => ['localhost:27017'], :database => 'kaminari_test'}}
13
+ else
14
+ config.master = Mongo::Connection.new.db('kaminari_test')
15
+ end
16
+ end
@@ -0,0 +1,22 @@
1
+ class User
2
+ include ::Mongoid::Document
3
+ field :name, :type => String
4
+ field :age, :type => Integer
5
+ end
6
+
7
+ class User::Address
8
+ include ::Mongoid::Document
9
+ end
10
+
11
+ class MongoMongoidExtensionDeveloper
12
+ include ::Mongoid::Document
13
+ field :salary, :type => Integer
14
+ embeds_many :frameworks
15
+ end
16
+
17
+ class Framework
18
+ include ::Mongoid::Document
19
+ field :name, :type => String
20
+ field :language, :type => String
21
+ embedded_in :mongo_mongoid_extension_developer
22
+ end
@@ -0,0 +1,56 @@
1
+ # require 'rails/all'
2
+ require 'action_controller/railtie'
3
+ require 'action_view/railtie'
4
+
5
+ require 'fake_app/active_record/config' if defined? ActiveRecord
6
+ require 'fake_app/data_mapper/config' if defined? DataMapper
7
+ require 'fake_app/mongoid/config' if defined? Mongoid
8
+ require 'fake_app/mongo_mapper/config' if defined? MongoMapper
9
+ # config
10
+ app = Class.new(Rails::Application)
11
+ app.config.secret_token = '3b7cd727ee24e8444053437c36cc66c4'
12
+ app.config.session_store :cookie_store, :key => '_myapp_session'
13
+ app.config.active_support.deprecation = :log
14
+ app.config.eager_load = false
15
+ # Rais.root
16
+ app.config.root = File.dirname(__FILE__)
17
+ Rails.backtrace_cleaner.remove_silencers!
18
+ app.initialize!
19
+
20
+ # routes
21
+ app.routes.draw do
22
+ resources :users
23
+ end
24
+
25
+ #models
26
+ require 'fake_app/active_record/models' if defined? ActiveRecord
27
+ require 'fake_app/data_mapper/models' if defined? DataMapper
28
+ require 'fake_app/mongoid/models' if defined? Mongoid
29
+ require 'fake_app/mongo_mapper/models' if defined? MongoMapper
30
+
31
+ # controllers
32
+ class ApplicationController < ActionController::Base; end
33
+ class UsersController < ApplicationController
34
+ def index
35
+ @users = User.page params[:page]
36
+ render :inline => <<-ERB
37
+ <%= @users.map(&:name).join("\n") %>
38
+ <%= paginate @users %>
39
+ ERB
40
+ end
41
+ end
42
+
43
+ if defined? ActiveRecord
44
+ class AddressesController < ApplicationController
45
+ def index
46
+ @addresses = User::Address.page params[:page]
47
+ render :inline => <<-ERB
48
+ <%= @addresses.map(&:street).join("\n") %>
49
+ <%= paginate @addresses %>
50
+ ERB
51
+ end
52
+ end
53
+ end
54
+
55
+ # helpers
56
+ Object.const_set(:ApplicationHelper, Module.new)
@@ -0,0 +1,22 @@
1
+ require 'fake_app/active_record/config' if defined? ActiveRecord
2
+ require 'fake_app/data_mapper/config' if defined? DataMapper
3
+ require 'fake_app/mongoid/config' if defined? Mongoid
4
+ require 'fake_app/mongo_mapper/config' if defined? MongoMapper
5
+
6
+ #models
7
+ require 'fake_app/active_record/models' if defined? ActiveRecord
8
+ require 'fake_app/data_mapper/models' if defined? DataMapper
9
+ require 'fake_app/mongoid/models' if defined? Mongoid
10
+ require 'fake_app/mongo_mapper/models' if defined? MongoMapper
11
+
12
+ class SinatraApp < Sinatra::Base
13
+ register Kaminari::Helpers::SinatraHelpers
14
+
15
+ get '/users' do
16
+ @users = User.page params[:page]
17
+ erb <<-ERB
18
+ <%= @users.map(&:name).join("\n") %>
19
+ <%= paginate @users %>
20
+ ERB
21
+ end
22
+ end
@@ -0,0 +1,4 @@
1
+ # Simulate a gem providing a subclass of ActiveRecord::Base before the Railtie is loaded.
2
+
3
+ class GemDefinedModel < ActiveRecord::Base
4
+ end
@@ -0,0 +1,262 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Kaminari::ActionViewExtension' do
4
+ describe '#paginate' do
5
+ before do
6
+ 50.times {|i| User.create! :name => "user#{i}"}
7
+ @users = User.page(1)
8
+ end
9
+ subject { helper.paginate @users, :params => {:controller => 'users', :action => 'index'} }
10
+ it { should be_a String }
11
+
12
+ context 'escaping the pagination for javascript' do
13
+ it 'should escape for javascript' do
14
+ lambda { helper.escape_javascript(helper.paginate @users, :params => {:controller => 'users', :action => 'index'}) }.should_not raise_error
15
+ end
16
+ end
17
+ end
18
+
19
+ describe '#link_to_previous_page' do
20
+ before do
21
+ 50.times {|i| User.create! :name => "user#{i}"}
22
+ end
23
+ context 'having previous pages' do
24
+ before do
25
+ @users = User.page(50)
26
+ end
27
+ context 'the default behaviour' do
28
+ subject { helper.link_to_previous_page @users, 'Previous', :params => {:controller => 'users', :action => 'index'} }
29
+ it { should be_a String }
30
+ it { should match(/rel="previous"/) }
31
+ end
32
+ context 'overriding rel=' do
33
+ subject { helper.link_to_previous_page @users, 'Previous', :rel => 'external', :params => {:controller => 'users', :action => 'index'} }
34
+ it { should match(/rel="external"/) }
35
+ end
36
+ end
37
+ context 'the first page' do
38
+ before do
39
+ @users = User.page(1)
40
+ end
41
+ subject { helper.link_to_previous_page @users, 'Previous', :params => {:controller => 'users', :action => 'index'} }
42
+ it { should_not be }
43
+ end
44
+ end
45
+
46
+ describe '#link_to_next_page' do
47
+ before do
48
+ 50.times {|i| User.create! :name => "user#{i}"}
49
+ end
50
+ context 'having more page' do
51
+ before do
52
+ @users = User.page(1)
53
+ end
54
+ context 'the default behaviour' do
55
+ subject { helper.link_to_next_page @users, 'More', :params => {:controller => 'users', :action => 'index'} }
56
+ it { should be_a String }
57
+ it { should match(/rel="next"/) }
58
+ end
59
+ context 'overriding rel=' do
60
+ subject { helper.link_to_next_page @users, 'More', :rel => 'external', :params => {:controller => 'users', :action => 'index'} }
61
+ it { should match(/rel="external"/) }
62
+ end
63
+ end
64
+ context 'the last page' do
65
+ before do
66
+ @users = User.page(2)
67
+ end
68
+ subject { helper.link_to_next_page @users, 'More', :params => {:controller => 'users', :action => 'index'} }
69
+ it { should_not be }
70
+ end
71
+ end
72
+
73
+ describe '#page_entries_info' do
74
+ context 'on a model without namespace' do
75
+ before do
76
+ @users = User.page(1).per(25)
77
+ end
78
+ context 'having no entries' do
79
+ subject { helper.page_entries_info @users, :params => {:controller => 'users', :action => 'index'} }
80
+ it { should == 'No entries found' }
81
+
82
+ context 'setting the entry name option to "member"' do
83
+ subject { helper.page_entries_info @users, :entry_name => 'member', :params => {:controller => 'users', :action => 'index'} }
84
+ it { should == 'No members found' }
85
+ end
86
+ end
87
+
88
+ context 'having 1 entry' do
89
+ before do
90
+ User.create! :name => 'user1'
91
+ @users = User.page(1).per(25)
92
+ end
93
+ subject { helper.page_entries_info @users, :params => {:controller => 'users', :action => 'index'} }
94
+ it { should == 'Displaying <b>1</b> user' }
95
+
96
+ context 'setting the entry name option to "member"' do
97
+ subject { helper.page_entries_info @users, :entry_name => 'member', :params => {:controller => 'users', :action => 'index'} }
98
+ it { should == 'Displaying <b>1</b> member' }
99
+ end
100
+ end
101
+
102
+ context 'having more than 1 but less than a page of entries' do
103
+ before do
104
+ 10.times {|i| User.create! :name => "user#{i}"}
105
+ @users = User.page(1).per(25)
106
+ end
107
+ subject { helper.page_entries_info @users, :params => {:controller => 'users', :action => 'index'} }
108
+ it { should == 'Displaying <b>all 10</b> users' }
109
+
110
+ context 'setting the entry name option to "member"' do
111
+ subject { helper.page_entries_info @users, :entry_name => 'member', :params => {:controller => 'users', :action => 'index'} }
112
+ it { should == 'Displaying <b>all 10</b> members' }
113
+ end
114
+ end
115
+
116
+ context 'having more than one page of entries' do
117
+ before do
118
+ 50.times {|i| User.create! :name => "user#{i}"}
119
+ end
120
+
121
+ describe 'the first page' do
122
+ before do
123
+ @users = User.page(1).per(25)
124
+ end
125
+ subject { helper.page_entries_info @users, :params => {:controller => 'users', :action => 'index'} }
126
+ it { should == 'Displaying users <b>1&nbsp;-&nbsp;25</b> of <b>50</b> in total' }
127
+
128
+ context 'setting the entry name option to "member"' do
129
+ subject { helper.page_entries_info @users, :entry_name => 'member', :params => {:controller => 'users', :action => 'index'} }
130
+ it { should == 'Displaying members <b>1&nbsp;-&nbsp;25</b> of <b>50</b> in total' }
131
+ end
132
+ end
133
+
134
+ describe 'the next page' do
135
+ before do
136
+ @users = User.page(2).per(25)
137
+ end
138
+ subject { helper.page_entries_info @users, :params => {:controller => 'users', :action => 'index'} }
139
+ it { should == 'Displaying users <b>26&nbsp;-&nbsp;50</b> of <b>50</b> in total' }
140
+
141
+ context 'setting the entry name option to "member"' do
142
+ subject { helper.page_entries_info @users, :entry_name => 'member', :params => {:controller => 'users', :action => 'index'} }
143
+ it { should == 'Displaying members <b>26&nbsp;-&nbsp;50</b> of <b>50</b> in total' }
144
+ end
145
+ end
146
+ end
147
+ end
148
+ context 'on a model with namespace' do
149
+ before do
150
+ @addresses = User::Address.page(1).per(25)
151
+ end
152
+ context 'having no entries' do
153
+ subject { helper.page_entries_info @addresses, :params => {:controller => 'addresses', :action => 'index'} }
154
+ it { should == 'No entries found' }
155
+ end
156
+
157
+ context 'having 1 entry' do
158
+ before do
159
+ User::Address.create!
160
+ @addresses = User::Address.page(1).per(25)
161
+ end
162
+ subject { helper.page_entries_info @addresses, :params => {:controller => 'addresses', :action => 'index'} }
163
+ it { should == 'Displaying <b>1</b> address' }
164
+
165
+ context 'setting the entry name option to "place"' do
166
+ subject { helper.page_entries_info @addresses, :entry_name => 'place', :params => {:controller => 'addresses', :action => 'index'} }
167
+ it { should == 'Displaying <b>1</b> place' }
168
+ end
169
+ end
170
+
171
+ context 'having more than 1 but less than a page of entries' do
172
+ before do
173
+ 10.times {|i| User::Address.create!}
174
+ @addresses = User::Address.page(1).per(25)
175
+ end
176
+ subject { helper.page_entries_info @addresses, :params => {:controller => 'addresses', :action => 'index'} }
177
+ it { should == 'Displaying <b>all 10</b> addresses' }
178
+
179
+ context 'setting the entry name option to "place"' do
180
+ subject { helper.page_entries_info @addresses, :entry_name => 'place', :params => {:controller => 'addresses', :action => 'index'} }
181
+ it { should == 'Displaying <b>all 10</b> places' }
182
+ end
183
+ end
184
+
185
+ context 'having more than one page of entries' do
186
+ before do
187
+ 50.times {|i| User::Address.create!}
188
+ end
189
+
190
+ describe 'the first page' do
191
+ before do
192
+ @addresses = User::Address.page(1).per(25)
193
+ end
194
+ subject { helper.page_entries_info @addresses, :params => {:controller => 'addresses', :action => 'index'} }
195
+ it { should == 'Displaying addresses <b>1&nbsp;-&nbsp;25</b> of <b>50</b> in total' }
196
+
197
+ context 'setting the entry name option to "place"' do
198
+ subject { helper.page_entries_info @addresses, :entry_name => 'place', :params => {:controller => 'addresses', :action => 'index'} }
199
+ it { should == 'Displaying places <b>1&nbsp;-&nbsp;25</b> of <b>50</b> in total' }
200
+ end
201
+ end
202
+
203
+ describe 'the next page' do
204
+ before do
205
+ @addresses = User::Address.page(2).per(25)
206
+ end
207
+ subject { helper.page_entries_info @addresses, :params => {:controller => 'addresses', :action => 'index'} }
208
+ it { should == 'Displaying addresses <b>26&nbsp;-&nbsp;50</b> of <b>50</b> in total' }
209
+
210
+ context 'setting the entry name option to "place"' do
211
+ subject { helper.page_entries_info @addresses, :entry_name => 'place', :params => {:controller => 'addresses', :action => 'index'} }
212
+ it { should == 'Displaying places <b>26&nbsp;-&nbsp;50</b> of <b>50</b> in total' }
213
+ end
214
+ end
215
+ end
216
+ end
217
+
218
+ context 'on a PaginatableArray' do
219
+ before do
220
+ @numbers = Kaminari.paginate_array(%w{one two three}).page(1)
221
+ end
222
+ subject { helper.page_entries_info @numbers }
223
+ it { should == 'Displaying <b>all 3</b> entries' }
224
+ end
225
+ end
226
+
227
+ describe '#rel_next_prev_link_tags' do
228
+ before do
229
+ 75.times {|i| User.create! :name => "user#{i}"}
230
+ end
231
+ context 'the first page' do
232
+ before do
233
+ @users = User.page(1).per(25)
234
+ end
235
+
236
+ subject { helper.rel_next_prev_link_tags @users, :params => {:controller => 'users', :action => 'index'} }
237
+ it { should be_a String }
238
+ it { should match(/rel="next"/) }
239
+ it { should_not match(/rel="prev"/) }
240
+ end
241
+ context 'the middle page' do
242
+ before do
243
+ @users = User.page(2).per(25)
244
+ end
245
+
246
+ subject { helper.rel_next_prev_link_tags @users, :params => {:controller => 'users', :action => 'index'} }
247
+ it { should be_a String }
248
+ it { should match(/rel="next"/) }
249
+ it { should match(/rel="prev"/) }
250
+ end
251
+ context 'the last page' do
252
+ before do
253
+ @users = User.page(3).per(25)
254
+ end
255
+
256
+ subject { helper.rel_next_prev_link_tags @users, :params => {:controller => 'users', :action => 'index'} }
257
+ it { should be_a String }
258
+ it { should_not match(/rel="next"/) }
259
+ it { should match(/rel="prev"/) }
260
+ end
261
+ end
262
+ end
@@ -0,0 +1,135 @@
1
+ require 'spec_helper'
2
+ include Kaminari::Helpers
3
+
4
+ describe 'Kaminari::Helpers::Paginator' do
5
+ let :template do
6
+ stub(r = Object.new) do
7
+ render.with_any_args
8
+ params { {} }
9
+ options { {} }
10
+ url_for {|h| "/foo?page=#{h[:page]}"}
11
+ end
12
+ r
13
+ end
14
+
15
+ describe '#params' do
16
+ before do
17
+ @paginator = Paginator.new(template, :params => {:controller => 'foo', :action => 'bar'})
18
+ end
19
+ subject { @paginator.page_tag(template).instance_variable_get('@params') }
20
+ it { should == {:controller => 'foo', :action => 'bar'} }
21
+ end
22
+
23
+ describe '#param_name' do
24
+ before do
25
+ @paginator = Paginator.new(template, :param_name => :pagina)
26
+ end
27
+ subject { @paginator.page_tag(template).instance_variable_get('@param_name') }
28
+ it { should == :pagina }
29
+ end
30
+
31
+ #TODO test somehow...
32
+ # describe '#tagify_links' do
33
+ # def tags_with(options)
34
+ # PaginationRenderer.new(template, options).tagify_links
35
+ # end
36
+
37
+ # context '1 page in total' do
38
+ # subject { tags_with :total_pages => 1, :current_page => 1 }
39
+ # it { should have(0).tags }
40
+ # end
41
+
42
+ # context '10 pages in total' do
43
+ # context 'first page' do
44
+ # subject { tags_with :total_pages => 10, :current_page => 1 }
45
+ # it { should_not contain_tag PrevLink }
46
+ # it { should contain_tag PrevSpan }
47
+ # it { should contain_tag CurrentPage }
48
+ # it { should_not contain_tag FirstPageLink }
49
+ # it { should contain_tag LastPageLink }
50
+ # it { should contain_tag PageLink }
51
+ # it { should contain_tag NextLink }
52
+ # it { should_not contain_tag NextSpan }
53
+ # it { should contain_tag TruncatedSpan }
54
+ # end
55
+
56
+ # context 'second page' do
57
+ # subject { tags_with :total_pages => 10, :current_page => 2 }
58
+ # it { should contain_tag PrevLink }
59
+ # it { should_not contain_tag PrevSpan }
60
+ # it { should contain_tag CurrentPage }
61
+ # it { should contain_tag FirstPageLink }
62
+ # it { should contain_tag LastPageLink }
63
+ # it { should contain_tag PageLink }
64
+ # it { should contain_tag NextLink }
65
+ # it { should_not contain_tag NextSpan }
66
+ # it { should contain_tag TruncatedSpan }
67
+ # end
68
+
69
+ # context 'third page' do
70
+ # subject { tags_with :total_pages => 10, :current_page => 3 }
71
+ # it { should contain_tag PrevLink }
72
+ # it { should_not contain_tag PrevSpan }
73
+ # it { should contain_tag CurrentPage }
74
+ # it { should contain_tag FirstPageLink }
75
+ # it { should contain_tag LastPageLink }
76
+ # it { should contain_tag PageLink }
77
+ # it { should contain_tag NextLink }
78
+ # it { should_not contain_tag NextSpan }
79
+ # it { should contain_tag TruncatedSpan }
80
+ # end
81
+
82
+ # context 'fourth page(no truncation)' do
83
+ # subject { tags_with :total_pages => 10, :current_page => 4 }
84
+ # it { should contain_tag PrevLink }
85
+ # it { should_not contain_tag PrevSpan }
86
+ # it { should contain_tag CurrentPage }
87
+ # it { should contain_tag FirstPageLink }
88
+ # it { should contain_tag LastPageLink }
89
+ # it { should contain_tag PageLink }
90
+ # it { should contain_tag NextLink }
91
+ # it { should_not contain_tag NextSpan }
92
+ # it { should_not contain_tag TruncatedSpan }
93
+ # end
94
+
95
+ # context 'seventh page(no truncation)' do
96
+ # subject { tags_with :total_pages => 10, :current_page => 7 }
97
+ # it { should contain_tag PrevLink }
98
+ # it { should_not contain_tag PrevSpan }
99
+ # it { should contain_tag CurrentPage }
100
+ # it { should contain_tag FirstPageLink }
101
+ # it { should contain_tag LastPageLink }
102
+ # it { should contain_tag PageLink }
103
+ # it { should contain_tag NextLink }
104
+ # it { should_not contain_tag NextSpan }
105
+ # it { should_not contain_tag TruncatedSpan }
106
+ # end
107
+
108
+ # context 'eighth page' do
109
+ # subject { tags_with :total_pages => 10, :current_page => 8 }
110
+ # it { should contain_tag PrevLink }
111
+ # it { should_not contain_tag PrevSpan }
112
+ # it { should contain_tag CurrentPage }
113
+ # it { should contain_tag FirstPageLink }
114
+ # it { should contain_tag LastPageLink }
115
+ # it { should contain_tag PageLink }
116
+ # it { should contain_tag NextLink }
117
+ # it { should_not contain_tag NextSpan }
118
+ # it { should contain_tag TruncatedSpan }
119
+ # end
120
+
121
+ # context 'last page' do
122
+ # subject { tags_with :total_pages => 10, :current_page => 10 }
123
+ # it { should contain_tag PrevLink }
124
+ # it { should_not contain_tag PrevSpan }
125
+ # it { should contain_tag CurrentPage }
126
+ # it { should contain_tag FirstPageLink }
127
+ # it { should_not contain_tag LastPageLink }
128
+ # it { should contain_tag PageLink }
129
+ # it { should_not contain_tag NextLink }
130
+ # it { should contain_tag NextSpan }
131
+ # it { should contain_tag TruncatedSpan }
132
+ # end
133
+ # end
134
+ # end
135
+ end