Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/assets/stylesheets/feedback.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/feedback_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion app/mailers/feedback_mailer.rb
Original file line number Diff line number Diff line change
@@ -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
9 changes: 7 additions & 2 deletions app/views/feedback/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@

<div class="field-wrap">
<%= 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 %>
</div>

<div class="field-wrap">
<%= label_tag 'contact_name', 'Your name (optional)', class: 'field-label' %>
<%= text_field_tag 'contact_name', nil, class: 'field field-text bento-field-text' %>
</div>

<div class="field-wrap">
<%= 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' %>
</div>

<div class="field-wrap">
Expand Down
2 changes: 2 additions & 0 deletions app/views/feedback_mailer/feedback_email.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

<p><%= @msg %></p>

<p>Contact Name: <%= @contact_name %></p>

<p>Contact Email: <%= @contact_email %></p>

<p>Client IP: <%= @ip %></p>
Expand Down
3 changes: 3 additions & 0 deletions test/controllers/feedback_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/feedback_mailer/feedback_email
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

<p>This is an important message!</p>

<p>Contact Name: Firsty Lastoson</p>

<p>Contact Email: yo@example.com</p>

<p>Client IP: 0.0.0.0</p>
Expand Down
3 changes: 2 additions & 1 deletion test/mailers/feedback_mailer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down