aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2012-11-20 19:02:13 +0000
committerLouise Crow <louise.crow@gmail.com>2012-11-20 19:02:13 +0000
commit0227bdc1d7a91adeac07757234d4e77045433fff (patch)
tree82020bd247b74e846d524c2cf6b9c66336df75db
parent75927f8684a1aa0bf89479306e8adce384781e64 (diff)
Restore explanatory messages when asked to sign in for actions that don't require an existing user. Fixes #719.
-rw-r--r--app/views/user/sign.rhtml17
-rw-r--r--spec/integration/create_request_spec.rb35
2 files changed, 34 insertions, 18 deletions
diff --git a/app/views/user/sign.rhtml b/app/views/user/sign.rhtml
index 4704ea95a..6a1979155 100644
--- a/app/views/user/sign.rhtml
+++ b/app/views/user/sign.rhtml
@@ -1,16 +1,16 @@
+
<% if !@post_redirect.nil? && @post_redirect.reason_params[:user_name] %>
<% @title = _("Sign in") %>
-
<div id="sign_alone">
<p id="sign_in_reason">
<% if @post_redirect.reason_params[:web].empty? %>
<%= _('Please sign in as ')%><%= link_to h(@post_redirect.reason_params[:user_name]), @post_redirect.reason_params[:user_url] %>.
<% else %>
- <%= @post_redirect.reason_params[:web] %>,
+ <%= @post_redirect.reason_params[:web] %>,
<%= _('please sign in as ')%><%= link_to h(@post_redirect.reason_params[:user_name]), @post_redirect.reason_params[:user_url] %>.
<% end %>
- </p>
+ </p>
<% if @post_redirect.post_params["controller"] == "admin_general" %>
<p id="superuser_message">Don't have a superuser account yet? <%= link_to "Sign in as the emergency user", @post_redirect.uri + "?emergency=1" %></p>
<% end %>
@@ -22,7 +22,16 @@
<% else %>
<% @title = _('Sign in or make a new account') %>
- <div id="sign_together">
+ <div id="sign_together">
+ <% if !@post_redirect.nil? %>
+ <p id="sign_in_reason">
+ <% if @post_redirect.reason_params[:web].empty? %>
+ <%= _('Please sign in or make a new account.') %>
+ <% else %>
+ <%= _('{{reason}}, please sign in or make a new account.', :reason => @post_redirect.reason_params[:web]) %>
+ <% end %>
+ </p>
+ <% end %>
<div id="left_half">
<h1><%= _('Sign in') %></h1>
<%= render :partial => 'signin', :locals => { :sign_in_as_existing_user => false } %>
diff --git a/spec/integration/create_request_spec.rb b/spec/integration/create_request_spec.rb
index 56757c7e0..4efbf94ee 100644
--- a/spec/integration/create_request_spec.rb
+++ b/spec/integration/create_request_spec.rb
@@ -1,23 +1,30 @@
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe "When creating requests" do
- it "should associate the request with the requestor, even if it is approved by an admin" do
- # This is a test for https://github.com/mysociety/alaveteli/issues/446
- 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
- }
+ 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")
+ # 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
+ # This is a test for https://github.com/mysociety/alaveteli/issues/446
+ create_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
# This will trigger a confirmation mail. Get the PostRedirect for later.