aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/application.rb18
-rw-r--r--app/controllers/user_controller.rb5
-rw-r--r--app/models/post_redirect.rb8
-rw-r--r--app/views/user/contact.rhtml2
4 files changed, 28 insertions, 5 deletions
diff --git a/app/controllers/application.rb b/app/controllers/application.rb
index af3f8de1b..891a505d9 100644
--- a/app/controllers/application.rb
+++ b/app/controllers/application.rb
@@ -6,7 +6,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: application.rb,v 1.30 2008-02-27 12:18:28 francis Exp $
+# $Id: application.rb,v 1.31 2008-03-20 11:58:21 francis Exp $
class ApplicationController < ActionController::Base
@@ -28,6 +28,21 @@ class ApplicationController < ActionController::Base
false
end
+ # Called from test code, is a mimic of User.confirm, for use in following email
+ # links when in controller tests (since we don't have full integration tests that
+ # can work over multiple controllers)0
+ def test_code_redirect_by_email_token(token, controller_example_group)
+ post_redirect = PostRedirect.find_by_email_token(token)
+ if post_redirect.nil?
+ raise "bad token in test code email"
+ end
+ session[:user_id] = post_redirect.user.id
+ session[:user_authtype] = :email
+ params = controller_example_group.params_from(:get, post_redirect.local_part_uri)
+ params.merge(post_redirect.post_params)
+ controller_example_group.get params[:action], params
+ end
+
private
# Check the user is logged in
@@ -112,6 +127,7 @@ class ApplicationController < ActionController::Base
# URL generating functions are needed by all controllers (for redirects)
# and views (for links), so include them into all of both.
include LinkToHelper
+
end
diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb
index 14cc9ac06..40547aafe 100644
--- a/app/controllers/user_controller.rb
+++ b/app/controllers/user_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: user_controller.rb,v 1.39 2008-03-13 12:33:40 francis Exp $
+# $Id: user_controller.rb,v 1.40 2008-03-20 11:58:21 francis Exp $
class UserController < ApplicationController
# Show page about a set of users with same url name
@@ -74,7 +74,8 @@ class UserController < ApplicationController
end
end
- # Followed link in user account confirmation email
+ # Followed link in user account confirmation email.
+ # If you change this, change ApplicationController.test_code_redirect_by_email_token also
def confirm
post_redirect = PostRedirect.find_by_email_token(params[:email_token])
diff --git a/app/models/post_redirect.rb b/app/models/post_redirect.rb
index c2b2383d9..a55e32ce1 100644
--- a/app/models/post_redirect.rb
+++ b/app/models/post_redirect.rb
@@ -25,7 +25,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: post_redirect.rb,v 1.23 2008-03-18 19:18:51 francis Exp $
+# $Id: post_redirect.rb,v 1.24 2008-03-20 11:58:21 francis Exp $
require 'openssl' # for random bytes function
@@ -52,6 +52,12 @@ class PostRedirect < ActiveRecord::Base
YAML.load(self.reason_params_yaml)
end
+ # Extract just local path part, without domain or #
+ def local_part_uri
+ self.uri.match(/^http:\/\/.+?(\/[^#]+)/)
+ return $1
+ end
+
# Makes a random token, suitable for using in URLs e.g confirmation messages.
def self.generate_random_token
bits = 12 * 8
diff --git a/app/views/user/contact.rhtml b/app/views/user/contact.rhtml
index d7cac2a4d..7069b671a 100644
--- a/app/views/user/contact.rhtml
+++ b/app/views/user/contact.rhtml
@@ -23,7 +23,7 @@
</p>
<p>
- <label class="form_label" for="outgoing_message_body">Message:</label>
+ <label class="form_label" for="contact_message">Message:</label>
<%= f.text_area :message, :rows => 10, :cols => 50 %>
</p>