aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortony <tony>2009-05-09 07:46:59 +0000
committertony <tony>2009-05-09 07:46:59 +0000
commit8835337c3a6b00d6f384b874730497b655aadd10 (patch)
tree69afa9460cc2f0e3fba2a76f518c217f78e4c083
parent9522d882a3cc43a55cab5935d7fbd22cdec25517 (diff)
Link redactions of email address and mobile phone numbers to the help
pages about this.
-rw-r--r--app/models/incoming_message.rb3
-rw-r--r--app/models/outgoing_message.rb3
-rw-r--r--spec/models/outgoing_message_spec.rb4
3 files changed, 8 insertions, 2 deletions
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb
index 8903b8c01..2b4469856 100644
--- a/app/models/incoming_message.rb
+++ b/app/models/incoming_message.rb
@@ -19,7 +19,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: incoming_message.rb,v 1.202 2009-04-27 02:25:31 francis Exp $
+# $Id: incoming_message.rb,v 1.203 2009-05-09 07:46:59 tony Exp $
# TODO
# Move some of the (e.g. quoting) functions here into rblib, as they feel
@@ -908,6 +908,7 @@ class IncomingMessage < ActiveRecord::Base
text = MySociety::Format.simplify_angle_bracketed_urls(text)
text = CGI.escapeHTML(text)
text = MySociety::Format.make_clickable(text, :contract => 1)
+ text.gsub!(/\[(email address|mobile number)\]/, '[<a href="/help/about#mobiles">\1</a>]')
if collapse_quoted_sections
text = text.gsub(/(\s*FOLDED_QUOTED_SECTION\s*)+/m, "FOLDED_QUOTED_SECTION")
text.strip!
diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb
index 5d81e5361..116dc5059 100644
--- a/app/models/outgoing_message.rb
+++ b/app/models/outgoing_message.rb
@@ -22,7 +22,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: outgoing_message.rb,v 1.83 2009-04-13 09:18:48 tony Exp $
+# $Id: outgoing_message.rb,v 1.84 2009-05-09 07:46:59 tony Exp $
class OutgoingMessage < ActiveRecord::Base
strip_attributes!
@@ -215,6 +215,7 @@ class OutgoingMessage < ActiveRecord::Base
text = MySociety::Format.wrap_email_body(text) # reparagraph and wrap it so is good preview of emails
text = CGI.escapeHTML(text)
text = MySociety::Format.make_clickable(text, :contract => 1)
+ text.gsub!(/\[(email address|mobile number)\]/, '[<a href="/help/about#mobiles">\1</a>]')
text = text.gsub(/\n/, '<br>')
return text
end
diff --git a/spec/models/outgoing_message_spec.rb b/spec/models/outgoing_message_spec.rb
index 14acf6ca0..32705ce9d 100644
--- a/spec/models/outgoing_message_spec.rb
+++ b/spec/models/outgoing_message_spec.rb
@@ -20,6 +20,10 @@ describe OutgoingMessage, " when making an outgoing message" do
@outgoing_message.get_body_for_html_display.should_not include("foo@bar.com")
end
+ it "should link to help page where email address was" do
+ @outgoing_message.get_body_for_html_display.should have_tag('a[href="/help/about#mobiles"]', :text => 'email address')
+ end
+
it "should include email addresses in outgoing messages" do
@outgoing_message.body.should include("foo@bar.com")
end