aboutsummaryrefslogtreecommitdiffstats
path: root/spec/integration/create_request_spec.rb
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2013-09-17 17:39:51 +0100
committerLouise Crow <louise.crow@gmail.com>2013-09-17 17:39:51 +0100
commit6fbcb461025dc315d688038d9f0a8e138d00ba33 (patch)
tree628ad3d7bf9cb2310bc2bed2e94b8670532a0dd4 /spec/integration/create_request_spec.rb
parentabde5e4a1139c41c6db23ce041fba090674f65ac (diff)
parentf41ec6d1cb167058a808b7820da5345c6da962fd (diff)
Merge branch 'feature/hide-individual-responses' into rails-3-develop
Conflicts: Gemfile app/views/admin_request/edit_outgoing.html.erb config/packages doc/CHANGES.md doc/INSTALL.md spec/models/info_request_spec.rb spec/models/public_body_spec.rb
Diffstat (limited to 'spec/integration/create_request_spec.rb')
-rw-r--r--spec/integration/create_request_spec.rb45
1 files changed, 15 insertions, 30 deletions
diff --git a/spec/integration/create_request_spec.rb b/spec/integration/create_request_spec.rb
index 4efbf94ee..84fad12f9 100644
--- a/spec/integration/create_request_spec.rb
+++ b/spec/integration/create_request_spec.rb
@@ -1,51 +1,36 @@
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require File.expand_path(File.dirname(__FILE__) + '/alaveteli_dsl')
describe "When creating requests" do
- def create_request_unregistered
- params = { :info_request => { :public_body_id => public_bodies(:geraldine_public_body).id,
- :title => "Why is your quango called Geraldine?",
- :tag_string => "" },
- :outgoing_message => { :body => "This is a silly letter. It is too short to be interesting." },
- :submitted_new_request => 1,
- :preview => 0
- }
-
- # Initially we are not logged in. Try to create a new request.
- post "/new", params
- # We expect to be redirected to the login page
- post_redirect = PostRedirect.get_last_post_redirect
- response.should redirect_to(:controller => 'user', :action => 'signin', :token => post_redirect.token)
- follow_redirect!
- response.should render_template("user/sign")
- response.body.should match(/To send your FOI request, please sign in or make a new account./)
- end
+
it "should associate the request with the requestor, even if it is approved by an admin" do
+
+ unregistered = without_login
# This is a test for https://github.com/mysociety/alaveteli/issues/446
- create_request_unregistered
+ unregistered.creates_request_unregistered
post_redirect = PostRedirect.get_last_post_redirect
# Now log in as an unconfirmed user.
- post "/profile/sign_in", :user_signin => {:email => users(:unconfirmed_user).email, :password => "jonespassword"}, :token => post_redirect.token
+ unregistered.post "/profile/sign_in", :user_signin => {:email => users(:unconfirmed_user).email, :password => "jonespassword"}, :token => post_redirect.token
# This will trigger a confirmation mail. Get the PostRedirect for later.
- response.should render_template("user/confirm")
+ unregistered.response.body.should match('Now check your email!')
post_redirect = PostRedirect.get_last_post_redirect
+
# Now log in as an admin user, then follow the confirmation link in the email that was sent to the unconfirmed user
- admin_user = users(:admin_user)
- admin_user.email_confirmed = true
- admin_user.save!
- post_via_redirect "/profile/sign_in", :user_signin => {:email => admin_user.email, :password => "jonespassword"}
- response.should be_success
- get "/c/" + post_redirect.email_token
- follow_redirect!
- response.location.should =~ %r(/request/(.+)/new)
- response.location =~ %r(/request/(.+)/new)
+ confirm(:admin_user)
+ 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)
url_title = $1
info_request = InfoRequest.find_by_url_title(url_title)
info_request.should_not be_nil
# Make sure the request is still owned by the user who made it, not the admin who confirmed it
info_request.user_id.should == users(:unconfirmed_user).id
+
end
end