Skip to content

Commit

Permalink
Deprecate show_new_request named route
Browse files Browse the repository at this point in the history
No reason to use this over show_request.
Redirects old URL path to show_request_path
  • Loading branch information
garethrees committed Jan 7, 2015
1 parent bd1c11a commit 5d61441
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/controllers/request_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ def new
<p>If you write about this request (for example in a forum or a blog) please link to this page, and add an
annotation below telling people about your writing.</p>",:law_used_full=>@info_request.law_used_full,
:late_number_of_days => AlaveteliConfiguration::reply_late_after_days)
redirect_to show_new_request_path(:url_title => @info_request.url_title)
redirect_to show_request_path(:url_title => @info_request.url_title)
end

# Submitted to the describing state of messages form
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
match '/request/search_ahead' => 'request#search_typeahead', :as => :search_ahead

match '/request/:url_title' => 'request#show', :as => :show_request
match '/request/:url_title/new' => 'request#show', :as => :show_new_request
match "/request/:url_title/new" => redirect("/request/%{url_title}")
match '/details/request/:url_title' => 'request#details', :as => :details_request
match '/similar/request/:url_title' => 'request#similar', :as => :similar_request

Expand Down
16 changes: 8 additions & 8 deletions spec/controllers/request_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1067,10 +1067,10 @@ def expect_hidden(hidden_template)
mail = deliveries[0]
mail.body.should =~ /This is a silly letter. It is too short to be interesting./

response.should redirect_to show_new_request_url(:url_title => ir.url_title)
response.should redirect_to show_request_url(:url_title => ir.url_title)
# This test uses an explicit path because it's relied in
# Google Analytics goals:
response.redirect_url.should =~ /request\/why_is_your_quango_called_gerald\/new$/
response.redirect_url.should =~ /request\/why_is_your_quango_called_gerald$/
end

it "should give an error if the same request is submitted twice" do
Expand Down Expand Up @@ -1105,7 +1105,7 @@ def expect_hidden(hidden_template)

ir.url_title.should_not == ir2.url_title

response.should redirect_to show_new_request_url(:url_title => ir2.url_title)
response.should redirect_to show_request_url(:url_title => ir2.url_title)
end

it 'should respect the rate limit' do
Expand All @@ -1117,14 +1117,14 @@ def expect_hidden(hidden_template)
:title => "What is the answer to the ultimate question?", :tag_string => "" },
:outgoing_message => { :body => "Please supply the answer from your files." },
:submitted_new_request => 1, :preview => 0
response.should redirect_to show_new_request_url(:url_title => 'what_is_the_answer_to_the_ultima')
response.should redirect_to show_request_url(:url_title => 'what_is_the_answer_to_the_ultima')


post :new, :info_request => { :public_body_id => @body.id,
:title => "Why did the chicken cross the road?", :tag_string => "" },
:outgoing_message => { :body => "Please send me all the relevant documents you hold." },
:submitted_new_request => 1, :preview => 0
response.should redirect_to show_new_request_url(:url_title => 'why_did_the_chicken_cross_the_ro')
response.should redirect_to show_request_url(:url_title => 'why_did_the_chicken_cross_the_ro')

post :new, :info_request => { :public_body_id => @body.id,
:title => "What's black and white and red all over?", :tag_string => "" },
Expand All @@ -1144,20 +1144,20 @@ def expect_hidden(hidden_template)
:title => "What is the answer to the ultimate question?", :tag_string => "" },
:outgoing_message => { :body => "Please supply the answer from your files." },
:submitted_new_request => 1, :preview => 0
response.should redirect_to show_new_request_url(:url_title => 'what_is_the_answer_to_the_ultima')
response.should redirect_to show_request_url(:url_title => 'what_is_the_answer_to_the_ultima')


post :new, :info_request => { :public_body_id => @body.id,
:title => "Why did the chicken cross the road?", :tag_string => "" },
:outgoing_message => { :body => "Please send me all the relevant documents you hold." },
:submitted_new_request => 1, :preview => 0
response.should redirect_to show_new_request_url(:url_title => 'why_did_the_chicken_cross_the_ro')
response.should redirect_to show_request_url(:url_title => 'why_did_the_chicken_cross_the_ro')

post :new, :info_request => { :public_body_id => @body.id,
:title => "What's black and white and red all over?", :tag_string => "" },
:outgoing_message => { :body => "Please send all minutes of meetings and email records that address this question." },
:submitted_new_request => 1, :preview => 0
response.should redirect_to show_new_request_url(:url_title => 'whats_black_and_white_and_red_al')
response.should redirect_to show_request_url(:url_title => 'whats_black_and_white_and_red_al')
end

end
Expand Down
4 changes: 2 additions & 2 deletions spec/integration/create_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
admin = login(:admin_user)
admin.get "/c/" + post_redirect.email_token
admin.follow_redirect!
admin.response.location.should =~ %r(/request/(.+)/new)
admin.response.location =~ %r(/request/(.+)/new)
admin.response.location.should =~ %r(/request/(.+))
admin.response.location =~ %r(/request/(.+))
url_title = $1
info_request = InfoRequest.find_by_url_title(url_title)
info_request.should_not be_nil
Expand Down

1 comment on commit 5d61441

@crowbot
Copy link
Member

@crowbot crowbot commented on 5d61441 Jan 8, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👎 As indicated in the comment in the spec, the /new url is used to record the completion of the 'Make a new request' goal in google analytics. More details in the original commit message.

Please sign in to comment.