remove the dup methods from the test helper. Add tests for no content and checking that a record has been created.

This commit is contained in:
Shaun McDonald 2009-04-13 00:13:51 +00:00
parent 90ec90f13d
commit 72a3947b1b

View file

@ -4,14 +4,6 @@ require 'changeset_controller'
class ChangesetControllerTest < ActionController::TestCase class ChangesetControllerTest < ActionController::TestCase
api_fixtures api_fixtures
def basic_authorization(user, pass)
@request.env["HTTP_AUTHORIZATION"] = "Basic %s" % Base64.encode64("#{user}:#{pass}")
end
def content(c)
@request.env["RAW_POST_DATA"] = c.to_s
end
# ----------------------- # -----------------------
# Test simple changeset creation # Test simple changeset creation
# ----------------------- # -----------------------
@ -48,6 +40,18 @@ class ChangesetControllerTest < ActionController::TestCase
assert_response :bad_request, "creating a invalid changeset should fail" assert_response :bad_request, "creating a invalid changeset should fail"
end end
def test_create_invalid_no_content
basic_authorization "test@openstreetmap.org", "test"
put :create
assert_response :bad_request, "creating a changeset with no content should fail"
end
def test_create_wrong_method
basic_authorization "test@openstreetmap.org", "test"
get :create
assert_response :method_not_allowed
end
## ##
# check that the changeset can be read and returns the correct # check that the changeset can be read and returns the correct
# document structure. # document structure.
@ -248,7 +252,9 @@ EOF
content "<osm><changeset>" + content "<osm><changeset>" +
"<tag k='created_by' v='osm test suite checking changesets'/>" + "<tag k='created_by' v='osm test suite checking changesets'/>" +
"</changeset></osm>" "</changeset></osm>"
put :create assert_difference('Changeset.count', 1) do
put :create
end
assert_response :success assert_response :success
changeset_id = @response.body.to_i changeset_id = @response.body.to_i
end end