aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfrancis <francis>2008-01-04 15:27:18 +0000
committerfrancis <francis>2008-01-04 15:27:18 +0000
commitf30b34ecfd7c9916ee9b9034d5c4cd4cc7b42746 (patch)
treecee22b79f864fc769352fb9fac6613a8dbe03fc3
parent26c033ba9e7cc0211881d0e388d05423567a81e4 (diff)
On second thoughts, use hidden field to mark submission of the form.
-rw-r--r--app/controllers/request_controller.rb5
-rw-r--r--app/views/request/new.rhtml1
-rw-r--r--spec/controllers/request_controller_spec.rb15
3 files changed, 13 insertions, 8 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 26318ef7d..21af0d8b0 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -4,7 +4,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: request_controller.rb,v 1.28 2008-01-04 15:12:32 francis Exp $
+# $Id: request_controller.rb,v 1.29 2008-01-04 15:27:18 francis Exp $
class RequestController < ApplicationController
@@ -25,7 +25,8 @@ class RequestController < ApplicationController
# Page new form posts to
def new
- if params[:info_request].nil? || params[:outgoing_message].nil?
+ # First time we get to the page, not everything is filled in
+ if params[:submitted_new_request].nil?
# Read parameters in - public body can be passed from front page
@info_request = InfoRequest.new(params[:info_request])
@outgoing_message = OutgoingMessage.new(params[:outgoing_message])
diff --git a/app/views/request/new.rhtml b/app/views/request/new.rhtml
index b14e40f1d..499745fee 100644
--- a/app/views/request/new.rhtml
+++ b/app/views/request/new.rhtml
@@ -50,6 +50,7 @@
</p>
<div class="form_button">
+ <%= hidden_field_tag(:submitted_new_request, { :value => 1 } ) %>
<%= submit_tag "Create public request >>" %>
</div>
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index a6668c7e1..94892081c 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -101,16 +101,17 @@ describe RequestController, "when creating a new request" do
end
it "should give an error and render 'new' template when a summary isn't given" do
- post :new, :info_request => { :public_body_id => public_bodies(:geraldine_public_body).id
- },
- :outgoing_message => { :body => "This is a silly letter. It is too short to be interesting." }
+ post :new, :info_request => { :public_body_id => public_bodies(:geraldine_public_body).id },
+ :outgoing_message => { :body => "This is a silly letter. It is too short to be interesting." },
+ :submitted_new_request => 1
response.should render_template('new')
end
it "should redirect to sign in page when input is good and nobody is logged in" do
params = { :info_request => { :public_body_id => public_bodies(:geraldine_public_body).id,
:title => "Why is your quango called Geraldine?"},
- :outgoing_message => { :body => "This is a silly letter. It is too short to be interesting." }
+ :outgoing_message => { :body => "This is a silly letter. It is too short to be interesting." },
+ :submitted_new_request => 1
}
post :new, params
# XXX yeuch - no other easy way of getting the token so we can check
@@ -127,7 +128,8 @@ describe RequestController, "when creating a new request" do
session[:user_id] = users(:bob_smith_user).id
post :new, :info_request => { :public_body_id => public_bodies(:geraldine_public_body).id,
:title => "Why is your quango called Geraldine?"},
- :outgoing_message => { :body => "This is a silly letter. It is too short to be interesting." }
+ :outgoing_message => { :body => "This is a silly letter. It is too short to be interesting." },
+ :submitted_new_request => 1
ir_array = InfoRequest.find(:all, :conditions => ["title = ?", "Why is your quango called Geraldine?"])
ir_array.size.should == 1
ir = ir_array[0]
@@ -140,7 +142,8 @@ describe RequestController, "when creating a new request" do
it "should give an error if the same request is submitted twice" do
post :new, :info_request => { :public_body_id => info_requests(:fancy_dog_request).public_body_id,
:title => info_requests(:fancy_dog_request).title},
- :outgoing_message => { :body => info_requests(:fancy_dog_request).outgoing_messages[0].body}
+ :outgoing_message => { :body => info_requests(:fancy_dog_request).outgoing_messages[0].body},
+ :submitted_new_request => 1
response.should render_template('new')
end
end