From 5d9ffe65d04c9eced48cc4c29ad576b719123b4e Mon Sep 17 00:00:00 2001 From: Ezra Spier Date: Fri, 13 May 2011 07:44:11 -0700 Subject: [PATCH] Don't HTML-escape notice message in err notification email text. --- Gemfile | 1 + Gemfile.lock | 3 +++ app/views/mailer/err_notification.text.erb | 2 +- spec/mailers/mailer_spec.rb | 14 ++++++++++++++ 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 spec/mailers/mailer_spec.rb diff --git a/Gemfile b/Gemfile index 044a001..725d4c6 100644 --- a/Gemfile +++ b/Gemfile @@ -25,4 +25,5 @@ group :test do gem 'rspec', '~> 2.5' gem 'database_cleaner', '~> 0.6.0' gem 'factory_girl_rails' + gem 'email_spec' end diff --git a/Gemfile.lock b/Gemfile.lock index b99c0c6..73cb831 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -47,6 +47,8 @@ GEM bcrypt-ruby (~> 2.1.2) warden (~> 1.0.2) diff-lcs (1.1.2) + email_spec (1.1.1) + rspec (~> 2.0) erubis (2.6.6) abstract (>= 1.0.0) factory_girl (1.3.3) @@ -139,6 +141,7 @@ DEPENDENCIES bson_ext (~> 1.2) database_cleaner (~> 0.6.0) devise (~> 1.1.8) + email_spec factory_girl_rails haml lighthouse-api diff --git a/app/views/mailer/err_notification.text.erb b/app/views/mailer/err_notification.text.erb index dfd8a31..554bf37 100644 --- a/app/views/mailer/err_notification.text.erb +++ b/app/views/mailer/err_notification.text.erb @@ -1,4 +1,4 @@ -An err has just occurred in <%= @notice.err.environment %>: <%= @notice.err.message %> +An err has just occurred in <%= @notice.err.environment %>: <%= raw(@notice.err.message) %> This err has occurred <%= pluralize @notice.err.notices_count, 'time' %>. You should really look into it here: diff --git a/spec/mailers/mailer_spec.rb b/spec/mailers/mailer_spec.rb new file mode 100644 index 0000000..be7c085 --- /dev/null +++ b/spec/mailers/mailer_spec.rb @@ -0,0 +1,14 @@ +require 'spec_helper' + +describe Mailer do + context "Err Notification" do + include EmailSpec::Helpers + include EmailSpec::Matchers + + it "should not html-escape the notice's message" do + @notice = Factory(:notice, :message => "class < ActionController::Base") + @email = Mailer.err_notification(@notice) + @email.should have_body_text("class < ActionController::Base") + end + end +end -- libgit2 0.21.2