def test_create
basic_authorization create(:user, :data_public => false).email, "test"
# Create the first user's changeset
- content "<osm><changeset>" \
- "<tag k='created_by' v='osm test suite checking changesets'/>" \
- "</changeset></osm>"
- put :create
+ xml = "<osm><changeset>" \
+ "<tag k='created_by' v='osm test suite checking changesets'/>" \
+ "</changeset></osm>"
+ put :create, :body => xml
assert_require_public_data
basic_authorization create(:user).email, "test"
# Create the first user's changeset
- content "<osm><changeset>" \
- "<tag k='created_by' v='osm test suite checking changesets'/>" \
- "</changeset></osm>"
- put :create
+ xml = "<osm><changeset>" \
+ "<tag k='created_by' v='osm test suite checking changesets'/>" \
+ "</changeset></osm>"
+ put :create, :body => xml
assert_response :success, "Creation of changeset did not return sucess status"
newid = @response.body.to_i
def test_create_invalid
basic_authorization create(:user, :data_public => false).email, "test"
- content "<osm><changeset></osm>"
- put :create
+ xml = "<osm><changeset></osm>"
+ put :create, :body => xml
assert_require_public_data
## Try the public user
basic_authorization create(:user).email, "test"
- content "<osm><changeset></osm>"
- put :create
+ xml = "<osm><changeset></osm>"
+ put :create, :body => xml
assert_response :bad_request, "creating a invalid changeset should fail"
end
CHANGESET
# upload it
- content diff
- post :upload, :params => { :id => changeset_id }
+ post :upload, :params => { :id => changeset_id }, :body => diff
assert_response :unauthorized,
"shouldn't be able to upload a simple valid diff to changeset: #{@response.body}"
CHANGESET
# upload it
- content diff
- post :upload, :params => { :id => changeset_id }
+ post :upload, :params => { :id => changeset_id }, :body => diff
assert_response :forbidden,
"can't upload a simple valid diff to changeset: #{@response.body}"
CHANGESET
# upload it
- content diff
- post :upload, :params => { :id => changeset_id }
+ post :upload, :params => { :id => changeset_id }, :body => diff
assert_response :success,
"can't upload a simple valid diff to changeset: #{@response.body}"
CHANGESET
# upload it
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff
assert_response :success,
"can't upload a simple valid creation to changeset: #{@response.body}"
end
# upload it
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff.to_s
assert_response :success,
"can't upload a deletion diff to changeset: #{@response.body}"
diff = "<osmChange><delete><node id='#{node.id}' version='#{node.version}' changeset='#{changeset.id}'/></delete></osmChange>"
# upload it
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff
assert_response :success,
"can't upload a deletion diff to changeset: #{@response.body}"
basic_authorization create(:user).email, "test"
# create a temporary changeset
- content "<osm><changeset>" \
- "<tag k='created_by' v='osm test suite checking changesets'/>" \
- "</changeset></osm>"
+ xml = "<osm><changeset>" \
+ "<tag k='created_by' v='osm test suite checking changesets'/>" \
+ "</changeset></osm>"
assert_difference "Changeset.count", 1 do
- put :create
+ put :create, :body => xml
end
assert_response :success
end
basic_authorization create(:user).email, "test"
# create a changeset
- content "<osm><changeset/></osm>"
- put :create
+ put :create, :body => "<osm><changeset/></osm>"
assert_response :success, "Should be able to create a changeset: #{@response.body}"
changeset_id = @response.body.to_i
# upload it, which used to cause an error like "PGError: ERROR:
# integer out of range" (bug #2152). but shouldn't any more.
- content diff
- post :upload, :params => { :id => changeset_id }
+ post :upload, :params => { :id => changeset_id }, :body => diff
assert_response :success,
"can't upload a spatially-large diff to changeset: #{@response.body}"
end
# upload it
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff.to_s
assert_response :precondition_failed,
"shouldn't be able to upload a invalid deletion diff: #{@response.body}"
assert_equal "Precondition failed: Way #{used_way.id} is still used by relations #{relation.id}.", @response.body
end
# upload it
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff.to_s
assert_response :success,
"can't do a conditional delete of in use objects: #{@response.body}"
CHANGESET
# upload it
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff
assert_response :bad_request,
"shoudln't be able to upload too long a tag to changeset: #{@response.body}"
end
CHANGESET
# upload it
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff
assert_response :success,
"can't upload a complex diff to changeset: #{@response.body}"
CHANGESET
# upload it
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff
assert_response :conflict,
"uploading a diff with multiple changesets should have failed"
CHANGESET
# upload it
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff
assert_response :success,
"can't upload multiple versions of an element in a diff: #{@response.body}"
CHANGESET
# upload it
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff
assert_response :conflict,
"shouldn't be able to upload the same element twice in a diff: #{@response.body}"
end
CHANGESET
# upload it
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff
assert_response :bad_request,
"shouldn't be able to upload an element without version: #{@response.body}"
end
</ping>
</osmChange>
CHANGESET
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff
assert_response :bad_request, "Shouldn't be able to upload a diff with the action ping"
assert_equal @response.body, "Unknown action ping, choices are create, modify, delete"
end
CHANGESET
# upload it
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff
assert_response :success,
"can't upload a valid diff with whitespace variations to changeset: #{@response.body}"
CHANGESET
# upload it
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff
assert_response :success,
"can't upload a valid diff with re-used placeholders to changeset: #{@response.body}"
CHANGESET
# upload it
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff
assert_response :bad_request,
"shouldn't be able to re-use placeholder IDs"
end
CHANGESET
# upload it
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff
assert_response :bad_request,
"shouldn't be able to use invalid placeholder IDs"
assert_equal "Placeholder node not found for reference -4 in way -1", @response.body
CHANGESET
# upload it
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff
assert_response :bad_request,
"shouldn't be able to use invalid placeholder IDs"
assert_equal "Placeholder node not found for reference -4 in way #{way.id}", @response.body
CHANGESET
# upload it
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff
assert_response :bad_request,
"shouldn't be able to use invalid placeholder IDs"
assert_equal "Placeholder Node not found for reference -4 in relation -1.", @response.body
CHANGESET
# upload it
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff
assert_response :bad_request,
"shouldn't be able to use invalid placeholder IDs"
assert_equal "Placeholder Way not found for reference -1 in relation #{relation.id}.", @response.body
def test_upload_node_move
basic_authorization create(:user).email, "test"
- content "<osm><changeset>" \
- "<tag k='created_by' v='osm test suite checking changesets'/>" \
- "</changeset></osm>"
- put :create
+ xml = "<osm><changeset>" \
+ "<tag k='created_by' v='osm test suite checking changesets'/>" \
+ "</changeset></osm>"
+ put :create, :body => xml
assert_response :success
changeset_id = @response.body.to_i
diff.root << modify
# upload it
- content diff
- post :upload, :params => { :id => changeset_id }
+ post :upload, :params => { :id => changeset_id }, :body => diff.to_s
assert_response :success,
"diff should have uploaded OK"
def test_upload_way_extend
basic_authorization create(:user).email, "test"
- content "<osm><changeset>" \
- "<tag k='created_by' v='osm test suite checking changesets'/>" \
- "</changeset></osm>"
- put :create
+ xml = "<osm><changeset>" \
+ "<tag k='created_by' v='osm test suite checking changesets'/>" \
+ "</changeset></osm>"
+ put :create, :body => xml
assert_response :success
changeset_id = @response.body.to_i
diff.root << modify
# upload it
- content diff
- post :upload, :params => { :id => changeset_id }
+ post :upload, :params => { :id => changeset_id }, :body => diff.to_s
assert_response :success,
"diff should have uploaded OK"
"<osmChange><modify/></osmChange>",
"<osmChange><modify></modify></osmChange>"].each do |diff|
# upload it
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff
assert_response(:success, "should be able to upload " \
"empty changeset: " + diff)
end
delete << node.to_xml_node
# upload it
- content diff
error_format "xml"
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff.to_s
assert_response :success,
"failed to return error in XML format"
basic_authorization create(:user, :data_public => false).email, "test"
# create a temporary changeset
- content "<osm><changeset>" \
- "<tag k='created_by' v='osm test suite checking changesets'/>" \
- "</changeset></osm>"
- put :create
+ xml = "<osm><changeset>" \
+ "<tag k='created_by' v='osm test suite checking changesets'/>" \
+ "</changeset></osm>"
+ put :create, :body => xml
assert_response :forbidden
## Now try with a normal user
basic_authorization create(:user).email, "test"
# create a temporary changeset
- content "<osm><changeset>" \
- "<tag k='created_by' v='osm test suite checking changesets'/>" \
- "</changeset></osm>"
- put :create
+ xml = "<osm><changeset>" \
+ "<tag k='created_by' v='osm test suite checking changesets'/>" \
+ "</changeset></osm>"
+ put :create, :body => xml
assert_response :success
changeset_id = @response.body.to_i
CHANGESET
# upload it
- content diff
- post :upload, :params => { :id => changeset_id }
+ post :upload, :params => { :id => changeset_id }, :body => diff
assert_response :success,
"can't upload multiple versions of an element in a diff: #{@response.body}"
basic_authorization create(:user).email, "test"
# create a temporary changeset
- content "<osm><changeset>" \
- "<tag k='created_by' v='osm test suite checking changesets'/>" \
- "</changeset></osm>"
- put :create
+ xml = "<osm><changeset>" \
+ "<tag k='created_by' v='osm test suite checking changesets'/>" \
+ "</changeset></osm>"
+ put :create, :body => xml
assert_response :success
changeset_id = @response.body.to_i
OSMFILE
# upload it
- content diff
- post :upload, :params => { :id => changeset_id }
+ post :upload, :params => { :id => changeset_id }, :body => diff
assert_response :success,
"can't upload a diff from JOSM: #{@response.body}"
basic_authorization create(:user).email, "test"
# create a temporary changeset
- content "<osm><changeset>" \
- "<tag k='created_by' v='osm test suite checking changesets'/>" \
- "</changeset></osm>"
- put :create
+ xml = "<osm><changeset>" \
+ "<tag k='created_by' v='osm test suite checking changesets'/>" \
+ "</changeset></osm>"
+ put :create, :body => xml
assert_response :success
changeset_id = @response.body.to_i
CHANGESET
# upload it
- content diff
- post :upload, :params => { :id => changeset_id }
+ post :upload, :params => { :id => changeset_id }, :body => diff
assert_response :success,
"can't upload multiple versions of an element in a diff: #{@response.body}"
basic_authorization create(:user).email, "test"
# create a new changeset
- content "<osm><changeset/></osm>"
- put :create
+ xml = "<osm><changeset/></osm>"
+ put :create, :body => xml
assert_response :success, "Creating of changeset failed."
changeset_id = @response.body.to_i
# add a single node to it
with_controller(NodesController.new) do
- content "<osm><node lon='1' lat='2' changeset='#{changeset_id}'/></osm>"
- put :create
+ xml = "<osm><node lon='1' lat='2' changeset='#{changeset_id}'/></osm>"
+ put :create, :body => xml
assert_response :success, "Couldn't create node."
end
# add another node to it
with_controller(NodesController.new) do
- content "<osm><node lon='2' lat='1' changeset='#{changeset_id}'/></osm>"
- put :create
+ xml = "<osm><node lon='2' lat='1' changeset='#{changeset_id}'/></osm>"
+ put :create, :body => xml
assert_response :success, "Couldn't create second node."
end
# add (delete) a way to it, which contains a point at (3,3)
with_controller(WaysController.new) do
- content update_changeset(way.to_xml, changeset_id)
- put :delete, :params => { :id => way.id }
+ xml = update_changeset(way.to_xml, changeset_id)
+ put :delete, :params => { :id => way.id }, :body => xml.to_s
assert_response :success, "Couldn't delete a way."
end
basic_authorization create(:user).display_name, "test"
# create a new changeset
- content "<osm><changeset/></osm>"
- put :create
+ put :create, :body => "<osm><changeset/></osm>"
assert_response :success, "Creating of changeset failed."
changeset_id = @response.body.to_i
basic_authorization create(:user).display_name, "test"
# create a new changeset
- content "<osm><changeset/></osm>"
- put :create
+ xml = "<osm><changeset/></osm>"
+ put :create, :body => xml
assert_response :success, "Creating of changeset failed."
changeset_id = @response.body.to_i
lat = -0.45
# Try and put
- content "<osm><node lon='#{lon}' lat='#{lat}'/></osm>"
- put :expand_bbox, :params => { :id => changeset_id }
+ xml = "<osm><node lon='#{lon}' lat='#{lat}'/></osm>"
+ put :expand_bbox, :params => { :id => changeset_id }, :body => xml
assert_response :method_not_allowed, "shouldn't be able to put a bbox expand"
# Try to get the update
- content "<osm><node lon='#{lon}' lat='#{lat}'/></osm>"
- get :expand_bbox, :params => { :id => changeset_id }
+ xml = "<osm><node lon='#{lon}' lat='#{lat}'/></osm>"
+ get :expand_bbox, :params => { :id => changeset_id }, :body => xml
assert_response :method_not_allowed, "shouldn't be able to get a bbox expand"
# Try to use a hopefully missing changeset
- content "<osm><node lon='#{lon}' lat='#{lat}'/></osm>"
- post :expand_bbox, :params => { :id => changeset_id + 13245 }
+ xml = "<osm><node lon='#{lon}' lat='#{lat}'/></osm>"
+ post :expand_bbox, :params => { :id => changeset_id + 13245 }, :body => xml
assert_response :not_found, "shouldn't be able to do a bbox expand on a nonexistant changeset"
end
new_tag["k"] = "tagtesting"
new_tag["v"] = "valuetesting"
new_changeset.find("//osm/changeset").first << new_tag
- content new_changeset
# try without any authorization
- put :update, :params => { :id => private_changeset.id }
+ put :update, :params => { :id => private_changeset.id }, :body => new_changeset.to_s
assert_response :unauthorized
# try with the wrong authorization
basic_authorization create(:user).email, "test"
- put :update, :params => { :id => private_changeset.id }
+ put :update, :params => { :id => private_changeset.id }, :body => new_changeset.to_s
assert_response :conflict
# now this should get an unauthorized
basic_authorization private_user.email, "test"
- put :update, :params => { :id => private_changeset.id }
+ put :update, :params => { :id => private_changeset.id }, :body => new_changeset.to_s
assert_require_public_data "user with their data non-public, shouldn't be able to edit their changeset"
## Now try with the public user
new_tag["k"] = "tagtesting"
new_tag["v"] = "valuetesting"
new_changeset.find("//osm/changeset").first << new_tag
- content new_changeset
# try without any authorization
@request.env["HTTP_AUTHORIZATION"] = nil
- put :update, :params => { :id => changeset.id }
+ put :update, :params => { :id => changeset.id }, :body => new_changeset.to_s
assert_response :unauthorized
# try with the wrong authorization
basic_authorization create(:user).email, "test"
- put :update, :params => { :id => changeset.id }
+ put :update, :params => { :id => changeset.id }, :body => new_changeset.to_s
assert_response :conflict
# now this should work...
basic_authorization user.email, "test"
- put :update, :params => { :id => changeset.id }
+ put :update, :params => { :id => changeset.id }, :body => new_changeset.to_s
assert_response :success
assert_select "osm>changeset[id='#{changeset.id}']", 1
new_tag["v"] = "testing"
new_changeset.find("//osm/changeset").first << new_tag
- content new_changeset
- put :update, :params => { :id => changeset.id }
+ put :update, :params => { :id => changeset.id }, :body => new_changeset.to_s
assert_response :conflict
end
basic_authorization create(:user).email, "test"
# open a new changeset
- content "<osm><changeset/></osm>"
- put :create
+ xml = "<osm><changeset/></osm>"
+ put :create, :body => xml
assert_response :success, "can't create a new changeset"
cs_id = @response.body.to_i
with_controller(NodesController.new) do
# create a new node
- content "<osm><node changeset='#{cs_id}' lat='0.0' lon='0.0'/></osm>"
- put :create
+ xml = "<osm><node changeset='#{cs_id}' lat='0.0' lon='0.0'/></osm>"
+ put :create, :body => xml
assert_response :success, "can't create a new node"
node_id = @response.body.to_i
node_xml["lon"] = rand.to_s
node_xml["version"] = (i + 1).to_s
- content node_doc
- put :update, :params => { :id => node_id }
+ put :update, :params => { :id => node_id }, :body => node_doc.to_s
assert_response :success, "attempt #{i} should have succeeded"
end
node_xml["lon"] = rand.to_s
node_xml["version"] = offset.to_s
- content node_doc
- put :update, :params => { :id => node_id }
+ put :update, :params => { :id => node_id }, :body => node_doc.to_s
assert_response :conflict, "final attempt should have failed"
end
##
# call the include method and assert properties of the bbox
def check_after_include(changeset_id, lon, lat, bbox)
- content "<osm><node lon='#{lon}' lat='#{lat}'/></osm>"
- post :expand_bbox, :params => { :id => changeset_id }
+ xml = "<osm><node lon='#{lon}' lat='#{lat}'/></osm>"
+ post :expand_bbox, :params => { :id => changeset_id }, :body => xml
assert_response :success, "Setting include of changeset failed: #{@response.body}"
# check exactly one changeset