From 4bbf03761852ea5dfcfd1384b98d2606842e95ad Mon Sep 17 00:00:00 2001 From: Azul Date: Sat, 1 Dec 2012 19:42:16 +0100 Subject: using login :is_admin => true instead of real records Travis CI does not seem to have the admin user records. Let's not depend on them and just stub the admin user. --- help/test/functional/tickets_controller_test.rb | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'help/test/functional') diff --git a/help/test/functional/tickets_controller_test.rb b/help/test/functional/tickets_controller_test.rb index cf123a9..ac6a92d 100644 --- a/help/test/functional/tickets_controller_test.rb +++ b/help/test/functional/tickets_controller_test.rb @@ -143,14 +143,12 @@ class TicketsControllerTest < ActionController::TestCase test "admin add comment to authenticated ticket" do - admin_login = APP_CONFIG['admins'].first - admin_user = User.find_by_login(admin_login) #assumes that there is an admin login - login(admin_user) + login :is_admin? => true ticket = Ticket.last assert_not_nil User.last.id ticket.created_by = User.last.id # TODO: hacky, but confirms it somebody elses ticket. assumes last user is not admin user: - assert_not_equal User.last, admin_user + assert_not_equal User.last.id, @current_user.id ticket.save #admin should be able to comment: @@ -166,15 +164,13 @@ class TicketsControllerTest < ActionController::TestCase 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 - login(admin_user) + login :is_admin? => true, :email => nil post :create, :ticket => {:title => "test tick", :comments_attributes => {"0" => {"body" =>"body of test tick"}}} post :create, :ticket => {:title => "another test tick", :comments_attributes => {"0" => {"body" =>"body of another test tick"}}} assert_not_nil assigns(:ticket).created_by - assert_equal assigns(:ticket).created_by, admin_user.id + assert_equal assigns(:ticket).created_by, @current_user.id get :index, {:admin_status => "mine", :open_status => "open"} assert assigns(:tickets).count > 1 # at least 2 tickets @@ -198,7 +194,7 @@ class TicketsControllerTest < ActionController::TestCase assert assigns(:tickets).include?(assigns(:ticket)) assert_not_nil assigns(:ticket).comments.last.posted_by - assert_equal assigns(:ticket).comments.last.posted_by, admin_user.id + assert_equal assigns(:ticket).comments.last.posted_by, @current_user.id assigns(:ticket).destroy -- cgit v1.2.3