From e7b2e867ff93b4d1daf04b829393ec7d50a27369 Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Wed, 11 Jan 2012 09:24:36 +0000 Subject: Don't choke on unescaped characters in URIs. Fixes #335. --- spec/helpers/link_to_helper_spec.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'spec/helpers/link_to_helper_spec.rb') diff --git a/spec/helpers/link_to_helper_spec.rb b/spec/helpers/link_to_helper_spec.rb index aae00c298..f85d2e70d 100644 --- a/spec/helpers/link_to_helper_spec.rb +++ b/spec/helpers/link_to_helper_spec.rb @@ -20,5 +20,17 @@ describe LinkToHelper do end end + + describe "when appending something to a URL" do + it 'should append to things without query strings' do + main_url('/a', '.json').should == 'http://test.localdomain/a.json' + end + it 'should append to things with query strings' do + main_url('/a?z=1', '.json').should == 'http://test.localdomain/a.json?z=1' + end + it 'should fail silently with invalid URLs' do + main_url('/a?z=9%', '.json').should == 'http://test.localdomain/a?z=9%' + end + end end -- cgit v1.2.3 From 34dad8557132bc730db8e502684f12e4c247c24d Mon Sep 17 00:00:00 2001 From: Robin Houston Date: Fri, 20 Jan 2012 12:10:15 +0000 Subject: Be sure to restore RoutingFilters There were some order-dependent test failures that turned out to be caused by the fact that the RoutingFilters were cleared and not subsequently restored, by some tests. --- spec/helpers/link_to_helper_spec.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'spec/helpers/link_to_helper_spec.rb') diff --git a/spec/helpers/link_to_helper_spec.rb b/spec/helpers/link_to_helper_spec.rb index f85d2e70d..3fa91a8f8 100644 --- a/spec/helpers/link_to_helper_spec.rb +++ b/spec/helpers/link_to_helper_spec.rb @@ -7,9 +7,14 @@ describe LinkToHelper do describe 'when creating a url for a request' do before do - ActionController::Routing::Routes.filters.clear @mock_request = mock_model(InfoRequest, :url_title => 'test_title') + @old_filters = ActionController::Routing::Routes.filters + ActionController::Routing::Routes.filters = RoutingFilter::Chain.new end + after do + ActionController::Routing::Routes.filters = @old_filters + end + it 'should return a path like /request/test_title' do request_url(@mock_request).should == '/request/test_title' -- cgit v1.2.3