Sha256: 27937b959827e073f1b13e3eb4c81b5c93599adcd38e3d2e2c7b2f758a810254

Contents?: true

Size: 942 Bytes

Versions: 6

Compression:

Stored size: 942 Bytes

Contents

require 'test_helper'

class PaginationTest < Test::Unit::TestCase
  attr_reader :routes, :params

  def setup
    @routes = draw_routes do
      filter :pagination
      match 'some', :to => 'some#index'
    end
    @params = { :controller => 'some', :action => 'index', :page => 2 }
  end

  test 'recognizes the path some/page/2' do
    assert_equal params, routes.recognize_path('/some/page/2')
  end

  test 'appends the segments /page/:page to the generated path if the passed :page param does not equal 1' do
    assert_equal '/some/page/2', routes.generate(params)
  end

  test 'does not append anything to the generated path if the passed :page param equals 1' do
    assert_equal '/some', routes.generate(params.merge(:page => 1))
  end

  test 'appends the segments /page/:page to the generated path but respects url query params' do
    assert_equal '/some/page/2?foo=bar', routes.generate(params.merge(:foo => 'bar'))
  end
end

Version data entries

6 entries across 6 versions & 4 rubygems

Version Path
routing-filter-0.2.4 test/filters/pagination_test.rb
sayso-routing-filter-0.2.2.001 test/filters/pagination_test.rb
vigetlabs-routing-filter-0.2.4 test/filters/pagination_test.rb
aratak-routing-filter-0.2.4 test/filters/pagination_test.rb
routing-filter-0.2.3 test/filters/pagination_test.rb
routing-filter-0.2.2 test/filters/pagination_test.rb