diff options
author | Azul <azul@leap.se> | 2014-05-13 10:52:55 +0200 |
---|---|---|
committer | Azul <azul@leap.se> | 2014-05-13 10:52:55 +0200 |
commit | 0261e82686ec4fcfc8b633664fadb1dd6d9c8070 (patch) | |
tree | 7c8401d59f2bccf5c9e46263e89be26afcea4857 /engines/support | |
parent | 86eb9062f1e81302647bf18ce0f5fd981202b68a (diff) |
keep empty email field if user removed prefill
We should respect the users choice. We can still get their email from the user id if we really need to.
Diffstat (limited to 'engines/support')
-rw-r--r-- | engines/support/app/controllers/tickets_controller.rb | 1 | ||||
-rw-r--r-- | engines/support/test/integration/create_ticket_test.rb | 28 |
2 files changed, 28 insertions, 1 deletions
diff --git a/engines/support/app/controllers/tickets_controller.rb b/engines/support/app/controllers/tickets_controller.rb index d552209..8ec8e4d 100644 --- a/engines/support/app/controllers/tickets_controller.rb +++ b/engines/support/app/controllers/tickets_controller.rb @@ -22,7 +22,6 @@ class TicketsController < ApplicationController @ticket.comments.last.posted_by = current_user.id @ticket.comments.last.private = false unless admin? @ticket.created_by = current_user.id - @ticket.email = current_user.email_address if current_user.email_address if @ticket.save flash[:notice] = t(:thing_was_successfully_created, :thing => t(:ticket)) diff --git a/engines/support/test/integration/create_ticket_test.rb b/engines/support/test/integration/create_ticket_test.rb index 2583fc7..59b263e 100644 --- a/engines/support/test/integration/create_ticket_test.rb +++ b/engines/support/test/integration/create_ticket_test.rb @@ -25,4 +25,32 @@ class CreateTicketTest < BrowserIntegrationTest assert page.has_content?("is invalid") end + test "prefills email when user has email service" do + login FactoryGirl.create(:premium_user) + visit '/' + click_on "Support Tickets" + click_on "New Ticket" + email = "#{@user.login}@#{APP_CONFIG[:domain]}" + assert_equal email, find_field('Email').value + end + + test "no prefill of email without email service" do + login + visit '/' + click_on "Support Tickets" + click_on "New Ticket" + assert_equal "", find_field('Email').value + end + + test "cleared email field should remain clear" do + login FactoryGirl.create(:premium_user) + visit '/' + click_on "Support Tickets" + click_on "New Ticket" + fill_in 'Subject', with: 'test ticket' + fill_in 'Email', with: '' + fill_in 'Description', with: 'description of the problem goes here' + click_on 'Create Ticket' + assert_nil Ticket.last.email + end end |