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
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