kaminari 0.17.0 → 1.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of kaminari might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/.travis.yml +20 -39
- data/CHANGELOG.md +560 -0
- data/CONTRIBUTING.md +16 -0
- data/Gemfile +1 -0
- data/README.md +545 -0
- data/Rakefile +21 -24
- data/gemfiles/active_record_41.gemfile +2 -4
- data/gemfiles/active_record_42.gemfile +2 -4
- data/gemfiles/active_record_50.gemfile +20 -0
- data/gemfiles/active_record_edge.gemfile +5 -6
- data/kaminari.gemspec +11 -17
- data/lib/kaminari.rb +4 -39
- data/lib/kaminari/version.rb +2 -1
- metadata +44 -186
- data/.gemtest +0 -0
- data/.rspec +0 -2
- data/CHANGELOG.rdoc +0 -480
- data/README.rdoc +0 -336
- data/app/views/kaminari/_first_page.html.erb +0 -11
- data/app/views/kaminari/_first_page.html.haml +0 -9
- data/app/views/kaminari/_first_page.html.slim +0 -10
- data/app/views/kaminari/_gap.html.erb +0 -8
- data/app/views/kaminari/_gap.html.haml +0 -8
- data/app/views/kaminari/_gap.html.slim +0 -9
- data/app/views/kaminari/_last_page.html.erb +0 -11
- data/app/views/kaminari/_last_page.html.haml +0 -9
- data/app/views/kaminari/_last_page.html.slim +0 -10
- data/app/views/kaminari/_next_page.html.erb +0 -11
- data/app/views/kaminari/_next_page.html.haml +0 -9
- data/app/views/kaminari/_next_page.html.slim +0 -10
- data/app/views/kaminari/_page.html.erb +0 -12
- data/app/views/kaminari/_page.html.haml +0 -10
- data/app/views/kaminari/_page.html.slim +0 -11
- data/app/views/kaminari/_paginator.html.erb +0 -23
- data/app/views/kaminari/_paginator.html.haml +0 -18
- data/app/views/kaminari/_paginator.html.slim +0 -19
- data/app/views/kaminari/_prev_page.html.erb +0 -11
- data/app/views/kaminari/_prev_page.html.haml +0 -9
- data/app/views/kaminari/_prev_page.html.slim +0 -10
- data/config/locales/kaminari.yml +0 -19
- data/gemfiles/active_record_30.gemfile +0 -28
- data/gemfiles/active_record_31.gemfile +0 -26
- data/gemfiles/active_record_32.gemfile +0 -25
- data/gemfiles/active_record_40.gemfile +0 -26
- data/gemfiles/data_mapper_12.gemfile +0 -32
- data/gemfiles/mongo_mapper.gemfile +0 -25
- data/gemfiles/mongoid_30.gemfile +0 -22
- data/gemfiles/mongoid_31.gemfile +0 -21
- data/gemfiles/mongoid_40.gemfile +0 -19
- data/gemfiles/mongoid_50.gemfile +0 -23
- data/gemfiles/sinatra_13.gemfile +0 -36
- data/gemfiles/sinatra_14.gemfile +0 -33
- data/lib/generators/kaminari/config_generator.rb +0 -16
- data/lib/generators/kaminari/templates/kaminari_config.rb +0 -10
- data/lib/generators/kaminari/views_generator.rb +0 -119
- data/lib/kaminari/config.rb +0 -51
- data/lib/kaminari/engine.rb +0 -4
- data/lib/kaminari/grape.rb +0 -4
- data/lib/kaminari/helpers/action_view_extension.rb +0 -132
- data/lib/kaminari/helpers/paginator.rb +0 -195
- data/lib/kaminari/helpers/sinatra_helpers.rb +0 -176
- data/lib/kaminari/helpers/tags.rb +0 -108
- data/lib/kaminari/hooks.rb +0 -53
- data/lib/kaminari/models/active_record_extension.rb +0 -22
- data/lib/kaminari/models/active_record_model_extension.rb +0 -22
- data/lib/kaminari/models/active_record_relation_methods.rb +0 -42
- data/lib/kaminari/models/array_extension.rb +0 -66
- data/lib/kaminari/models/configuration_methods.rb +0 -48
- data/lib/kaminari/models/data_mapper_collection_methods.rb +0 -19
- data/lib/kaminari/models/data_mapper_extension.rb +0 -51
- data/lib/kaminari/models/mongo_mapper_extension.rb +0 -18
- data/lib/kaminari/models/mongoid_criteria_methods.rb +0 -40
- data/lib/kaminari/models/mongoid_extension.rb +0 -26
- data/lib/kaminari/models/page_scope_methods.rb +0 -73
- data/lib/kaminari/models/plucky_criteria_methods.rb +0 -23
- data/lib/kaminari/railtie.rb +0 -7
- data/lib/kaminari/sinatra.rb +0 -7
- data/spec/config/config_spec.rb +0 -91
- data/spec/fake_app/active_record/config.rb +0 -3
- data/spec/fake_app/active_record/models.rb +0 -65
- data/spec/fake_app/data_mapper/config.rb +0 -1
- data/spec/fake_app/data_mapper/models.rb +0 -27
- data/spec/fake_app/mongo_mapper/config.rb +0 -2
- data/spec/fake_app/mongo_mapper/models.rb +0 -9
- data/spec/fake_app/mongoid/config.rb +0 -20
- data/spec/fake_app/mongoid/models.rb +0 -38
- data/spec/fake_app/rails_app.rb +0 -56
- data/spec/fake_app/sinatra_app.rb +0 -22
- data/spec/fake_app/views/alternative/kaminari/_first_page.html.erb +0 -1
- data/spec/fake_app/views/alternative/kaminari/_paginator.html.erb +0 -3
- data/spec/fake_app/views/kaminari/bootstrap/_page.html.erb +0 -1
- data/spec/fake_app/views/kaminari/bootstrap/_paginator.html.erb +0 -7
- data/spec/fake_gem.rb +0 -20
- data/spec/generators/views_generator_spec.rb +0 -18
- data/spec/helpers/action_view_extension_spec.rb +0 -318
- data/spec/helpers/helpers_spec.rb +0 -144
- data/spec/helpers/sinatra_helpers_spec.rb +0 -223
- data/spec/helpers/tags_spec.rb +0 -140
- data/spec/models/active_record/active_record_relation_methods_spec.rb +0 -77
- data/spec/models/active_record/inherited_spec.rb +0 -9
- data/spec/models/active_record/scopes_spec.rb +0 -265
- data/spec/models/array_spec.rb +0 -172
- data/spec/models/configuration_methods_spec.rb +0 -125
- data/spec/models/data_mapper/data_mapper_spec.rb +0 -205
- data/spec/models/mongo_mapper/mongo_mapper_spec.rb +0 -84
- data/spec/models/mongoid/mongoid_spec.rb +0 -228
- data/spec/requests/users_spec.rb +0 -53
- data/spec/spec_helper.rb +0 -34
- data/spec/spec_helper_for_sinatra.rb +0 -34
- data/spec/support/database_cleaner.rb +0 -19
- data/spec/support/matchers.rb +0 -52
@@ -1 +0,0 @@
|
|
1
|
-
DataMapper.setup(:default, 'sqlite::memory:')
|
@@ -1,27 +0,0 @@
|
|
1
|
-
class User
|
2
|
-
include ::DataMapper::Resource
|
3
|
-
|
4
|
-
property :id, Serial
|
5
|
-
property :name, String, :required => true
|
6
|
-
property :age, Integer
|
7
|
-
|
8
|
-
has n, :projects, :through => Resource
|
9
|
-
end
|
10
|
-
|
11
|
-
class User::Address
|
12
|
-
include ::DataMapper::Resource
|
13
|
-
|
14
|
-
property :id, Serial
|
15
|
-
end
|
16
|
-
|
17
|
-
class Project
|
18
|
-
include ::DataMapper::Resource
|
19
|
-
|
20
|
-
property :id, Serial
|
21
|
-
property :name, String, :required => true
|
22
|
-
|
23
|
-
has n, :users, :through => Resource
|
24
|
-
end
|
25
|
-
|
26
|
-
DataMapper.finalize
|
27
|
-
DataMapper.auto_migrate!
|
@@ -1,20 +0,0 @@
|
|
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
|
-
require 'mongoid/version'
|
7
|
-
|
8
|
-
if RUBY_VERSION >= '1.9.2' && RUBY_VERSION < '2.2.0'
|
9
|
-
YAML::ENGINE.yamler = 'syck'
|
10
|
-
end
|
11
|
-
|
12
|
-
Mongoid.configure do |config|
|
13
|
-
if Mongoid::VERSION >= '5.0.0'
|
14
|
-
config.connect_to 'kaminari_test'
|
15
|
-
elsif Mongoid::VERSION > '3.0.0'
|
16
|
-
config.sessions = {:default => {:hosts => ['0.0.0.0:27017'], :database => 'kaminari_test'}}
|
17
|
-
else
|
18
|
-
config.master = Mongo::Connection.new.db('kaminari_test')
|
19
|
-
end
|
20
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
class User
|
2
|
-
include ::Mongoid::Document
|
3
|
-
if Mongoid::VERSION >= '4.0.0'
|
4
|
-
include Mongoid::Attributes::Dynamic
|
5
|
-
end
|
6
|
-
|
7
|
-
field :name, :type => String
|
8
|
-
field :age, :type => Integer
|
9
|
-
end
|
10
|
-
|
11
|
-
class User::Address
|
12
|
-
include ::Mongoid::Document
|
13
|
-
end
|
14
|
-
|
15
|
-
class Product
|
16
|
-
include ::Mongoid::Document
|
17
|
-
end
|
18
|
-
|
19
|
-
class Device < Product
|
20
|
-
paginates_per 100
|
21
|
-
end
|
22
|
-
|
23
|
-
class Android < Device
|
24
|
-
paginates_per 200
|
25
|
-
end
|
26
|
-
|
27
|
-
class MongoMongoidExtensionDeveloper
|
28
|
-
include ::Mongoid::Document
|
29
|
-
field :salary, :type => Integer
|
30
|
-
embeds_many :frameworks
|
31
|
-
end
|
32
|
-
|
33
|
-
class Framework
|
34
|
-
include ::Mongoid::Document
|
35
|
-
field :name, :type => String
|
36
|
-
field :language, :type => String
|
37
|
-
embedded_in :mongo_mongoid_extension_developer
|
38
|
-
end
|
data/spec/fake_app/rails_app.rb
DELETED
@@ -1,56 +0,0 @@
|
|
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)
|
@@ -1,22 +0,0 @@
|
|
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
|
@@ -1 +0,0 @@
|
|
1
|
-
<b><%= current_page %></b>
|
@@ -1 +0,0 @@
|
|
1
|
-
<li class="bootstrap-page-link"><%= link_to page, url %></li>
|
data/spec/fake_gem.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
module Kaminari
|
2
|
-
module FakeGem
|
3
|
-
extend ActiveSupport::Concern
|
4
|
-
|
5
|
-
module ClassMethods
|
6
|
-
def inherited(kls)
|
7
|
-
super
|
8
|
-
def kls.fake_gem_defined_method; end
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
ActiveSupport.on_load :active_record do
|
15
|
-
ActiveRecord::Base.send :include, Kaminari::FakeGem
|
16
|
-
|
17
|
-
# Simulate a gem providing a subclass of ActiveRecord::Base before the Railtie is loaded.
|
18
|
-
class GemDefinedModel < ActiveRecord::Base
|
19
|
-
end
|
20
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
if defined?(Rails)
|
4
|
-
require 'rails/generators'
|
5
|
-
require 'generators/kaminari/views_generator'
|
6
|
-
|
7
|
-
describe Kaminari::Generators::GitHubApiHelper, :generator_spec => true do
|
8
|
-
describe '.get_files_in_master' do
|
9
|
-
subject { Kaminari::Generators::GitHubApiHelper.get_files_in_master }
|
10
|
-
it { should include(["README", "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"]) }
|
11
|
-
end
|
12
|
-
|
13
|
-
describe '.get_content_for' do
|
14
|
-
subject { Kaminari::Generators::GitHubApiHelper.get_content_for("README") }
|
15
|
-
it { should == "" }
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,318 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'Kaminari::ActionViewExtension', :if => defined?(Rails)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
|
-
|
10
|
-
subject { helper.paginate @users, :params => {:controller => 'users', :action => 'index'} }
|
11
|
-
it { should be_a String }
|
12
|
-
|
13
|
-
context 'escaping the pagination for javascript' do
|
14
|
-
it 'should escape for javascript' do
|
15
|
-
lambda { helper.escape_javascript(helper.paginate @users, :params => {:controller => 'users', :action => 'index'}) }.should_not raise_error
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
context 'accepts :theme option' do
|
20
|
-
before { helper.controller.append_view_path "spec/fake_app/views" }
|
21
|
-
subject { helper.paginate @users, :theme => "bootstrap", :params => {:controller => 'users', :action => 'index'} }
|
22
|
-
it { should match(/bootstrap-paginator/) }
|
23
|
-
it { should match(/bootstrap-page-link/) }
|
24
|
-
end
|
25
|
-
|
26
|
-
context 'accepts :view_prefix option' do
|
27
|
-
before { helper.controller.append_view_path "spec/fake_app/views" }
|
28
|
-
subject { helper.paginate @users, :views_prefix => "alternative/", :params => {:controller => 'users', :action => 'index'} }
|
29
|
-
it { should eq(" <b>1</b>\n") }
|
30
|
-
end
|
31
|
-
|
32
|
-
context "num_pages: 3" do
|
33
|
-
subject { helper.paginate @users, :num_pages => 3, :params => {:controller => 'users', :action => 'index'} }
|
34
|
-
it { should match(/<a href="\/users\?page=3">Last/) }
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe '#link_to_previous_page' do
|
39
|
-
before do
|
40
|
-
50.times {|i| User.create! :name => "user#{i}"}
|
41
|
-
end
|
42
|
-
|
43
|
-
context 'having previous pages' do
|
44
|
-
before do
|
45
|
-
@users = User.page(50)
|
46
|
-
end
|
47
|
-
|
48
|
-
context 'the default behaviour' do
|
49
|
-
subject { helper.link_to_previous_page @users, 'Previous', :params => {:controller => 'users', :action => 'index'} }
|
50
|
-
it { should be_a String }
|
51
|
-
it { should match(/rel="previous"/) }
|
52
|
-
end
|
53
|
-
|
54
|
-
context 'overriding rel=' do
|
55
|
-
subject { helper.link_to_previous_page @users, 'Previous', :rel => 'external', :params => {:controller => 'users', :action => 'index'} }
|
56
|
-
it { should match(/rel="external"/) }
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
context 'the first page' do
|
61
|
-
before do
|
62
|
-
@users = User.page(1)
|
63
|
-
end
|
64
|
-
|
65
|
-
subject { helper.link_to_previous_page @users, 'Previous', :params => {:controller => 'users', :action => 'index'} }
|
66
|
-
it { should_not be }
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
describe '#link_to_next_page' do
|
71
|
-
before do
|
72
|
-
50.times {|i| User.create! :name => "user#{i}"}
|
73
|
-
end
|
74
|
-
|
75
|
-
context 'having more page' do
|
76
|
-
before do
|
77
|
-
@users = User.page(1)
|
78
|
-
end
|
79
|
-
|
80
|
-
context 'the default behaviour' do
|
81
|
-
subject { helper.link_to_next_page @users, 'More', :params => {:controller => 'users', :action => 'index'} }
|
82
|
-
it { should be_a String }
|
83
|
-
it { should match(/rel="next"/) }
|
84
|
-
end
|
85
|
-
|
86
|
-
context 'overriding rel=' do
|
87
|
-
subject { helper.link_to_next_page @users, 'More', :rel => 'external', :params => {:controller => 'users', :action => 'index'} }
|
88
|
-
it { should match(/rel="external"/) }
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
context 'the last page' do
|
93
|
-
before do
|
94
|
-
@users = User.page(2)
|
95
|
-
end
|
96
|
-
|
97
|
-
subject { helper.link_to_next_page @users, 'More', :params => {:controller => 'users', :action => 'index'} }
|
98
|
-
it { should_not be }
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
describe '#page_entries_info' do
|
103
|
-
context 'on a model without namespace' do
|
104
|
-
before do
|
105
|
-
@users = User.page(1).per(25)
|
106
|
-
end
|
107
|
-
|
108
|
-
context 'having no entries' do
|
109
|
-
subject { helper.page_entries_info @users, :params => {:controller => 'users', :action => 'index'} }
|
110
|
-
it { should == 'No users found' }
|
111
|
-
|
112
|
-
context 'setting the entry name option to "member"' do
|
113
|
-
subject { helper.page_entries_info @users, :entry_name => 'member', :params => {:controller => 'users', :action => 'index'} }
|
114
|
-
it { should == 'No members found' }
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
context 'having 1 entry' do
|
119
|
-
before do
|
120
|
-
User.create! :name => 'user1'
|
121
|
-
@users = User.page(1).per(25)
|
122
|
-
end
|
123
|
-
|
124
|
-
subject { helper.page_entries_info @users, :params => {:controller => 'users', :action => 'index'} }
|
125
|
-
it { should == 'Displaying <b>1</b> user' }
|
126
|
-
|
127
|
-
context 'setting the entry name option to "member"' do
|
128
|
-
subject { helper.page_entries_info @users, :entry_name => 'member', :params => {:controller => 'users', :action => 'index'} }
|
129
|
-
it { should == 'Displaying <b>1</b> member' }
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
context 'having more than 1 but less than a page of entries' do
|
134
|
-
before do
|
135
|
-
10.times {|i| User.create! :name => "user#{i}"}
|
136
|
-
@users = User.page(1).per(25)
|
137
|
-
end
|
138
|
-
|
139
|
-
subject { helper.page_entries_info @users, :params => {:controller => 'users', :action => 'index'} }
|
140
|
-
it { should == 'Displaying <b>all 10</b> users' }
|
141
|
-
|
142
|
-
context 'setting the entry name option to "member"' do
|
143
|
-
subject { helper.page_entries_info @users, :entry_name => 'member', :params => {:controller => 'users', :action => 'index'} }
|
144
|
-
it { should == 'Displaying <b>all 10</b> members' }
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
context 'having more than one page of entries' do
|
149
|
-
before do
|
150
|
-
50.times {|i| User.create! :name => "user#{i}"}
|
151
|
-
end
|
152
|
-
|
153
|
-
describe 'the first page' do
|
154
|
-
before do
|
155
|
-
@users = User.page(1).per(25)
|
156
|
-
end
|
157
|
-
|
158
|
-
subject { helper.page_entries_info @users, :params => {:controller => 'users', :action => 'index'} }
|
159
|
-
it { should == 'Displaying users <b>1 - 25</b> of <b>50</b> in total' }
|
160
|
-
|
161
|
-
context 'setting the entry name option to "member"' do
|
162
|
-
subject { helper.page_entries_info @users, :entry_name => 'member', :params => {:controller => 'users', :action => 'index'} }
|
163
|
-
it { should == 'Displaying members <b>1 - 25</b> of <b>50</b> in total' }
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
describe 'the next page' do
|
168
|
-
before do
|
169
|
-
@users = User.page(2).per(25)
|
170
|
-
end
|
171
|
-
|
172
|
-
subject { helper.page_entries_info @users, :params => {:controller => 'users', :action => 'index'} }
|
173
|
-
it { should == 'Displaying users <b>26 - 50</b> of <b>50</b> in total' }
|
174
|
-
|
175
|
-
context 'setting the entry name option to "member"' do
|
176
|
-
subject { helper.page_entries_info @users, :entry_name => 'member', :params => {:controller => 'users', :action => 'index'} }
|
177
|
-
it { should == 'Displaying members <b>26 - 50</b> of <b>50</b> in total' }
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
describe 'the last page' do
|
182
|
-
before do
|
183
|
-
User.max_pages_per 4
|
184
|
-
@users = User.page(4).per(10)
|
185
|
-
end
|
186
|
-
|
187
|
-
after { User.max_pages_per nil }
|
188
|
-
|
189
|
-
subject { helper.page_entries_info @users, :params => {:controller => 'users', :action => 'index'} }
|
190
|
-
it { should == 'Displaying users <b>31 - 40</b> of <b>50</b> in total' }
|
191
|
-
end
|
192
|
-
end
|
193
|
-
end
|
194
|
-
context 'on a model with namespace' do
|
195
|
-
before do
|
196
|
-
@addresses = User::Address.page(1).per(25)
|
197
|
-
end
|
198
|
-
|
199
|
-
context 'having no entries' do
|
200
|
-
subject { helper.page_entries_info @addresses, :params => {:controller => 'addresses', :action => 'index'} }
|
201
|
-
it { should == 'No addresses found' }
|
202
|
-
end
|
203
|
-
|
204
|
-
context 'having 1 entry' do
|
205
|
-
before do
|
206
|
-
User::Address.create!
|
207
|
-
@addresses = User::Address.page(1).per(25)
|
208
|
-
end
|
209
|
-
|
210
|
-
subject { helper.page_entries_info @addresses, :params => {:controller => 'addresses', :action => 'index'} }
|
211
|
-
it { should == 'Displaying <b>1</b> address' }
|
212
|
-
|
213
|
-
context 'setting the entry name option to "place"' do
|
214
|
-
subject { helper.page_entries_info @addresses, :entry_name => 'place', :params => {:controller => 'addresses', :action => 'index'} }
|
215
|
-
it { should == 'Displaying <b>1</b> place' }
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
context 'having more than 1 but less than a page of entries' do
|
220
|
-
before do
|
221
|
-
10.times {|i| User::Address.create!}
|
222
|
-
@addresses = User::Address.page(1).per(25)
|
223
|
-
end
|
224
|
-
|
225
|
-
subject { helper.page_entries_info @addresses, :params => {:controller => 'addresses', :action => 'index'} }
|
226
|
-
it { should == 'Displaying <b>all 10</b> addresses' }
|
227
|
-
|
228
|
-
context 'setting the entry name option to "place"' do
|
229
|
-
subject { helper.page_entries_info @addresses, :entry_name => 'place', :params => {:controller => 'addresses', :action => 'index'} }
|
230
|
-
it { should == 'Displaying <b>all 10</b> places' }
|
231
|
-
end
|
232
|
-
end
|
233
|
-
|
234
|
-
context 'having more than one page of entries' do
|
235
|
-
before do
|
236
|
-
50.times {|i| User::Address.create!}
|
237
|
-
end
|
238
|
-
|
239
|
-
describe 'the first page' do
|
240
|
-
before do
|
241
|
-
@addresses = User::Address.page(1).per(25)
|
242
|
-
end
|
243
|
-
|
244
|
-
subject { helper.page_entries_info @addresses, :params => {:controller => 'addresses', :action => 'index'} }
|
245
|
-
it { should == 'Displaying addresses <b>1 - 25</b> of <b>50</b> in total' }
|
246
|
-
|
247
|
-
context 'setting the entry name option to "place"' do
|
248
|
-
subject { helper.page_entries_info @addresses, :entry_name => 'place', :params => {:controller => 'addresses', :action => 'index'} }
|
249
|
-
it { should == 'Displaying places <b>1 - 25</b> of <b>50</b> in total' }
|
250
|
-
end
|
251
|
-
end
|
252
|
-
|
253
|
-
describe 'the next page' do
|
254
|
-
before do
|
255
|
-
@addresses = User::Address.page(2).per(25)
|
256
|
-
end
|
257
|
-
|
258
|
-
subject { helper.page_entries_info @addresses, :params => {:controller => 'addresses', :action => 'index'} }
|
259
|
-
it { should == 'Displaying addresses <b>26 - 50</b> of <b>50</b> in total' }
|
260
|
-
|
261
|
-
context 'setting the entry name option to "place"' do
|
262
|
-
subject { helper.page_entries_info @addresses, :entry_name => 'place', :params => {:controller => 'addresses', :action => 'index'} }
|
263
|
-
it { should == 'Displaying places <b>26 - 50</b> of <b>50</b> in total' }
|
264
|
-
end
|
265
|
-
end
|
266
|
-
end
|
267
|
-
end
|
268
|
-
|
269
|
-
context 'on a PaginatableArray' do
|
270
|
-
before do
|
271
|
-
@numbers = Kaminari.paginate_array(%w{one two three}).page(1)
|
272
|
-
end
|
273
|
-
|
274
|
-
subject { helper.page_entries_info @numbers }
|
275
|
-
it { should == 'Displaying <b>all 3</b> entries' }
|
276
|
-
end
|
277
|
-
end
|
278
|
-
|
279
|
-
describe '#rel_next_prev_link_tags' do
|
280
|
-
before do
|
281
|
-
80.times {|i| User.create! :name => "user#{i}"}
|
282
|
-
end
|
283
|
-
|
284
|
-
context 'the first page' do
|
285
|
-
before do
|
286
|
-
@users = User.page(1).per(25)
|
287
|
-
end
|
288
|
-
|
289
|
-
subject { helper.rel_next_prev_link_tags @users, :params => {:controller => 'users', :action => 'index'} }
|
290
|
-
it { should_not match(/rel="prev"/) }
|
291
|
-
it { should match(/rel="next"/) }
|
292
|
-
it { should match(/\?page=2/) }
|
293
|
-
end
|
294
|
-
|
295
|
-
context 'the middle page' do
|
296
|
-
before do
|
297
|
-
@users = User.page(3).per(25)
|
298
|
-
end
|
299
|
-
|
300
|
-
subject { helper.rel_next_prev_link_tags @users, :params => {:controller => 'users', :action => 'index'} }
|
301
|
-
it { should match(/rel="prev"/) }
|
302
|
-
it { should match(/\?page=2/) }
|
303
|
-
it { should match(/rel="next"/) }
|
304
|
-
it { should match(/\?page=4/) }
|
305
|
-
end
|
306
|
-
|
307
|
-
context 'the last page' do
|
308
|
-
before do
|
309
|
-
@users = User.page(4).per(25)
|
310
|
-
end
|
311
|
-
|
312
|
-
subject { helper.rel_next_prev_link_tags @users, :params => {:controller => 'users', :action => 'index'} }
|
313
|
-
it { should match(/rel="prev"/) }
|
314
|
-
it { should match(/\?page=3"/) }
|
315
|
-
it { should_not match(/rel="next"/) }
|
316
|
-
end
|
317
|
-
end
|
318
|
-
end
|