basic_authorization users(:normal_user).email, "test"
# Create the first user's changeset
content "<osm><changeset>" +
- "<tag k='created_by' v='osm test suite checking changesets'/>" +
- "</changeset></osm>"
+ "<tag k='created_by' v='osm test suite checking changesets'/>" +
+ "</changeset></osm>"
put :create
assert_require_public_data
basic_authorization users(:public_user).email, "test"
# Create the first user's changeset
content "<osm><changeset>" +
- "<tag k='created_by' v='osm test suite checking changesets'/>" +
- "</changeset></osm>"
+ "<tag k='created_by' v='osm test suite checking changesets'/>" +
+ "</changeset></osm>"
put :create
assert_response :success, "Creation of changeset did not return sucess status"
# create a temporary changeset
content "<osm><changeset>" +
- "<tag k='created_by' v='osm test suite checking changesets'/>" +
- "</changeset></osm>"
+ "<tag k='created_by' v='osm test suite checking changesets'/>" +
+ "</changeset></osm>"
assert_difference "Changeset.count", 1 do
put :create
end
<osmChange>
<create>
<node id='-1' lon='0' lat='0' changeset='#{cs_id}'>
- <tag k='foo' v='#{"x" * 256}'/>
+ <tag k='foo' v='#{'x' * 256}'/>
</node>
</create>
</osmChange>
basic_authorization users(:public_user).email, "test"
content "<osm><changeset>" +
- "<tag k='created_by' v='osm test suite checking changesets'/>" +
- "</changeset></osm>"
+ "<tag k='created_by' v='osm test suite checking changesets'/>" +
+ "</changeset></osm>"
put :create
assert_response :success
changeset_id = @response.body.to_i
diff.root = XML::Node.new "osmChange"
modify = XML::Node.new "modify"
xml_old_node = old_node.to_xml_node
- xml_old_node["lat"] = (2.0).to_s
- xml_old_node["lon"] = (2.0).to_s
+ xml_old_node["lat"] = 2.0.to_s
+ xml_old_node["lon"] = 2.0.to_s
xml_old_node["changeset"] = changeset_id.to_s
modify << xml_old_node
diff.root << modify
basic_authorization users(:public_user).email, "test"
content "<osm><changeset>" +
- "<tag k='created_by' v='osm test suite checking changesets'/>" +
- "</changeset></osm>"
+ "<tag k='created_by' v='osm test suite checking changesets'/>" +
+ "</changeset></osm>"
put :create
assert_response :success
changeset_id = @response.body.to_i
["<osmChange/>",
"<osmChange></osmChange>",
"<osmChange><modify/></osmChange>",
- "<osmChange><modify></modify></osmChange>"
- ].each do |diff|
+ "<osmChange><modify></modify></osmChange>"].each do |diff|
# upload it
content diff
post :upload, :id => changesets(:public_user_first_change).id
# create a temporary changeset
content "<osm><changeset>" +
- "<tag k='created_by' v='osm test suite checking changesets'/>" +
- "</changeset></osm>"
+ "<tag k='created_by' v='osm test suite checking changesets'/>" +
+ "</changeset></osm>"
put :create
assert_response :forbidden
# create a temporary changeset
content "<osm><changeset>" +
- "<tag k='created_by' v='osm test suite checking changesets'/>" +
- "</changeset></osm>"
+ "<tag k='created_by' v='osm test suite checking changesets'/>" +
+ "</changeset></osm>"
put :create
assert_response :success
changeset_id = @response.body.to_i
# create a temporary changeset
content "<osm><changeset>" +
- "<tag k='created_by' v='osm test suite checking changesets'/>" +
- "</changeset></osm>"
+ "<tag k='created_by' v='osm test suite checking changesets'/>" +
+ "</changeset></osm>"
put :create
assert_response :success
changeset_id = @response.body.to_i
# create a temporary changeset
content "<osm><changeset>" +
- "<tag k='created_by' v='osm test suite checking changesets'/>" +
- "</changeset></osm>"
+ "<tag k='created_by' v='osm test suite checking changesets'/>" +
+ "</changeset></osm>"
put :create
assert_response :success
changeset_id = @response.body.to_i
# NOTE: the include method doesn't over-expand, like inserting
# a real method does. this is because we expect the client to
# know what it is doing!
- check_after_include(changeset_id, 1, 1, [1, 1, 1, 1])
- check_after_include(changeset_id, 3, 3, [1, 1, 3, 3])
- check_after_include(changeset_id, 4, 2, [1, 1, 4, 3])
- check_after_include(changeset_id, 2, 2, [1, 1, 4, 3])
- check_after_include(changeset_id, -1, -1, [-1, -1, 4, 3])
- check_after_include(changeset_id, -2, 5, [-2, -1, 4, 5])
+ check_after_include(changeset_id, 1, 1, [1, 1, 1, 1])
+ check_after_include(changeset_id, 3, 3, [1, 1, 3, 3])
+ check_after_include(changeset_id, 4, 2, [1, 1, 4, 3])
+ check_after_include(changeset_id, 2, 2, [1, 1, 4, 3])
+ check_after_include(changeset_id, -1, -1, [-1, -1, 4, 3])
+ check_after_include(changeset_id, -2, 5, [-2, -1, 4, 5])
end
##
get :query, :closed => "true"
assert_response :success, "can't get changesets by closed-ness"
- assert_changesets [3, 5, 6, 7, 8]
+ assert_changesets [3, 5, 6, 7, 8, 9]
get :query, :closed => "true", :user => users(:normal_user).id
assert_response :success, "can't get changesets by closed-ness and user"
def test_query_invalid
["abracadabra!",
"1,2,3,F",
- ";drop table users;"
- ].each do |bbox|
+ ";drop table users;"].each do |bbox|
get :query, :bbox => bbox
assert_response :bad_request, "'#{bbox}' isn't a bbox"
end
"00-00-00",
";drop table users;",
",",
- "-,-"
- ].each do |time|
+ "-,-"].each do |time|
get :query, :time => time
assert_response :bad_request, "'#{time}' isn't a valid time range"
end
["me",
"foobar",
"-1",
- "0"
- ].each do |uid|
+ "0"].each do |uid|
get :query, :user => uid
assert_response :bad_request, "'#{uid}' isn't a valid user ID"
end
# check the result of a list
def check_list_result(changesets)
changesets = changesets.where("num_changes > 0")
- .order(:created_at => :desc)
- .limit(20)
+ .order(:created_at => :desc)
+ .limit(20)
assert changesets.size <= 20
assert_select "ol.changesets", :count => [changesets.size, 1].min do
# check the result of a feed
def check_feed_result(changesets)
changesets = changesets.where("num_changes > 0")
- .order(:created_at => :desc)
- .limit(20)
+ .order(:created_at => :desc)
+ .limit(20)
assert changesets.size <= 20
assert_select "feed", :count => [changesets.size, 1].min do
- assert_select "entry", :count => changesets.size
+ assert_select "> title", :count => 1, :text => /^Changesets/
+ assert_select "> entry", :count => changesets.size
changesets.each do |changeset|
- assert_select "entry > id", changeset_url(:id => changeset.id)
+ assert_select "> entry > id", changeset_url(:id => changeset.id)
end
end
end