From b8869da002b1e3306b6c347ac13d87cc05cf0cd8 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Thu, 19 Jul 2018 17:50:30 +0100 Subject: [PATCH 1/2] Fix bundler version at 1.16.2 The 1.16.3 release has a load issue with the cucumber task. --- .travis.yml | 2 +- Gemfile.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1c25439b7..7dae05ecc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ services: addons: postgresql: "9.4" before_install: -- gem install bundler +- gem install bundler -v 1.16.2 - | export PHANTOMJS_VERSION=2.1.1 export PATH=$PWD/travis_phantomjs/phantomjs-$PHANTOMJS_VERSION-linux-x86_64/bin:$PATH diff --git a/Gemfile.lock b/Gemfile.lock index 9e3034db2..337291f1e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -350,4 +350,4 @@ DEPENDENCIES will_paginate BUNDLED WITH - 1.16.0 + 1.16.2 From 00b9fa9d7426e4120e2ffeba61c44b52f0d3d388 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Thu, 19 Jul 2018 17:51:31 +0100 Subject: [PATCH 2/2] Add a HTML template for feedback messages An unknown PC email clients was rendering the text template on one line. --- app/models/feedback.rb | 4 ++++ .../feedback_mailer/send_feedback.html.erb | 23 +++++++++++++++++++ .../feedback_mailer/send_feedback.text.erb | 17 ++++++++++---- features/step_definitions/feedback_steps.rb | 2 +- .../previews/feedback_mailer_preview.rb | 6 +++++ 5 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 app/views/feedback_mailer/send_feedback.html.erb create mode 100644 spec/mailers/previews/feedback_mailer_preview.rb diff --git a/app/models/feedback.rb b/app/models/feedback.rb index d83979370..be18e74d5 100644 --- a/app/models/feedback.rb +++ b/app/models/feedback.rb @@ -2,4 +2,8 @@ class Feedback < ActiveRecord::Base validates :comment, presence: true, length: { maximum: 32768 } validates :petition_link_or_title, length: { maximum: 255 }, allow_blank: true validates :email, format: { with: EMAIL_REGEX }, length: { maximum: 255 }, allow_blank: true + + def petition_link? + petition_link_or_title =~ /\A#{Regexp.escape(Site.url)}/ + end end diff --git a/app/views/feedback_mailer/send_feedback.html.erb b/app/views/feedback_mailer/send_feedback.html.erb new file mode 100644 index 000000000..a8e76bed9 --- /dev/null +++ b/app/views/feedback_mailer/send_feedback.html.erb @@ -0,0 +1,23 @@ +

Comments:

+<%= simple_format(@feedback.comment) %> + +
+ +

+ Link or title:
+ <% if @feedback.petition_link? %> + <%= link_to nil, @feedback.petition_link_or_title %> + <% else %> + <%= @feedback.petition_link_or_title %> + <% end %> +

+ +

+ Email:
+ <%= mail_to(@feedback.email) %> +

+ +

+ Browser:
+ <%= @feedback.user_agent %> +

diff --git a/app/views/feedback_mailer/send_feedback.text.erb b/app/views/feedback_mailer/send_feedback.text.erb index 03c7364b5..73acc7b74 100644 --- a/app/views/feedback_mailer/send_feedback.text.erb +++ b/app/views/feedback_mailer/send_feedback.text.erb @@ -1,4 +1,13 @@ -Comments: <%= @feedback.comment %> -Link: <%= @feedback.petition_link_or_title %> -Email: <%= @feedback.email %> -Browser: <%= @feedback.user_agent %> +Comments: +<%= word_wrap(@feedback.comment, line_width: 72) %> + +======================================================================= + +Link or title: +<%= @feedback.petition_link_or_title %> + +Email: +<%= @feedback.email %> + +Browser: +<%= @feedback.user_agent %> diff --git a/features/step_definitions/feedback_steps.rb b/features/step_definitions/feedback_steps.rb index e9feb1185..575c0043f 100644 --- a/features/step_definitions/feedback_steps.rb +++ b/features/step_definitions/feedback_steps.rb @@ -18,7 +18,7 @@ Then they should see "#{@feedback.email}" in the email body Then they should see "#{@feedback.petition_link_or_title}" in the email body Then they should see "#{@feedback.comment}" in the email body - Then they should see "Browser: Chrome" in the email body + Then they should see "Chrome" in the email body ) end diff --git a/spec/mailers/previews/feedback_mailer_preview.rb b/spec/mailers/previews/feedback_mailer_preview.rb new file mode 100644 index 000000000..e13213c25 --- /dev/null +++ b/spec/mailers/previews/feedback_mailer_preview.rb @@ -0,0 +1,6 @@ +# Preview all emails at http://localhost:3000/rails/mailers/feedback_mailer +class FeedbackMailerPreview < ActionMailer::Preview + def send_feedback + FeedbackMailer.send_feedback(Feedback.last) + end +end