summaryrefslogtreecommitdiff
path: root/engines/support/test
diff options
context:
space:
mode:
authorAzul <azul@riseup.net>2017-03-23 10:43:11 +0100
committerAzul <azul@riseup.net>2017-03-23 11:04:21 +0100
commitc828d0164a43c169775ae107be3fd4409d6c3ecb (patch)
tree0611aeffde20fab088eacb2cac0736258bf789f3 /engines/support/test
parent3efe125d6e3bd5f4eecd18952376ffc37e09b9c5 (diff)
fix: keep ticket submit button clickable
It was marked as submitted even when client side validations interfered. fixes github issue #227
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