summaryrefslogtreecommitdiff
path: root/engines/support/test
diff options
context:
space:
mode:
Diffstat (limited to 'engines/support/test')
-rw-r--r--engines/support/test/integration/create_ticket_test.rb61
1 files changed, 43 insertions, 18 deletions
diff --git a/engines/support/test/integration/create_ticket_test.rb b/engines/support/test/integration/create_ticket_test.rb
index 6abb3d3..fcdc6b8 100644
--- a/engines/support/test/integration/create_ticket_test.rb
+++ b/engines/support/test/integration/create_ticket_test.rb
@@ -7,30 +7,30 @@ class CreateTicketTest < BrowserIntegrationTest
@testcode.save!
end
+ teardown do
+ Ticket.last.destroy if Ticket.last.present?
+ end
+
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 'Submit 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
+ submit_ticket
+ assert_ticket_submitted
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 'Regarding User', with: 'some user'
- fill_in 'Description', with: 'description of the problem goes here'
- click_on 'Submit Ticket'
- assert page.has_content?("is invalid")
+ submit_ticket email: 'invalid data',
+ regarding_user: 'some user'
+ assert_invalid_submission
assert_equal 'invaliddata', find_field('Email').value
assert_equal 'some user', find_field('Regarding User').value
+ resubmit_ticket email: 'valid@data.info'
+ assert_ticket_submitted
+ end
+
+ test "can resubmit after missing description" do
+ submit_ticket description: ''
+ assert page.has_content?("can't be blank")
+ resubmit_ticket description: 'okay, okay... you get a subject'
+ assert_ticket_submitted
end
test "prefills fields" do
@@ -66,4 +66,29 @@ class CreateTicketTest < BrowserIntegrationTest
ticket.destroy
end
+ def submit_ticket(email: nil, regarding_user: nil, description: 'some content')
+ visit '/'
+ click_on 'Get Help'
+ fill_in 'Subject', with: 'test ticket'
+ fill_in 'Email', with: email if email
+ fill_in 'Regarding User', with: regarding_user if regarding_user
+ fill_in 'Description', with: description
+ click_on 'Submit Ticket'
+ end
+
+ def assert_invalid_submission
+ assert page.has_content?("is invalid")
+ end
+
+ def resubmit_ticket(email: nil, description: nil)
+ fill_in 'Email', with: email if email
+ fill_in 'Description', with: description if description
+ click_on 'Submit Ticket'
+ end
+
+ def assert_ticket_submitted
+ 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)
+ end
end