From 5a2f8e47a909ee3b20045dd85c0b70d05624e315 Mon Sep 17 00:00:00 2001 From: Jeremy Prevost Date: Wed, 15 Feb 2017 13:04:11 -0500 Subject: [PATCH] Feedback Form Updates - removes feedback placeholders - adds optional name to feedback form see https://mitlibraries.atlassian.net/browse/DI-221 --- app/assets/stylesheets/feedback.scss | 2 +- app/controllers/feedback_controller.rb | 2 +- app/mailers/feedback_mailer.rb | 3 ++- app/views/feedback/index.html.erb | 9 +++++++-- app/views/feedback_mailer/feedback_email.html.erb | 2 ++ test/controllers/feedback_controller_test.rb | 3 +++ test/fixtures/feedback_mailer/feedback_email | 2 ++ test/mailers/feedback_mailer_test.rb | 3 ++- 8 files changed, 20 insertions(+), 6 deletions(-) diff --git a/app/assets/stylesheets/feedback.scss b/app/assets/stylesheets/feedback.scss index 2dfd6a03..96d8d529 100644 --- a/app/assets/stylesheets/feedback.scss +++ b/app/assets/stylesheets/feedback.scss @@ -2,7 +2,7 @@ // They will automatically be included in application.css. // You can use Sass (SCSS) here: http://sass-lang.com/ -.bento-field-email { +.bento-field-email, .bento-field-text { width: 80%; padding: 6px 12px; } diff --git a/app/controllers/feedback_controller.rb b/app/controllers/feedback_controller.rb index e3932451..07a5e5b1 100644 --- a/app/controllers/feedback_controller.rb +++ b/app/controllers/feedback_controller.rb @@ -7,7 +7,7 @@ def index; end def submit FeedbackMailer.feedback_email(params[:feedback_message], request.remote_ip, params[:previous_page], - params[:contact_email], + params[:contact_email], params[:contact_name], request.env['HTTP_USER_AGENT']).deliver_now end diff --git a/app/mailers/feedback_mailer.rb b/app/mailers/feedback_mailer.rb index 303c2f38..c79f5b7d 100644 --- a/app/mailers/feedback_mailer.rb +++ b/app/mailers/feedback_mailer.rb @@ -1,10 +1,11 @@ class FeedbackMailer < ApplicationMailer - def feedback_email(msg, ip, page, contact_email, ua) + def feedback_email(msg, ip, page, contact_email, contact_name, ua) @ip = ip @msg = msg @page = page @ua = ua @contact_email = contact_email + @contact_name = contact_name mail(to: ENV['FEEDBACK_MAIL_TO'], subject: 'MIT Bento Feedback') end end diff --git a/app/views/feedback/index.html.erb b/app/views/feedback/index.html.erb index be649c6f..1d3aad16 100644 --- a/app/views/feedback/index.html.erb +++ b/app/views/feedback/index.html.erb @@ -5,12 +5,17 @@
<%= label_tag 'feedback_message', 'What did you think of the new search?', class: 'field-label' %> - <%= text_area_tag 'feedback_message', nil, class: 'field field-textarea bento-field-textarea', placeholder: 'Good? Bad? Let us know how it worked for you', required: true %> + <%= text_area_tag 'feedback_message', nil, class: 'field field-textarea bento-field-textarea', required: true %> +
+ +
+ <%= label_tag 'contact_name', 'Your name (optional)', class: 'field-label' %> + <%= text_field_tag 'contact_name', nil, class: 'field field-text bento-field-text' %>
<%= label_tag 'contact_email', 'Contact Email (optional)', class: 'field-label' %> - <%= email_field_tag 'contact_email', nil, class: 'field field-email bento-field-email', placeholder: 'Enter your email address if you would like a response' %> + <%= email_field_tag 'contact_email', nil, class: 'field field-email bento-field-email' %>
diff --git a/app/views/feedback_mailer/feedback_email.html.erb b/app/views/feedback_mailer/feedback_email.html.erb index a3a2a423..cc337f14 100644 --- a/app/views/feedback_mailer/feedback_email.html.erb +++ b/app/views/feedback_mailer/feedback_email.html.erb @@ -2,6 +2,8 @@

<%= @msg %>

+

Contact Name: <%= @contact_name %>

+

Contact Email: <%= @contact_email %>

Client IP: <%= @ip %>

diff --git a/test/controllers/feedback_controller_test.rb b/test/controllers/feedback_controller_test.rb index d2e4fda4..6b5e8699 100644 --- a/test/controllers/feedback_controller_test.rb +++ b/test/controllers/feedback_controller_test.rb @@ -11,6 +11,7 @@ class FeedbackControllerTest < ActionDispatch::IntegrationTest post feedback_submit_url, params: { feedback_message: 'Popcorn is cool.', contact_email: 'yo@example.com', + contact_name: 'Firsty Lastoson', previous_page: 'http://example.com/hi' } end @@ -26,6 +27,8 @@ class FeedbackControllerTest < ActionDispatch::IntegrationTest feedback_email.body.to_s) assert_match(/Contact Email: yo@example.com/, feedback_email.body.to_s) + assert_match(/Contact Name: Firsty Lastoson/, + feedback_email.body.to_s) assert_match(%r{Originating page: http://example.com/hi}, feedback_email.body.to_s) end diff --git a/test/fixtures/feedback_mailer/feedback_email b/test/fixtures/feedback_mailer/feedback_email index 7a25814b..83130f55 100644 --- a/test/fixtures/feedback_mailer/feedback_email +++ b/test/fixtures/feedback_mailer/feedback_email @@ -12,6 +12,8 @@

This is an important message!

+

Contact Name: Firsty Lastoson

+

Contact Email: yo@example.com

Client IP: 0.0.0.0

diff --git a/test/mailers/feedback_mailer_test.rb b/test/mailers/feedback_mailer_test.rb index 5651f110..e44de0ad 100644 --- a/test/mailers/feedback_mailer_test.rb +++ b/test/mailers/feedback_mailer_test.rb @@ -5,7 +5,8 @@ def test_feedback_email # Create the email and store it for further assertions email = FeedbackMailer.feedback_email('This is an important message!', '0.0.0.0', 'http://example.com/stuff', - 'yo@example.com', 'Netscape 4.0') + 'yo@example.com', 'Firsty Lastoson', + 'Netscape 4.0') # Send the email, then test that it got queued assert_emails 1 do