From f1e3b135eec6e0a6a02b920cdadd7adc5889f9e2 Mon Sep 17 00:00:00 2001 From: jessib Date: Thu, 15 Nov 2012 12:37:35 -0800 Subject: Some more ticket tests. --- help/test/functional/tickets_controller_test.rb | 28 +++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'help/test/functional/tickets_controller_test.rb') diff --git a/help/test/functional/tickets_controller_test.rb b/help/test/functional/tickets_controller_test.rb index 56d81d7..35901ca 100644 --- a/help/test/functional/tickets_controller_test.rb +++ b/help/test/functional/tickets_controller_test.rb @@ -15,6 +15,31 @@ class TicketsControllerTest < ActionController::TestCase assert_response :success end + test "ticket show access" do + ticket = Ticket.first + ticket.created_by = nil # TODO: hacky, but this makes sure this ticket is an unauthenticated one + ticket.save + get :show, :id => ticket.id + assert_response :success + + ticket.created_by = User.last.id + ticket.save + get :show, :id => ticket.id + assert_response :redirect + assert_redirected_to login_url + + login(User.last) + get :show, :id => ticket.id + assert_response :success + + login(User.first) #assumes User.first != User.last: + assert_not_equal User.first, User.last + get :show, :id => ticket.id + assert_response :redirect + assert_redirected_to root_url + + end + test "should create unauthenticated ticket" do params = {:title => "unauth ticket test title", :comments_attributes => {"0" => {"body" =>"body of test ticket"}}} @@ -129,7 +154,7 @@ class TicketsControllerTest < ActionController::TestCase end - test "test_tickets_by_admin" do + test "tickets by admin" do admin_login = APP_CONFIG['admins'].first admin_user = User.find_by_login(admin_login) #assumes that there is an admin login @@ -169,6 +194,5 @@ class TicketsControllerTest < ActionController::TestCase end - end -- cgit v1.2.3