From 7cf9cbf62b431dbbb1a6e45bd5980d3c56fbf70d Mon Sep 17 00:00:00 2001 From: lukemelia Date: Fri, 8 Dec 2006 07:56:21 +0000 Subject: [PATCH] Restored some inadvertently commented tests. Also, I forgot to mention that the last changeset also removed lightbox.js and lightbox.css. I noticed they were adding to total page size unnecessarily as they are not used. git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@366 a4c988fc-2ded-0310-b66e-134b36920a42 --- .../test/integration/create_user_api_test.rb | 104 +++++++++--------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/tracks/test/integration/create_user_api_test.rb b/tracks/test/integration/create_user_api_test.rb index 52b863df..50a78f36 100644 --- a/tracks/test/integration/create_user_api_test.rb +++ b/tracks/test/integration/create_user_api_test.rb @@ -14,44 +14,44 @@ class CreateUserControllerTest < ActionController::IntegrationTest assert_test_environment_ok end - # def test_fails_with_401_if_not_authorized_user - # authenticated_post_xml_to_user_create @@foobar_postdata, 'nobody', 'nohow' - # assert_401_unauthorized - # end - # - # def test_fails_with_401_if_not_admin_user - # authenticated_post_xml_to_user_create @@foobar_postdata, users(:other_user).login, 'sesame' - # assert_401_unauthorized - # end - # - # def test_content_type_must_be_xml - # authenticated_post_xml_to_user_create @@foobar_postdata, users(:admin_user).login, 'abracadabra', {'CONTENT_TYPE' => "application/x-www-form-urlencoded"} - # assert_404_invalid_xml - # end - # - # def test_fails_with_invalid_xml_format - # authenticated_post_xml_to_user_create "" - # assert_404_invalid_xml - # end - # - # def test_fails_with_invalid_xml_format2 - # authenticated_post_xml_to_user_create "foo" - # assert_404_invalid_xml - # end - # - # def test_xml_simple_param_parsing - # authenticated_post_xml_to_user_create - # assert @controller.params.has_key?(:request) - # assert @controller.params[:request].has_key?(:login) - # assert @controller.params[:request].has_key?(:password) - # assert_equal 'foo', @controller.params[:request][:login] - # assert_equal 'bar', @controller.params[:request][:password] - # end - # - # def test_fails_with_too_short_password - # authenticated_post_xml_to_user_create - # assert_response_and_body 404, "\n\n Password is too short (minimum is 5 characters)\n\n" - # end + def test_fails_with_401_if_not_authorized_user + authenticated_post_xml_to_user_create @@foobar_postdata, 'nobody', 'nohow' + assert_401_unauthorized + end + + def test_fails_with_401_if_not_admin_user + authenticated_post_xml_to_user_create @@foobar_postdata, users(:other_user).login, 'sesame' + assert_401_unauthorized + end + + def test_content_type_must_be_xml + authenticated_post_xml_to_user_create @@foobar_postdata, users(:admin_user).login, 'abracadabra', {'CONTENT_TYPE' => "application/x-www-form-urlencoded"} + assert_404_invalid_xml + end + + def test_fails_with_invalid_xml_format + authenticated_post_xml_to_user_create "" + assert_404_invalid_xml + end + + def test_fails_with_invalid_xml_format2 + authenticated_post_xml_to_user_create "foo" + assert_404_invalid_xml + end + + def test_xml_simple_param_parsing + authenticated_post_xml_to_user_create + assert @controller.params.has_key?(:request) + assert @controller.params[:request].has_key?(:login) + assert @controller.params[:request].has_key?(:password) + assert_equal 'foo', @controller.params[:request][:login] + assert_equal 'bar', @controller.params[:request][:password] + end + + def test_fails_with_too_short_password + authenticated_post_xml_to_user_create + assert_response_and_body 404, "\n\n Password is too short (minimum is 5 characters)\n\n" + end def test_fails_with_nonunique_login existing_login = users(:other_user).login @@ -59,20 +59,20 @@ class CreateUserControllerTest < ActionController::IntegrationTest assert_response_and_body 404, "\n\n Login has already been taken\n\n" end - # def test_creates_new_user - # initial_count = User.count - # authenticated_post_xml_to_user_create @@johnny_postdata - # assert_response_and_body 200, "User created." - # assert_equal initial_count + 1, User.count - # johnny1 = User.find_by_login('johnny') - # assert_not_nil johnny1, "expected user johnny to be created" - # johnny2 = User.authenticate('johnny','barracuda') - # assert_not_nil johnny2, "expected user johnny to be created" - # end - # - # def test_fails_with_get_verb - # authenticated_get_xml "/user/create", users(:admin_user).login, 'abracadabra', {} - # end + def test_creates_new_user + initial_count = User.count + authenticated_post_xml_to_user_create @@johnny_postdata + assert_response_and_body 200, "User created." + assert_equal initial_count + 1, User.count + johnny1 = User.find_by_login('johnny') + assert_not_nil johnny1, "expected user johnny to be created" + johnny2 = User.authenticate('johnny','barracuda') + assert_not_nil johnny2, "expected user johnny to be created" + end + + def test_fails_with_get_verb + authenticated_get_xml "/user/create", users(:admin_user).login, 'abracadabra', {} + end private