aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2013-06-20 16:06:17 -0700
committerLouise Crow <louise.crow@gmail.com>2013-06-20 16:06:17 -0700
commitad619c00329fb79f8e227622bb1c0ba5db303ea2 (patch)
treefdfdc704d78674c10884bf1b8109f81976791cc2
parentc1b3324922687778b316ee1a180582013bcf6d0e (diff)
Use request.params to generate a json format url when @has_json is true, not request.query_parameters. The latter has unexpected results when a querystring parameter of 'action' or 'controller' is supplied. Fixes #981.
-rw-r--r--app/views/layouts/default.html.erb2
-rw-r--r--spec/integration/view_request_spec.rb7
2 files changed, 8 insertions, 1 deletions
diff --git a/app/views/layouts/default.html.erb b/app/views/layouts/default.html.erb
index 32ea5e4ff..688816fa9 100644
--- a/app/views/layouts/default.html.erb
+++ b/app/views/layouts/default.html.erb
@@ -33,7 +33,7 @@
<% end %>
<% end %>
<% if @has_json %>
- <link rel="alternate" type="application/json" title="JSON version of this page" href="<%=h url_for(request.query_parameters.merge(:format => 'json')) %>">
+ <link rel="alternate" type="application/json" title="JSON version of this page" href="<%=h url_for(request.params.merge(:format => 'json')) %>">
<% end %>
<% if @no_crawl %>
diff --git a/spec/integration/view_request_spec.rb b/spec/integration/view_request_spec.rb
index 442721890..3d646cfe7 100644
--- a/spec/integration/view_request_spec.rb
+++ b/spec/integration/view_request_spec.rb
@@ -13,5 +13,12 @@ describe "When viewing requests" do
response.body.should include("dog.json?unfold=1")
end
+ it 'should not raise a routing error when making a json link for a request with an
+ "action" querystring param' do
+ @dog_request = info_requests(:fancy_dog_request)
+ get "request/#{@dog_request.url_title}?action=add"
+ response.should be_success
+ end
+
end