From e79935c2d596e165be566f6d92eed8d5acd6a843 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Fri, 25 May 2012 15:31:53 +0900 Subject: [PATCH] num_pages => total_pages --- app/views/kaminari/_first_page.html.erb | 2 +- app/views/kaminari/_first_page.html.haml | 2 +- app/views/kaminari/_first_page.html.slim | 2 +- app/views/kaminari/_gap.html.erb | 2 +- app/views/kaminari/_gap.html.haml | 2 +- app/views/kaminari/_gap.html.slim | 2 +- app/views/kaminari/_last_page.html.erb | 2 +- app/views/kaminari/_last_page.html.haml | 2 +- app/views/kaminari/_last_page.html.slim | 2 +- app/views/kaminari/_next_page.html.erb | 2 +- app/views/kaminari/_next_page.html.haml | 2 +- app/views/kaminari/_next_page.html.slim | 2 +- app/views/kaminari/_page.html.erb | 3 ++- app/views/kaminari/_page.html.haml | 2 +- app/views/kaminari/_page.html.slim | 2 +- app/views/kaminari/_paginator.html.erb | 2 +- app/views/kaminari/_paginator.html.haml | 2 +- app/views/kaminari/_paginator.html.slim | 2 +- app/views/kaminari/_prev_page.html.erb | 2 +- app/views/kaminari/_prev_page.html.haml | 2 +- app/views/kaminari/_prev_page.html.slim | 2 +- lib/kaminari/helpers/action_view_extension.rb | 4 ++-- lib/kaminari/helpers/paginator.rb | 10 ++++---- lib/kaminari/helpers/sinatra_helpers.rb | 2 +- lib/kaminari/helpers/tags.rb | 2 +- lib/kaminari/models/page_scope_methods.rb | 4 ++-- spec/helpers/helpers_spec.rb | 16 ++++++------- spec/helpers/tags_spec.rb | 16 ++++++------- spec/models/active_record/scopes_spec.rb | 16 ++++++------- spec/models/array_spec.rb | 14 +++++------ spec/models/data_mapper/data_mapper_spec.rb | 24 +++++++++---------- spec/models/mongo_mapper/mongo_mapper_spec.rb | 12 +++++----- spec/models/mongoid/mongoid_spec.rb | 16 ++++++------- 33 files changed, 90 insertions(+), 89 deletions(-) diff --git a/app/views/kaminari/_first_page.html.erb b/app/views/kaminari/_first_page.html.erb index f147502..404e9b0 100644 --- a/app/views/kaminari/_first_page.html.erb +++ b/app/views/kaminari/_first_page.html.erb @@ -2,7 +2,7 @@ - available local variables url: url to the first page current_page: a page object for the currently displayed page - num_pages: total number of pages + total_pages: total number of pages per_page: number of items to fetch per page remote: data-remote -%> diff --git a/app/views/kaminari/_first_page.html.haml b/app/views/kaminari/_first_page.html.haml index fee8112..ea2ed02 100644 --- a/app/views/kaminari/_first_page.html.haml +++ b/app/views/kaminari/_first_page.html.haml @@ -2,7 +2,7 @@ -# available local variables -# url: url to the first page -# current_page: a page object for the currently displayed page --# num_pages: total number of pages +-# total_pages: total number of pages -# per_page: number of items to fetch per page -# remote: data-remote %span.first diff --git a/app/views/kaminari/_first_page.html.slim b/app/views/kaminari/_first_page.html.slim index 388ec33..cb1c660 100644 --- a/app/views/kaminari/_first_page.html.slim +++ b/app/views/kaminari/_first_page.html.slim @@ -2,7 +2,7 @@ - available local variables url : url to the first page current_page : a page object for the currently displayed page - num_pages : total number of pages + total_pages : total number of pages per_page : number of items to fetch per page remote : data-remote span.first diff --git a/app/views/kaminari/_gap.html.erb b/app/views/kaminari/_gap.html.erb index d1800e1..33b9d7a 100644 --- a/app/views/kaminari/_gap.html.erb +++ b/app/views/kaminari/_gap.html.erb @@ -1,7 +1,7 @@ <%# Non-link tag that stands for skipped pages... - available local variables current_page: a page object for the currently displayed page - num_pages: total number of pages + total_pages: total number of pages per_page: number of items to fetch per page remote: data-remote -%> diff --git a/app/views/kaminari/_gap.html.haml b/app/views/kaminari/_gap.html.haml index f82f185..58c0abd 100644 --- a/app/views/kaminari/_gap.html.haml +++ b/app/views/kaminari/_gap.html.haml @@ -1,7 +1,7 @@ -# Non-link tag that stands for skipped pages... -# available local variables -# current_page: a page object for the currently displayed page --# num_pages: total number of pages +-# total_pages: total number of pages -# per_page: number of items to fetch per page -# remote: data-remote %span.page.gap diff --git a/app/views/kaminari/_gap.html.slim b/app/views/kaminari/_gap.html.slim index bb1f32a..c71155c 100644 --- a/app/views/kaminari/_gap.html.slim +++ b/app/views/kaminari/_gap.html.slim @@ -1,7 +1,7 @@ / Non-link tag that stands for skipped pages... - available local variables current_page : a page object for the currently displayed page - num_pages : total number of pages + total_pages : total number of pages per_page : number of items to fetch per page remote : data-remote span.page.gap diff --git a/app/views/kaminari/_last_page.html.erb b/app/views/kaminari/_last_page.html.erb index 73ce4d4..2a60cd2 100644 --- a/app/views/kaminari/_last_page.html.erb +++ b/app/views/kaminari/_last_page.html.erb @@ -2,7 +2,7 @@ - available local variables url: url to the last page current_page: a page object for the currently displayed page - num_pages: total number of pages + total_pages: total number of pages per_page: number of items to fetch per page remote: data-remote -%> diff --git a/app/views/kaminari/_last_page.html.haml b/app/views/kaminari/_last_page.html.haml index 6e41d23..2e0a293 100644 --- a/app/views/kaminari/_last_page.html.haml +++ b/app/views/kaminari/_last_page.html.haml @@ -2,7 +2,7 @@ -# available local variables -# url: url to the last page -# current_page: a page object for the currently displayed page --# num_pages: total number of pages +-# total_pages: total number of pages -# per_page: number of items to fetch per page -# remote: data-remote %span.last diff --git a/app/views/kaminari/_last_page.html.slim b/app/views/kaminari/_last_page.html.slim index 72b3354..c8210a3 100644 --- a/app/views/kaminari/_last_page.html.slim +++ b/app/views/kaminari/_last_page.html.slim @@ -2,7 +2,7 @@ - available local variables url : url to the last page current_page : a page object for the currently displayed page - num_pages : total number of pages + total_pages : total number of pages per_page : number of items to fetch per page remote : data-remote span.last diff --git a/app/views/kaminari/_next_page.html.erb b/app/views/kaminari/_next_page.html.erb index 1900875..6937d27 100644 --- a/app/views/kaminari/_next_page.html.erb +++ b/app/views/kaminari/_next_page.html.erb @@ -2,7 +2,7 @@ - available local variables url: url to the next page current_page: a page object for the currently displayed page - num_pages: total number of pages + total_pages: total number of pages per_page: number of items to fetch per page remote: data-remote -%> diff --git a/app/views/kaminari/_next_page.html.haml b/app/views/kaminari/_next_page.html.haml index e87ab4e..da8fd4a 100644 --- a/app/views/kaminari/_next_page.html.haml +++ b/app/views/kaminari/_next_page.html.haml @@ -2,7 +2,7 @@ -# available local variables -# url: url to the next page -# current_page: a page object for the currently displayed page --# num_pages: total number of pages +-# total_pages: total number of pages -# per_page: number of items to fetch per page -# remote: data-remote %span.next diff --git a/app/views/kaminari/_next_page.html.slim b/app/views/kaminari/_next_page.html.slim index 0633935..dd60ac4 100644 --- a/app/views/kaminari/_next_page.html.slim +++ b/app/views/kaminari/_next_page.html.slim @@ -2,7 +2,7 @@ - available local variables url : url to the next page current_page : a page object for the currently displayed page - num_pages : total number of pages + total_pages : total number of pages per_page : number of items to fetch per page remote : data-remote span.next diff --git a/app/views/kaminari/_page.html.erb b/app/views/kaminari/_page.html.erb index 1683069..038bab5 100644 --- a/app/views/kaminari/_page.html.erb +++ b/app/views/kaminari/_page.html.erb @@ -3,10 +3,11 @@ page: a page object for "this" page url: url to this page current_page: a page object for the currently displayed page - num_pages: total number of pages + total_pages: total number of pages per_page: number of items to fetch per page remote: data-remote -%> +<%= p total_pages %> <%= link_to_unless page.current?, page, url, opts = {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil} %> diff --git a/app/views/kaminari/_page.html.haml b/app/views/kaminari/_page.html.haml index 528bba8..acfb0cf 100644 --- a/app/views/kaminari/_page.html.haml +++ b/app/views/kaminari/_page.html.haml @@ -3,7 +3,7 @@ -# page: a page object for "this" page -# url: url to this page -# current_page: a page object for the currently displayed page --# num_pages: total number of pages +-# total_pages: total number of pages -# per_page: number of items to fetch per page -# remote: data-remote %span{:class => "page#{' current' if page.current?}"} diff --git a/app/views/kaminari/_page.html.slim b/app/views/kaminari/_page.html.slim index b1babb1..b21f545 100644 --- a/app/views/kaminari/_page.html.slim +++ b/app/views/kaminari/_page.html.slim @@ -3,7 +3,7 @@ page : a page object for "this" page url : url to this page current_page : a page object for the currently displayed page - num_pages : total number of pages + total_pages : total number of pages per_page : number of items to fetch per page remote : data-remote span class="page#{' current' if page.current?}" diff --git a/app/views/kaminari/_paginator.html.erb b/app/views/kaminari/_paginator.html.erb index aad45ef..4fb445f 100644 --- a/app/views/kaminari/_paginator.html.erb +++ b/app/views/kaminari/_paginator.html.erb @@ -1,7 +1,7 @@ <%# The container tag - available local variables current_page: a page object for the currently displayed page - num_pages: total number of pages + total_pages: total number of pages per_page: number of items to fetch per page remote: data-remote paginator: the paginator that renders the pagination tags inside diff --git a/app/views/kaminari/_paginator.html.haml b/app/views/kaminari/_paginator.html.haml index 1bf1884..4f33e2d 100644 --- a/app/views/kaminari/_paginator.html.haml +++ b/app/views/kaminari/_paginator.html.haml @@ -1,7 +1,7 @@ -# The container tag -# available local variables -# current_page: a page object for the currently displayed page --# num_pages: total number of pages +-# total_pages: total number of pages -# per_page: number of items to fetch per page -# remote: data-remote -# paginator: the paginator that renders the pagination tags inside diff --git a/app/views/kaminari/_paginator.html.slim b/app/views/kaminari/_paginator.html.slim index d51f0a1..6a587d7 100644 --- a/app/views/kaminari/_paginator.html.slim +++ b/app/views/kaminari/_paginator.html.slim @@ -1,7 +1,7 @@ / The container tag - available local variables current_page : a page object for the currently displayed page - num_pages : total number of pages + total_pages : total number of pages per_page : number of items to fetch per page remote : data-remote paginator : the paginator that renders the pagination tags inside diff --git a/app/views/kaminari/_prev_page.html.erb b/app/views/kaminari/_prev_page.html.erb index 4e94c8a..b9b4da8 100644 --- a/app/views/kaminari/_prev_page.html.erb +++ b/app/views/kaminari/_prev_page.html.erb @@ -2,7 +2,7 @@ - available local variables url: url to the previous page current_page: a page object for the currently displayed page - num_pages: total number of pages + total_pages: total number of pages per_page: number of items to fetch per page remote: data-remote -%> diff --git a/app/views/kaminari/_prev_page.html.haml b/app/views/kaminari/_prev_page.html.haml index 13f0d8a..43c869b 100644 --- a/app/views/kaminari/_prev_page.html.haml +++ b/app/views/kaminari/_prev_page.html.haml @@ -2,7 +2,7 @@ -# available local variables -# url: url to the previous page -# current_page: a page object for the currently displayed page --# num_pages: total number of pages +-# total_pages: total number of pages -# per_page: number of items to fetch per page -# remote: data-remote %span.prev diff --git a/app/views/kaminari/_prev_page.html.slim b/app/views/kaminari/_prev_page.html.slim index 8f37596..5e0533d 100644 --- a/app/views/kaminari/_prev_page.html.slim +++ b/app/views/kaminari/_prev_page.html.slim @@ -2,7 +2,7 @@ - available local variables url : url to the previous page current_page : a page object for the currently displayed page - num_pages : total number of pages + total_pages : total number of pages per_page : number of items to fetch per page remote : data-remote span.prev diff --git a/lib/kaminari/helpers/action_view_extension.rb b/lib/kaminari/helpers/action_view_extension.rb index 60520a7..0d6d808 100644 --- a/lib/kaminari/helpers/action_view_extension.rb +++ b/lib/kaminari/helpers/action_view_extension.rb @@ -15,7 +15,7 @@ module Kaminari # * :remote - Ajax? (false by default) # * :ANY_OTHER_VALUES - Any other hash key & values would be directly passed into each tag as :locals value. def paginate(scope, options = {}, &block) - paginator = Kaminari::Helpers::Paginator.new self, options.reverse_merge(:current_page => scope.current_page, :num_pages => scope.num_pages, :per_page => scope.limit_value, :param_name => Kaminari.config.param_name, :remote => false) + paginator = Kaminari::Helpers::Paginator.new self, options.reverse_merge(:current_page => scope.current_page, :total_pages => scope.total_pages, :per_page => scope.limit_value, :param_name => Kaminari.config.param_name, :remote => false) paginator.to_s end @@ -101,7 +101,7 @@ module Kaminari end entry_name = entry_name.pluralize unless collection.total_count == 1 - if collection.num_pages < 2 + if collection.total_pages < 2 t('helpers.page_entries_info.one_page.display_entries', :entry_name => entry_name, :count => collection.total_count) else first = collection.offset_value + 1 diff --git a/lib/kaminari/helpers/paginator.rb b/lib/kaminari/helpers/paginator.rb index 88c91ad..c7c3217 100644 --- a/lib/kaminari/helpers/paginator.rb +++ b/lib/kaminari/helpers/paginator.rb @@ -29,7 +29,7 @@ module Kaminari # render given block as a view template def render(&block) - instance_eval(&block) if @options[:num_pages] > 1 + instance_eval(&block) if @options[:total_pages] > 1 @output_buffer end @@ -50,10 +50,10 @@ module Kaminari def relevant_pages(options) left_window_plus_one = 1.upto(options[:left] + 1).to_a - right_window_plus_one = (options[:num_pages] - options[:right]).upto(options[:num_pages]).to_a + right_window_plus_one = (options[:total_pages] - options[:right]).upto(options[:total_pages]).to_a inside_window_plus_each_sides = (options[:current_page] - options[:window] - 1).upto(options[:current_page] + options[:window] + 1).to_a - (left_window_plus_one + inside_window_plus_each_sides + right_window_plus_one).uniq.sort.reject {|x| (x < 1) || (x > options[:num_pages])} + (left_window_plus_one + inside_window_plus_each_sides + right_window_plus_one).uniq.sort.reject {|x| (x < 1) || (x > options[:total_pages])} end private :relevant_pages @@ -114,7 +114,7 @@ module Kaminari # the last page or not def last? - @page == @options[:num_pages] + @page == @options[:total_pages] end # the previous page or not @@ -134,7 +134,7 @@ module Kaminari # within the right outer window or not def right_outer? - @options[:num_pages] - @page < @options[:right] + @options[:total_pages] - @page < @options[:right] end # inside the inner window or not diff --git a/lib/kaminari/helpers/sinatra_helpers.rb b/lib/kaminari/helpers/sinatra_helpers.rb index ab2d19d..ae12cde 100644 --- a/lib/kaminari/helpers/sinatra_helpers.rb +++ b/lib/kaminari/helpers/sinatra_helpers.rb @@ -82,7 +82,7 @@ module Kaminari::Helpers current_params = Rack::Utils.parse_query(env['QUERY_STRING']).symbolize_keys rescue {} paginator = Kaminari::Helpers::Paginator.new( ActionViewTemplateProxy.new(:current_params => current_params, :current_path => current_path, :param_name => options[:param_name] || Kaminari.config.param_name), - options.reverse_merge(:current_page => scope.current_page, :num_pages => scope.num_pages, :per_page => scope.limit_value, :param_name => Kaminari.config.param_name, :remote => false) + options.reverse_merge(:current_page => scope.current_page, :total_pages => scope.total_pages, :per_page => scope.limit_value, :param_name => Kaminari.config.param_name, :remote => false) ) paginator.to_s end diff --git a/lib/kaminari/helpers/tags.rb b/lib/kaminari/helpers/tags.rb index 844b736..2acbdc8 100644 --- a/lib/kaminari/helpers/tags.rb +++ b/lib/kaminari/helpers/tags.rb @@ -68,7 +68,7 @@ module Kaminari class LastPage < Tag include Link def page #:nodoc: - @options[:num_pages] + @options[:total_pages] end end diff --git a/lib/kaminari/models/page_scope_methods.rb b/lib/kaminari/models/page_scope_methods.rb index 273f983..2bf87ad 100644 --- a/lib/kaminari/models/page_scope_methods.rb +++ b/lib/kaminari/models/page_scope_methods.rb @@ -15,7 +15,7 @@ module Kaminari end # Total number of pages - def num_pages + def total_pages (total_count.to_f / limit_value).ceil end @@ -31,7 +31,7 @@ module Kaminari # Last page of the collection? def last_page? - current_page >= num_pages + current_page >= total_pages end end end diff --git a/spec/helpers/helpers_spec.rb b/spec/helpers/helpers_spec.rb index d1ff21d..20c08e3 100644 --- a/spec/helpers/helpers_spec.rb +++ b/spec/helpers/helpers_spec.rb @@ -35,13 +35,13 @@ describe 'Kaminari::Helpers::Paginator' do # end # context '1 page in total' do -# subject { tags_with :num_pages => 1, :current_page => 1 } +# subject { tags_with :total_pages => 1, :current_page => 1 } # it { should have(0).tags } # end # context '10 pages in total' do # context 'first page' do -# subject { tags_with :num_pages => 10, :current_page => 1 } +# subject { tags_with :total_pages => 10, :current_page => 1 } # it { should_not contain_tag PrevLink } # it { should contain_tag PrevSpan } # it { should contain_tag CurrentPage } @@ -54,7 +54,7 @@ describe 'Kaminari::Helpers::Paginator' do # end # context 'second page' do -# subject { tags_with :num_pages => 10, :current_page => 2 } +# subject { tags_with :total_pages => 10, :current_page => 2 } # it { should contain_tag PrevLink } # it { should_not contain_tag PrevSpan } # it { should contain_tag CurrentPage } @@ -67,7 +67,7 @@ describe 'Kaminari::Helpers::Paginator' do # end # context 'third page' do -# subject { tags_with :num_pages => 10, :current_page => 3 } +# subject { tags_with :total_pages => 10, :current_page => 3 } # it { should contain_tag PrevLink } # it { should_not contain_tag PrevSpan } # it { should contain_tag CurrentPage } @@ -80,7 +80,7 @@ describe 'Kaminari::Helpers::Paginator' do # end # context 'fourth page(no truncation)' do -# subject { tags_with :num_pages => 10, :current_page => 4 } +# subject { tags_with :total_pages => 10, :current_page => 4 } # it { should contain_tag PrevLink } # it { should_not contain_tag PrevSpan } # it { should contain_tag CurrentPage } @@ -93,7 +93,7 @@ describe 'Kaminari::Helpers::Paginator' do # end # context 'seventh page(no truncation)' do -# subject { tags_with :num_pages => 10, :current_page => 7 } +# subject { tags_with :total_pages => 10, :current_page => 7 } # it { should contain_tag PrevLink } # it { should_not contain_tag PrevSpan } # it { should contain_tag CurrentPage } @@ -106,7 +106,7 @@ describe 'Kaminari::Helpers::Paginator' do # end # context 'eighth page' do -# subject { tags_with :num_pages => 10, :current_page => 8 } +# subject { tags_with :total_pages => 10, :current_page => 8 } # it { should contain_tag PrevLink } # it { should_not contain_tag PrevSpan } # it { should contain_tag CurrentPage } @@ -119,7 +119,7 @@ describe 'Kaminari::Helpers::Paginator' do # end # context 'last page' do -# subject { tags_with :num_pages => 10, :current_page => 10 } +# subject { tags_with :total_pages => 10, :current_page => 10 } # it { should contain_tag PrevLink } # it { should_not contain_tag PrevSpan } # it { should contain_tag CurrentPage } diff --git a/spec/helpers/tags_spec.rb b/spec/helpers/tags_spec.rb index f8a96d3..54e18f9 100644 --- a/spec/helpers/tags_spec.rb +++ b/spec/helpers/tags_spec.rb @@ -28,11 +28,11 @@ describe 'Kaminari::Helpers' do describe '#last?' do context 'current_page == page' do - subject { Paginator::PageProxy.new({:num_pages => 39}, 39, nil) } + subject { Paginator::PageProxy.new({:total_pages => 39}, 39, nil) } its(:last?) { should be_true } end context 'current_page != page' do - subject { Paginator::PageProxy.new({:num_pages => 39}, 38, nil) } + subject { Paginator::PageProxy.new({:total_pages => 39}, 38, nil) } its(:last?) { should_not be_true } end end @@ -75,16 +75,16 @@ describe 'Kaminari::Helpers' do end describe '#right_outer?' do - context 'num_pages - page > right' do - subject { Paginator::PageProxy.new({:num_pages => 10, :right => 3}, 6, nil) } + context 'total_pages - page > right' do + subject { Paginator::PageProxy.new({:total_pages => 10, :right => 3}, 6, nil) } its(:right_outer?) { should_not be_true } end - context 'num_pages - page == right' do - subject { Paginator::PageProxy.new({:num_pages => 10, :right => 3}, 7, nil) } + context 'total_pages - page == right' do + subject { Paginator::PageProxy.new({:total_pages => 10, :right => 3}, 7, nil) } its(:right_outer?) { should_not be_true } end - context 'num_pages - page < right' do - subject { Paginator::PageProxy.new({:num_pages => 10, :right => 3}, 8, nil) } + context 'total_pages - page < right' do + subject { Paginator::PageProxy.new({:total_pages => 10, :right => 3}, 8, nil) } its(:right_outer?) { should be_true } end end diff --git a/spec/models/active_record/scopes_spec.rb b/spec/models/active_record/scopes_spec.rb index 3b4e99d..2911e2f 100644 --- a/spec/models/active_record/scopes_spec.rb +++ b/spec/models/active_record/scopes_spec.rb @@ -68,35 +68,35 @@ if defined? ActiveRecord end end - describe '#num_pages' do + describe '#total_pages' do context 'per 25 (default)' do subject { model_class.page } - its(:num_pages) { should == 4 } + its(:total_pages) { should == 4 } end context 'per 7' do subject { model_class.page(2).per(7) } - its(:num_pages) { should == 15 } + its(:total_pages) { should == 15 } end context 'per 65536' do subject { model_class.page(50).per(65536) } - its(:num_pages) { should == 1 } + its(:total_pages) { should == 1 } end context 'per 0 (using default)' do subject { model_class.page(50).per(0) } - its(:num_pages) { should == 4 } + its(:total_pages) { should == 4 } end context 'per -1 (using default)' do subject { model_class.page(5).per(-1) } - its(:num_pages) { should == 4 } + its(:total_pages) { should == 4 } end context 'per "String value that can not be converted into Number" (using default)' do subject { model_class.page(5).per('aho') } - its(:num_pages) { should == 4 } + its(:total_pages) { should == 4 } end end @@ -153,7 +153,7 @@ if defined? ActiveRecord subject { model_class.group('age').page(2).per 5 } # 0..10 its(:total_count) { should == 11 } - its(:num_pages) { should == 3 } + its(:total_pages) { should == 3 } end context 'activerecord descendants' do diff --git a/spec/models/array_spec.rb b/spec/models/array_spec.rb index a95c68c..489c620 100644 --- a/spec/models/array_spec.rb +++ b/spec/models/array_spec.rb @@ -56,35 +56,35 @@ describe Kaminari::PaginatableArray do end end - describe '#num_pages' do + describe '#total_pages' do context 'per 25 (default)' do subject { array.page } - its(:num_pages) { should == 4 } + its(:total_pages) { should == 4 } end context 'per 7' do subject { array.page(2).per(7) } - its(:num_pages) { should == 15 } + its(:total_pages) { should == 15 } end context 'per 65536' do subject { array.page(50).per(65536) } - its(:num_pages) { should == 1 } + its(:total_pages) { should == 1 } end context 'per 0 (using default)' do subject { array.page(50).per(0) } - its(:num_pages) { should == 4 } + its(:total_pages) { should == 4 } end context 'per -1 (using default)' do subject { array.page(5).per(-1) } - its(:num_pages) { should == 4 } + its(:total_pages) { should == 4 } end context 'per "String value that can not be converted into Number" (using default)' do subject { array.page(5).per('aho') } - its(:num_pages) { should == 4 } + its(:total_pages) { should == 4 } end end diff --git a/spec/models/data_mapper/data_mapper_spec.rb b/spec/models/data_mapper/data_mapper_spec.rb index 640952a..70fa931 100644 --- a/spec/models/data_mapper/data_mapper_spec.rb +++ b/spec/models/data_mapper/data_mapper_spec.rb @@ -35,7 +35,7 @@ if defined? DataMapper its('query.limit') { should == 25 } its('query.offset') { should == 0 } its(:total_count) { should == User.count(:age.gte => 60) } - its(:num_pages) { should == 2 } + its(:total_pages) { should == 2 } end context 'page 1' do @@ -45,7 +45,7 @@ if defined? DataMapper its('query.limit') { should == 25 } its('query.offset') { should == 0 } its(:total_count) { should == 100 } - its(:num_pages) { should == 4 } + its(:total_pages) { should == 4 } end context 'page 2' do @@ -56,7 +56,7 @@ if defined? DataMapper its('query.limit') { should == 25 } its('query.offset') { should == 25 } its(:total_count) { should == 100 } - its(:num_pages) { should == 4 } + its(:total_pages) { should == 4 } end context 'page "foobar"' do @@ -66,7 +66,7 @@ if defined? DataMapper its('query.limit') { should == 25 } its('query.offset') { should == 0 } its(:total_count) { should == 100 } - its(:num_pages) { should == 4 } + its(:total_pages) { should == 4 } end context 'with criteria before' do @@ -76,7 +76,7 @@ if defined? DataMapper its('query.limit') { should == 25 } its('query.offset') { should == 25 } its(:total_count) { should == User.count(:age.gt => 60) } - its(:num_pages) { should == 2 } + its(:total_pages) { should == 2 } end context 'with criteria after' do @@ -86,7 +86,7 @@ if defined? DataMapper its('query.limit') { should == 25 } its('query.offset') { should == 25 } its(:total_count) { should == User.count(:age.gt => 60) } - its(:num_pages) { should == 2 } + its(:total_pages) { should == 2 } end end @@ -99,7 +99,7 @@ if defined? DataMapper its(:limit_value) { should == 20 } its('query.offset') { should == 20 } its(:total_count) { should == 100 } - its(:num_pages) { should == 5 } + its(:total_pages) { should == 5 } end context 'on query with condition' do @@ -108,7 +108,7 @@ if defined? DataMapper its('query.limit') { should == 13 } its('query.offset') { should == 52 } its(:total_count) { should == 81 } - its(:num_pages) { should == 7 } + its(:total_pages) { should == 7 } end context 'on query with order' do @@ -121,7 +121,7 @@ if defined? DataMapper its('query.limit') { should == 13 } its('query.offset') { should == 52 } its(:total_count) { should == 81 } - its(:num_pages) { should == 7 } + its(:total_pages) { should == 7 } end context 'on chained queries' do @@ -130,7 +130,7 @@ if defined? DataMapper its('query.limit') { should == 13 } its('query.offset') { should == 26 } its(:total_count) { should == 31 } - its(:num_pages) { should == 3 } + its(:total_pages) { should == 3 } end context 'on query on association' do @@ -139,7 +139,7 @@ if defined? DataMapper its('query.limit') { should == 5 } its('query.offset') { should == 10 } its(:total_count) { should == 50 } - its(:num_pages) { should == 10 } + its(:total_pages) { should == 10 } end context 'on query with association conditions' do @@ -148,7 +148,7 @@ if defined? DataMapper its('query.limit') { should == 5 } its('query.offset') { should == 10 } its(:total_count) { should == 50 } - its(:num_pages) { should == 10 } + its(:total_pages) { should == 10 } end end end diff --git a/spec/models/mongo_mapper/mongo_mapper_spec.rb b/spec/models/mongo_mapper/mongo_mapper_spec.rb index cd1f814..833781e 100644 --- a/spec/models/mongo_mapper/mongo_mapper_spec.rb +++ b/spec/models/mongo_mapper/mongo_mapper_spec.rb @@ -13,7 +13,7 @@ if defined? MongoMapper it { should be_a Plucky::Query } its(:current_page) { should == 1 } its(:limit_value) { should == 25 } - its(:num_pages) { should == 2 } + its(:total_pages) { should == 2 } it { should skip(0) } end @@ -22,7 +22,7 @@ if defined? MongoMapper it { should be_a Plucky::Query } its(:current_page) { should == 2 } its(:limit_value) { should == 25 } - its(:num_pages) { should == 2 } + its(:total_pages) { should == 2 } it { should skip 25 } end @@ -31,7 +31,7 @@ if defined? MongoMapper it { should be_a Plucky::Query } its(:current_page) { should == 1 } its(:limit_value) { should == 25 } - its(:num_pages) { should == 2 } + its(:total_pages) { should == 2 } it { should skip 0 } end @@ -43,7 +43,7 @@ if defined? MongoMapper subject { User.where(:salary => 1).page 2 } its(:current_page) { should == 2 } its(:limit_value) { should == 25 } - its(:num_pages) { should == 2 } + its(:total_pages) { should == 2 } it { should skip 25 } end @@ -55,7 +55,7 @@ if defined? MongoMapper subject { User.page(2).where(:salary => 1) } its(:current_page) { should == 2 } its(:limit_value) { should == 25 } - its(:num_pages) { should == 2 } + its(:total_pages) { should == 2 } it { should skip 25 } end end @@ -65,7 +65,7 @@ if defined? MongoMapper it { should be_a Plucky::Query } its(:current_page) { should == 2 } its(:limit_value) { should == 10 } - its(:num_pages) { should == 5 } + its(:total_pages) { should == 5 } it { should skip 10 } end end diff --git a/spec/models/mongoid/mongoid_spec.rb b/spec/models/mongoid/mongoid_spec.rb index c27bb00..7bebbf4 100644 --- a/spec/models/mongoid/mongoid_spec.rb +++ b/spec/models/mongoid/mongoid_spec.rb @@ -15,7 +15,7 @@ if defined? Mongoid it { should be_a Mongoid::Criteria } its(:current_page) { should == 1 } its(:limit_value) { should == 25 } - its(:num_pages) { should == 2 } + its(:total_pages) { should == 2 } it { should skip(0) } end @@ -24,7 +24,7 @@ if defined? Mongoid it { should be_a Mongoid::Criteria } its(:current_page) { should == 2 } its(:limit_value) { should == 25 } - its(:num_pages) { should == 2 } + its(:total_pages) { should == 2 } it { should skip 25 } end @@ -33,7 +33,7 @@ if defined? Mongoid it { should be_a Mongoid::Criteria } its(:current_page) { should == 1 } its(:limit_value) { should == 25 } - its(:num_pages) { should == 2 } + its(:total_pages) { should == 2 } it { should skip 0 } end @@ -45,7 +45,7 @@ if defined? Mongoid end its(:current_page) { should == 2 } its(:limit_value) { should == 25 } - its(:num_pages) { should == 2 } + its(:total_pages) { should == 2 } it { should skip 25 } end @@ -65,7 +65,7 @@ if defined? Mongoid it { should be_a Mongoid::Criteria } its(:current_page) { should == 2 } its(:limit_value) { should == 10 } - its(:num_pages) { should == 5 } + its(:total_pages) { should == 5 } it { should skip 10 } end @@ -85,7 +85,7 @@ if defined? Mongoid its(:total_count) { should == 5 } its(:limit_value) { should == 1 } its(:current_page) { should == 1 } - its(:num_pages) { should == 5 } + its(:total_pages) { should == 5 } end context 'with criteria after' do @@ -94,7 +94,7 @@ if defined? Mongoid its(:total_count) { should == 3 } its(:limit_value) { should == 2 } its(:current_page) { should == 1 } - its(:num_pages) { should == 2 } + its(:total_pages) { should == 2 } end context 'with criteria before' do @@ -103,7 +103,7 @@ if defined? Mongoid its(:total_count) { should == 3 } its(:limit_value) { should == 2 } its(:current_page) { should == 1 } - its(:num_pages) { should == 2 } + its(:total_pages) { should == 2 } end end end