diff --git a/app/assets/javascripts/supplier/translations.js.erb b/app/assets/javascripts/supplier/translations.js.erb index a9d2d020..faecaf05 100644 --- a/app/assets/javascripts/supplier/translations.js.erb +++ b/app/assets/javascripts/supplier/translations.js.erb @@ -12,6 +12,7 @@ var $translations = { <%= I18n.t('supplier', locale: :nl).to_json[1..-2] %> } } + $transformation_mappings = { downcase: 'toLowerCase', upcase: 'toUpperCase' diff --git a/app/assets/stylesheets/supplier/structure.css.sass b/app/assets/stylesheets/supplier/structure.css.sass index 957c92b5..fd78de03 100644 --- a/app/assets/stylesheets/supplier/structure.css.sass +++ b/app/assets/stylesheets/supplier/structure.css.sass @@ -18,6 +18,13 @@ body padding-bottom: 0 .main-content padding-top: 16px + label + &.number + display: inline + padding: 4px 10px + input + &.number + width: 40px .supplier-is-closed .alert form diff --git a/app/controllers/suppliers/tables_controller.rb b/app/controllers/suppliers/tables_controller.rb index 1a3cea4a..77667a68 100644 --- a/app/controllers/suppliers/tables_controller.rb +++ b/app/controllers/suppliers/tables_controller.rb @@ -3,7 +3,7 @@ module Suppliers # GET /tables # GET /tables.json def index - @tables = current_supplier.tables + @tables = Table.for_supplier(current_supplier, page: params[:page], per_page: params[:per_page] || 25, from_number: params[:from_number], to_number: params[:to_number]) respond_to do |format| format.html # index.html.erb diff --git a/app/models/supplier.rb b/app/models/supplier.rb index 33795ae8..a148bfcf 100644 --- a/app/models/supplier.rb +++ b/app/models/supplier.rb @@ -31,7 +31,6 @@ class Supplier has_many :sections, dependent: :destroy after_create :add_section_on_create - after_create :send_creation_notifications view :by_email, key: :email @@ -39,7 +38,7 @@ class Supplier validates :iens_profile, numericality: {allow_blank: true} def location=(val) - lat, lng = val.strip.split(/[ ,]+/).map(&:to_f) + lat, lng = val.is_a?(Array) ? val : val.strip.split(/[ ,]+/).map(&:to_f) self.lat = lat self.lng = lng end @@ -88,14 +87,29 @@ class Supplier self.open = false save end + + + # Find a user by its confirmation token and try to confirm it. + # If no user is found, returns a new user with an error. + # If the user is already confirmed, create an error for the user + # Options must have the confirmation_token + # + # Overwrite devise method for mail sending + def self.confirm_by_token(confirmation_token) + confirmable = find_or_initialize_with_error_by(:confirmation_token, confirmation_token) + confirmable.confirm! if confirmable.persisted? + confirmable.send_creation_notifications if confirmable.errors.empty? + confirmable + end + + def send_creation_notifications + SupplierMailer.creation(self).deliver + end private def add_section_on_create @section = Section.create supplier: self, title: I18n.t('supplier.section.first_section_title') end - def send_creation_notifications - SupplierMailer.creation(self).deliver - end end diff --git a/app/models/table.rb b/app/models/table.rb index 09c1bbec..f54ca156 100644 --- a/app/models/table.rb +++ b/app/models/table.rb @@ -1,5 +1,6 @@ class Table include SimplyStored::Couch + per_page_method :limit_value #kaminari property :number, type: Fixnum, default: 1 property :position_x, type: Float @@ -21,8 +22,16 @@ class Table view :by_number, key: :number def self.for_supplier(supplier, options = {}) - startkey = options[:from_number].present? ? [supplier.id, options.delete(:from_number).to_i] : [supplier.id] - endkey = options[:to_number].present? ? [supplier.id, options.delete(:to_number).to_i]: [supplier.id, {}] + startkey = if from_number = options.delete(:from_number).presence + [supplier.id, from_number.to_i] + else + [supplier.id] + end + endkey = if to_number = options.delete(:to_number).presence + [supplier.id, to_number.to_i] + else + [supplier.id, {}] + end total_entries = database.view(by_supplier_id_and_number({startkey: startkey, endkey: endkey, include_docs: false, reduce: true})) options[:total_entries] = total_entries diff --git a/app/views/admin/lists/index.html.slim b/app/views/admin/lists/index.html.slim index 7cee85c4..18b6144a 100644 --- a/app/views/admin/lists/index.html.slim +++ b/app/views/admin/lists/index.html.slim @@ -11,7 +11,7 @@ div.page-header= title :index, model_class th= Table.model_name.human th= Supplier.model_name.human th= model_class.human_attribute_name(:created_at) - th=t 'helpers.actions' + th=t 'helpers.actions.title' tbody - @lists.each do |list| tr diff --git a/app/views/admin/orders/index.html.slim b/app/views/admin/orders/index.html.slim index edfc332e..8d55c612 100644 --- a/app/views/admin/orders/index.html.slim +++ b/app/views/admin/orders/index.html.slim @@ -7,7 +7,7 @@ div.page-header= title :index, model_class th= model_class.human_attribute_name(:state) th= Supplier.model_name.human th= model_class.human_attribute_name(:created_at) - th=t 'helpers.actions' + th=t 'helpers.actions.title' tbody - @orders.each do |order| tr diff --git a/app/views/admin/product_categories/index.html.slim b/app/views/admin/product_categories/index.html.slim index 0db1f9d5..8964d32a 100644 --- a/app/views/admin/product_categories/index.html.slim +++ b/app/views/admin/product_categories/index.html.slim @@ -8,7 +8,7 @@ th= model_class.human_attribute_name(:position) th= Supplier.model_name.human th.timestamp= model_class.human_attribute_name(:created_at) - th.actions=t 'helpers.actions' + th.actions=t 'helpers.actions.title' tbody - @product_categories.each do |product_category| tr diff --git a/app/views/admin/products/index.html.slim b/app/views/admin/products/index.html.slim index 00fb17c0..8b7751c9 100644 --- a/app/views/admin/products/index.html.slim +++ b/app/views/admin/products/index.html.slim @@ -9,7 +9,7 @@ th= model_class.human_attribute_name(:price) th= Supplier.model_name.human th.timestamp= model_class.human_attribute_name(:created_at) - th.actions=t 'helpers.actions' + th.actions=t 'helpers.actions.title' tbody - @products.each do |product| tr diff --git a/app/views/admin/sections/index.html.slim b/app/views/admin/sections/index.html.slim index 02b8f83d..0c4c0e60 100644 --- a/app/views/admin/sections/index.html.slim +++ b/app/views/admin/sections/index.html.slim @@ -7,7 +7,7 @@ th= model_class.human_attribute_name(:title) th= Supplier.model_name.human th= model_class.human_attribute_name(:created_at) - th=t 'helpers.actions' + th=t 'helpers.actions.title' tbody - @sections.each do |section| tr diff --git a/app/views/admin/suppliers/index.html.slim b/app/views/admin/suppliers/index.html.slim index 2698b7ba..babe77ca 100644 --- a/app/views/admin/suppliers/index.html.slim +++ b/app/views/admin/suppliers/index.html.slim @@ -7,7 +7,7 @@ th= model_class.human_attribute_name(:email) th= model_class.human_attribute_name(:name) th= model_class.human_attribute_name(:created_at) - th=t 'helpers.actions' + th=t 'helpers.actions.title' tbody - @suppliers.each do |supplier| tr diff --git a/app/views/admin/tables/index.html.slim b/app/views/admin/tables/index.html.slim index c6e844a3..bca066f1 100644 --- a/app/views/admin/tables/index.html.slim +++ b/app/views/admin/tables/index.html.slim @@ -7,7 +7,7 @@ div.page-header= title :index, model_class th= model_class.human_attribute_name(:number) th= Supplier.model_name.human th= model_class.human_attribute_name(:created_at) - th=t 'helpers.actions' + th=t 'helpers.actions.title' tbody - @tables.each do |table| tr diff --git a/app/views/admin/users/index.html.slim b/app/views/admin/users/index.html.slim index d5734dc6..df3ddb80 100644 --- a/app/views/admin/users/index.html.slim +++ b/app/views/admin/users/index.html.slim @@ -6,7 +6,7 @@ tr th= model_class.human_attribute_name(:email) th= model_class.human_attribute_name(:created_at) - th=t 'helpers.actions' + th=t 'helpers.actions.title' tbody - @users.each do |user| tr diff --git a/app/views/suppliers/_links.html.slim b/app/views/devise/_links.html.slim similarity index 100% rename from app/views/suppliers/_links.html.slim rename to app/views/devise/_links.html.slim diff --git a/app/views/suppliers/lists/index.html.slim b/app/views/suppliers/lists/index.html.slim index b697d4cf..67bab240 100644 --- a/app/views/suppliers/lists/index.html.slim +++ b/app/views/suppliers/lists/index.html.slim @@ -14,7 +14,7 @@ form action='' method="get" th= Table.model_name.human th.currency= model_class.human_attribute_name(:price) th.timestamp= model_class.human_attribute_name(:created_at) - th.actions=t 'helpers.actions' + th.actions=t 'helpers.actions.title' tbody - @lists.each do |list| tr diff --git a/app/views/suppliers/products/index.html.slim b/app/views/suppliers/products/index.html.slim index 6e4f4d6d..d28849a9 100644 --- a/app/views/suppliers/products/index.html.slim +++ b/app/views/suppliers/products/index.html.slim @@ -5,12 +5,12 @@ table.table thead tr - th= model_class.human_attribute_name(:name) - th= model_class.human_attribute_name(:code) - th.currency= model_class.human_attribute_name(:price) - th= ProductCategory.model_name.human_plural - th.timestamp= model_class.human_attribute_name(:created_at) - th.actions=t 'helpers.actions' + th data-t="attributes.product.name" = model_class.human_attribute_name(:name) + th data-t="attributes.product.code" = model_class.human_attribute_name(:code) + th.currency data-t="attributes.product.price" = model_class.human_attribute_name(:price) + th data-t="models.product_category" = ProductCategory.model_name.human_plural + th.timestamp data-t="attributes.product.created_at" = model_class.human_attribute_name(:created_at) + th.actions data-t="helpers.actions.title" =t 'helpers.actions.title' tbody - @products.each do |product| tr @@ -26,4 +26,4 @@ - else = no_content_given model_class = link_to t("helpers.links.new"), new_suppliers_product_path(product_category_id: @product_category.try(:id)), class: 'btn btn-primary' - +/a.btn.btn-primary data-t="helpers.links.new" href=new_suppliers_product_path diff --git a/app/views/suppliers/registrations/new.html.slim b/app/views/suppliers/registrations/new.html.slim index 4c70a247..0dd0684a 100644 --- a/app/views/suppliers/registrations/new.html.slim +++ b/app/views/suppliers/registrations/new.html.slim @@ -1,4 +1,8 @@ h2= t('devise.registrations.title') +p + | + Leuk dat je je wilt aanmelden voor Qwaiter. Na de aanmelding zal er een bevestigings e-mail worden gestuurd + om het e-mailadres te bevestigen. Hierna kan je aan de slag met mobiel bestellen! = form_for(resource, :as => resource_name, :url => registration_path(resource_name), html: {class: 'form-horizontal'}) do |f| = devise_error_messages! .control-group diff --git a/app/views/suppliers/sections/index.html.slim b/app/views/suppliers/sections/index.html.slim index af6e222c..35963be4 100644 --- a/app/views/suppliers/sections/index.html.slim +++ b/app/views/suppliers/sections/index.html.slim @@ -10,7 +10,7 @@ th.numeric data-t='attributes.section.width' = model_class.human_attribute_name(:width) th.numeric data-t='attributes.section.height' = model_class.human_attribute_name(:height) th.timestamp data-t='attributes.section.created_at' = model_class.human_attribute_name(:created_at) - th.actions data-t='helpers.actions' = t 'helpers.actions' + th.actions data-t='helpers.actions.title' = t 'helpers.actions.title' tbody - @sections.each do |section| tr diff --git a/app/views/suppliers/tables/index.html.slim b/app/views/suppliers/tables/index.html.slim index 1478b6f6..0fa5bca0 100644 --- a/app/views/suppliers/tables/index.html.slim +++ b/app/views/suppliers/tables/index.html.slim @@ -1,14 +1,22 @@ - model_class = Table div.page-header= title :index, model_class += form_tag({}, method: :get) do + label.number for="filter-from_number" data-t="attributes.table.from_number" + input#filter-from_number.number type="number" size=4 value=params[:from_number] name="from_number" + label.number for="filter-to_number" data-t="attributes.table.to_number" + input#filter-to_number.number type="number" size=4 value=params[:to_number] name="to_number" + ' + = submit_tag 'Filter' .well - if @tables.any? + = paginate @tables table.table thead tr th.link data-t="attributes.table.number"= model_class.human_attribute_name(:number) th.link data-t="models.section"= Section.model_name.human th.timestamp data-t="attributes.table.created_at"= model_class.human_attribute_name(:created_at) - th.actions data-t="helpers.actions"=t 'helpers.actions' + th.actions data-t="helpers.actions.title"=t 'helpers.actions.title' tbody - @tables.each do |table| tr diff --git a/app/views/users/_links.html.slim b/app/views/users/_links.html.slim deleted file mode 100644 index 689d28c9..00000000 --- a/app/views/users/_links.html.slim +++ /dev/null @@ -1,19 +0,0 @@ -ul.nav.nav-pills - - if controller_name != 'sessions' - li= link_to t('devise.sessions.button'), new_session_path(resource_name), class: [:devise, :btn] - - - if devise_mapping.registerable? && controller_name != 'registrations' - li= link_to t('devise.registrations.button'), new_registration_path(resource_name), class: [:devise, :btn] - - - if devise_mapping.recoverable? && controller_name != 'passwords' - li= link_to t('devise.sessions.forgot_your_password'), new_password_path(resource_name), class: [:devise, :btn] - - - if devise_mapping.confirmable? && controller_name != 'confirmations' - li= link_to t('devise.confirmations.did_not_receive_instructions_link'), new_confirmation_path(resource_name), class: [:devise, :btn] - - - if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' - li= link_to t('devise.unlocks.did_not_receive_instructions_link'), new_unlock_path(resource_name), class: [:devise, :btn] - - - if devise_mapping.omniauthable? - - resource_class.omniauth_providers.each do |provider| - li= link_to t('devise.omniauth_callbacks.sign_in_with', provider: provider.to_s.titleize), omniauth_authorize_path(resource_name, provider), class: [:devise, :btn] diff --git a/config/environments/development.rb b/config/environments/development.rb index ed6ddb02..9f43a7e2 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -22,7 +22,7 @@ Qwaiter::Application.configure do # Don't care if the mailer can't send config.action_mailer.raise_delivery_errors = false - #config.action_mailer.delivery_method = :letter_opener + config.action_mailer.delivery_method = :letter_opener config.action_mailer.default_url_options = { host: 'localhost', port: 3000 diff --git a/config/locales/devise.nl.yml b/config/locales/devise.nl.yml index 931fa64e..dff32c55 100644 --- a/config/locales/devise.nl.yml +++ b/config/locales/devise.nl.yml @@ -37,7 +37,7 @@ nl: send_instructions_button: Stuur mij reset instructies confirmations: send_instructions: 'Er wordt een een e-mail naar je toe gestuurd waarin je je account kan bevestigen.' - confirmed: 'De activatie van je account is successvol. Je bent nu aangemeld!' + confirmed: 'De activatie van je account is succesvol. Je bent nu aangemeld!' did_not_receive_instructions_link: "Heeft u geen bevestigingsinstructies ontvangen?" did_not_receive: 'Heeft u geen bevestigingsinstructies ontvangen?' registrations: diff --git a/config/locales/en.yml b/config/locales/en.yml index cb80293d..e32aeb13 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -30,6 +30,8 @@ en: submit: 'Save %{model}' list: no_records: There are no items present + actions: + title: Actions messages: cannot_order_on_non_active_list: You cannot place an order on a closed list no_active_list: There is no active list diff --git a/config/locales/models.en.yml b/config/locales/models.en.yml index a40767a7..49d46d3b 100644 --- a/config/locales/models.en.yml +++ b/config/locales/models.en.yml @@ -1,3 +1,4 @@ +en: activemodel: models: user: User @@ -19,7 +20,10 @@ section: Sections attributes: product: + name: Name + code: Code price: Price + created_at: Created list: created_at: Created state: Status @@ -32,3 +36,8 @@ password: 'Password' password_confirmation: 'Confirmation' iens_profile: Iens profile id + table: + number: Number + from_number: From number + to_number: To number + created_at: Created diff --git a/config/locales/models.nl.yml b/config/locales/models.nl.yml index ccfc3f13..a2dc912e 100644 --- a/config/locales/models.nl.yml +++ b/config/locales/models.nl.yml @@ -20,7 +20,10 @@ nl: section: Afdelingen attributes: product: + name: Naam + code: Code price: Prijs + created_at: Aangemaakt list: created_at: Aangemaakt state: Status @@ -38,3 +41,8 @@ nl: password: 'Wachtwoord' password_confirmation: 'Bevestiging' iens_profile: Iens profiel id + table: + number: Nummer + from_number: Vanaf nummer + to_number: Tot nummer + created_at: Aangemaakt diff --git a/config/locales/nl.yml b/config/locales/nl.yml index eea1b875..0bb36011 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -29,6 +29,8 @@ nl: submit: '%{model} opslaan' list: no_records: Er zijn geen items aanwezig + actions: + title: Acties messages: cannot_order_on_non_active_list: Je kan niet bestellen op een gesloten lijst no_active_list: Er is momenteel geen lijst actief diff --git a/spec/acceptance/suppliers/product_categories_spec.rb b/spec/acceptance/suppliers/product_categories_spec.rb index 3e4505d1..4ab9ea18 100644 --- a/spec/acceptance/suppliers/product_categories_spec.rb +++ b/spec/acceptance/suppliers/product_categories_spec.rb @@ -2,11 +2,11 @@ require 'acceptance/acceptance_helper' feature 'Supplier product categories spec', %q{ In order to manage product categories - As a supplier + As a confirmed supplier I want to have control over product categories and associated products } do background do - create_supplier 'supplier@qwaiter.com' + create_confirmed_supplier 'supplier@qwaiter.com' end context "GET #index" do background do diff --git a/spec/acceptance/suppliers/supplier_main_board_spec.rb_spec.rb b/spec/acceptance/suppliers/supplier_main_board_spec.rb_spec.rb index a68249f6..7dea3994 100644 --- a/spec/acceptance/suppliers/supplier_main_board_spec.rb_spec.rb +++ b/spec/acceptance/suppliers/supplier_main_board_spec.rb_spec.rb @@ -2,12 +2,12 @@ require 'acceptance/acceptance_helper' feature 'Supplier main board spec.rb', %q{ In order to manage active lists and orders - As a supplier + As a confirmed supplier I want to have control over lists and orders from the main activity panel } do background do CouchPotato.couchrest_database.recreate! - create_supplier 'supplier@qwaiter.com' + create_confirmed_supplier 'supplier@qwaiter.com' create_user 'user@qwaiter.com' end diff --git a/spec/acceptance/support/helpers.rb b/spec/acceptance/support/helpers.rb index bf7e2989..10b8c062 100644 --- a/spec/acceptance/support/helpers.rb +++ b/spec/acceptance/support/helpers.rb @@ -8,6 +8,11 @@ module HelperMethods @supplier = Supplier.find_by_email(email) || FactoryGirl.create(:supplier, email: email, password: password) end + def create_confirmed_supplier(email, password='secret') + @supplier = Supplier.find_by_email(email) || FactoryGirl.create(:supplier, :confirmed, email: email, password: password) + @supplier.confirm! unless @supplier.confirmed? + end + def login_user_as(email) visit "/users/sign_in" fill_in "user_email", with: email diff --git a/spec/controllers/suppliers/lists_controller_spec.rb b/spec/controllers/suppliers/lists_controller_spec.rb index 5b46e969..199f3250 100644 --- a/spec/controllers/suppliers/lists_controller_spec.rb +++ b/spec/controllers/suppliers/lists_controller_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Suppliers::ListsController do before :each do - @supplier = Supplier.find_by_email('supplier@qwaiter.com') || Supplier.create(name: 'Supplier', email: 'supplier@qwaiter.com', password: 'secret') + @supplier = Supplier.find_by_email('supplier@qwaiter.com') || create(:supplier, :confirmed) sign_in @supplier end diff --git a/spec/controllers/suppliers/product_categories_controller_spec.rb b/spec/controllers/suppliers/product_categories_controller_spec.rb index f98ce70b..fa119fc3 100644 --- a/spec/controllers/suppliers/product_categories_controller_spec.rb +++ b/spec/controllers/suppliers/product_categories_controller_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Suppliers::ProductCategoriesController do before :each do - @supplier = Supplier.find_by_email('supplier@qwaiter.com') || Supplier.create(name: 'Supplier', email: 'supplier@qwaiter.com', password: 'secret') + @supplier = Supplier.find_by_email('supplier@qwaiter.com') || create(:supplier, :confirmed) sign_in @supplier end diff --git a/spec/controllers/suppliers/products_controller_spec.rb b/spec/controllers/suppliers/products_controller_spec.rb index f6019f2d..488dbc83 100644 --- a/spec/controllers/suppliers/products_controller_spec.rb +++ b/spec/controllers/suppliers/products_controller_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Suppliers::ProductsController do before :each do - @supplier = Supplier.find_by_email('supplier@qwaiter.com') || Supplier.create(name: 'Supplier', email: 'supplier@qwaiter.com', password: 'secret') + @supplier = Supplier.find_by_email('supplier@qwaiter.com') || create(:supplier, :confirmed) sign_in @supplier end diff --git a/spec/controllers/suppliers/sections_controller_spec.rb b/spec/controllers/suppliers/sections_controller_spec.rb index 14acba42..59689c54 100644 --- a/spec/controllers/suppliers/sections_controller_spec.rb +++ b/spec/controllers/suppliers/sections_controller_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Suppliers::SectionsController do before :each do - @supplier = Supplier.find_by_email('supplier@qwaiter.com') || Supplier.create(name: 'Supplier', email: 'supplier@qwaiter.com', password: 'secret') + @supplier = Supplier.find_by_email('supplier@qwaiter.com') || create(:supplier, :confirmed) sign_in @supplier end diff --git a/spec/controllers/suppliers/tables_controller_spec.rb b/spec/controllers/suppliers/tables_controller_spec.rb index 3c8155fd..595274c5 100644 --- a/spec/controllers/suppliers/tables_controller_spec.rb +++ b/spec/controllers/suppliers/tables_controller_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Suppliers::TablesController do before :each do - @supplier = Supplier.find_by_email('supplier@qwaiter.com') || Supplier.create(name: 'Supplier', email: 'supplier@qwaiter.com', password: 'secret') + @supplier = Supplier.find_by_email('supplier@qwaiter.com') || create(:supplier, :confirmed) sign_in @supplier end diff --git a/spec/factories/supplier_factory.rb b/spec/factories/supplier_factory.rb index d8e323c9..d8e0fce1 100644 --- a/spec/factories/supplier_factory.rb +++ b/spec/factories/supplier_factory.rb @@ -1,6 +1,12 @@ FactoryGirl.define do factory :supplier do sequence(:name){|i| "Supplier #{i}"} + email 'supplier@qwaiter.com' password 'secret' + + trait :confirmed do + confirmed_at { Time.now } + + end end end diff --git a/spec/models/table_spec.rb b/spec/models/table_spec.rb index 4831f981..50d3a12f 100644 --- a/spec/models/table_spec.rb +++ b/spec/models/table_spec.rb @@ -16,7 +16,6 @@ describe Table do @table2 = create :table, supplier: supplier, number: 4 @table3 = create :table, supplier: supplier, number: 6 @table4 = create :table, number: 4 - end it "returns all by default" do subject.should == [@table1, @table2, @table3] @@ -26,6 +25,22 @@ describe Table do options[:per_page] = 2 subject.size.should == 2 subject.total_count.should == 3 + end + + it "should filter by table number using from_number" do + options[:per_page] = 1 + options[:from_number] = 3 + subject.size.should == 1 + subject.total_pages.should == 2 + subject.first.number.should == 4 + + end + it "should filter by table number using from_number and to_number" do + options[:from_number] = 3 + options[:to_number] = 5 + subject.size.should == 1 + subject.total_pages.should == 1 + subject.first.number.should == 4 end end