summaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/support/test/functional/tickets_controller_test.rb11
-rw-r--r--engines/support/test/integration/create_ticket_test.rb28
2 files changed, 39 insertions, 0 deletions
diff --git a/engines/support/test/functional/tickets_controller_test.rb b/engines/support/test/functional/tickets_controller_test.rb
index 416fb73..d746b59 100644
--- a/engines/support/test/functional/tickets_controller_test.rb
+++ b/engines/support/test/functional/tickets_controller_test.rb
@@ -72,6 +72,17 @@ class TicketsControllerTest < ActionController::TestCase
end
+ test "handle invalid ticket" do
+ params = {:subject => "unauth ticket test subject", :comments_attributes => {"0" => {"body" =>"body of test ticket"}}, :email => 'a'}
+
+ assert_no_difference('Ticket.count') do
+ post :create, :ticket => params
+ end
+
+ assert_template :new
+ assert_equal params[:subject], assigns(:ticket).subject
+ end
+
test "should create authenticated ticket" do
params = {:subject => "auth ticket test subject", :comments_attributes => {"0" => {"body" =>"body of test ticket"}}}
diff --git a/engines/support/test/integration/create_ticket_test.rb b/engines/support/test/integration/create_ticket_test.rb
new file mode 100644
index 0000000..2583fc7
--- /dev/null
+++ b/engines/support/test/integration/create_ticket_test.rb
@@ -0,0 +1,28 @@
+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
+
+end