diff options
author | Louise Crow <louise.crow@gmail.com> | 2013-09-30 10:31:54 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2013-09-30 10:31:54 +0100 |
commit | 666a7a0b53974ce5bd545d1e69a50aa46b59ee79 (patch) | |
tree | 25310c11de6e8b3c024d7788d3658f7ca01740bd | |
parent | fea5f1580608abf81f14c960f590b9395c9edaf8 (diff) | |
parent | b597d3528ac71d17c57d3ddca9950a4430f75039 (diff) |
Merge branch 'hotfix/0.14.0.1' into wdtk
-rw-r--r-- | app/models/outgoing_message.rb | 2 | ||||
-rw-r--r-- | spec/models/outgoing_message_spec.rb | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb index e89c11141..e2ee696c5 100644 --- a/app/models/outgoing_message.rb +++ b/app/models/outgoing_message.rb @@ -271,7 +271,7 @@ class OutgoingMessage < ActiveRecord::Base end def format_of_body - if self.body.empty? || self.body =~ /\A#{get_salutation}\s+#{get_signoff}/ || self.body =~ /#{get_internal_review_insert_here_note}/ + if self.body.empty? || self.body =~ /\A#{Regexp.escape(get_salutation)}\s+#{Regexp.escape(get_signoff)}/ || self.body =~ /#{Regexp.escape(get_internal_review_insert_here_note)}/ if self.message_type == 'followup' if self.what_doing == 'internal_review' errors.add(:body, _("Please give details explaining why you want a review")) diff --git a/spec/models/outgoing_message_spec.rb b/spec/models/outgoing_message_spec.rb index 1e05e09f1..20f07e8fe 100644 --- a/spec/models/outgoing_message_spec.rb +++ b/spec/models/outgoing_message_spec.rb @@ -163,3 +163,13 @@ describe IncomingMessage, " when censoring data" do @om.body.should match(/fancy cat/) end end + +describe OutgoingMessage, "when validating the format of the message body", :focus => true do + + it 'should handle a salutation with a bracket in it' do + outgoing_message = FactoryGirl.build(:initial_request) + outgoing_message.stub!(:get_salutation).and_return("Dear Bob (Robert,") + lambda{ outgoing_message.valid? }.should_not raise_error(RegexpError) + end + +end |