diff options
-rw-r--r-- | help/test/functional/tickets_controller_test.rb | 14 | ||||
-rw-r--r-- | users/test/support/stub_record_helper.rb | 2 |
2 files changed, 6 insertions, 10 deletions
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 diff --git a/users/test/support/stub_record_helper.rb b/users/test/support/stub_record_helper.rb index e744ad7..ede21cf 100644 --- a/users/test/support/stub_record_helper.rb +++ b/users/test/support/stub_record_helper.rb @@ -7,7 +7,7 @@ module StubRecordHelper params.reverse_merge!(klass.valid_attributes_hash) end params[:params] = params.stringify_keys - params.reverse_merge! :id => 123, + params.reverse_merge! :id => "A123", :class => klass, :to_key => ['123'], :to_json => %Q({"stub":"#{klass.name}"}), |