summaryrefslogtreecommitdiff
path: root/engines/support/test/integration/create_ticket_test.rb
blob: 59b263e5386e5019250abb182b8fe0d91e305226 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
require 'test_helper'

class CreateTicketTest < BrowserIntegrationTest

  test "can submit ticket anonymously" do
    visit '/'
    click_on 'Get Help'
    fill_in 'Subject', with: 'test ticket'
    fill_in 'Description', with: 'description of the problem goes here'
    click_on 'Create Ticket'
    assert page.has_content?("Ticket was successfully created.")
    assert page.has_content?("You can later access this ticket at the URL")
    assert page.has_content?(current_url)
    assert ticket = Ticket.last
    ticket.destroy
  end

  test "get help when creating ticket with invalid email" do
    visit '/'
    click_on 'Get Help'
    fill_in 'Subject', with: 'test ticket'
    fill_in 'Email', with: 'invalid data'
    fill_in 'Description', with: 'description of the problem goes here'
    click_on 'Create Ticket'
    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