test/paginate/renderer_test.rb in paginate-0.1.1 vs test/paginate/renderer_test.rb in paginate-0.1.2
- old
+ new
@@ -31,6 +31,41 @@
string.expects(:html_safe).never
String.expects(:new).returns(string)
@renderer.render
end
+
+ def test_simple_url
+ @renderer.options[:url] = "/some/path"
+ assert_equal "/some/path?page=1", @renderer.url_for(1)
+ end
+
+ def test_simple_url_with_page_param
+ @renderer.options[:url] = "/some/path?page=3"
+ assert_equal "/some/path?page=1", @renderer.url_for(1)
+ end
+
+ def test_simple_url_with_page_as_first_param
+ @renderer.options[:url] = "/some/path?page=3&a=1&b=2&c=3"
+ assert_equal "/some/path?a=1&b=2&c=3&page=1", @renderer.url_for(1)
+ end
+
+ def test_simple_url_with_page_as_last_param
+ @renderer.options[:url] = "/some/path?a=1&b=2&c=3&page=3"
+ assert_equal "/some/path?a=1&b=2&c=3&page=1", @renderer.url_for(1)
+ end
+
+ def test_simple_url_with_page_param_in_the_middle
+ @renderer.options[:url] = "/some/path?a=1&b=2&page=3&c=3"
+ assert_equal "/some/path?a=1&b=2&c=3&page=1", @renderer.url_for(1)
+ end
+
+ def test_simple_url_with_page_as_text
+ @renderer.options[:url] = "/some/path?a=1&b=2&c=3&page=abc"
+ assert_equal "/some/path?a=1&b=2&c=3&page=1", @renderer.url_for(1)
+ end
+
+ def test_escape_url_from_blocks
+ @renderer.options[:url] = proc {|page| "/some/path/#{page}?a=1&b=2"}
+ assert_equal "/some/path/1?a=1&b=2", @renderer.url_for(1)
+ end
end
\ No newline at end of file