Sha256: db6e3e00e2d427792f17c055af6be0c4bf4e8b17d86dc6c34e6c30dd331d75b9

Contents?: true

Size: 1.63 KB

Versions: 1

Compression:

Stored size: 1.63 KB

Contents

require "spec_helper"

describe Paginate::Renderer do
  before do
    Paginate.setup do |config|
      config.param_name = :page
      config.size  = 10
    end

    I18n.locale = :en

    @renderer = Paginate::Renderer.new({
      :collection => Array.new(11),
      :page => 1,
      :fullpath => "/some/path"
    })
  end

  specify { @renderer.render.should be_html_safe }

  it "should parse simple url" do
    @renderer.options[:url] = "/some/path"
    @renderer.url_for(1).should == "/some/path?page=1"
  end

  it "should parse url with page param" do
    @renderer.options[:url] = "/some/path?page=3"
    @renderer.url_for(1).should == "/some/path?page=1"
  end

  it "should parse url with page as first param" do
    @renderer.options[:url] = "/some/path?page=3&a=1&b=2&c=3"
    @renderer.url_for(1).should == "/some/path?a=1&b=2&c=3&page=1"
  end

  it "should parse url with page as last param" do
    @renderer.options[:url] = "/some/path?a=1&b=2&c=3&page=3"
    @renderer.url_for(1).should == "/some/path?a=1&b=2&c=3&page=1"
  end

  it "should parse url with page param in the middle" do
    @renderer.options[:url] = "/some/path?a=1&b=2&page=3&c=3"
    @renderer.url_for(1).should == "/some/path?a=1&b=2&c=3&page=1"
  end

  it "should parse url with page as arbitrary string" do
    @renderer.options[:url] = "/some/path?a=1&b=2&c=3&page=abc"
    @renderer.url_for(1).should == "/some/path?a=1&b=2&c=3&page=1"
  end

  it "should escape url from blocks" do
    @renderer.options[:url] = proc {|page| "/some/path/#{page}?a=1&b=2"}
    @renderer.url_for(1).should == "/some/path/1?a=1&b=2"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
paginate-1.0.0 spec/paginate/renderer_spec.rb