X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/f8de0c1811a21a552541acd2288d191e872ca434..a66f0f32e977cb2d6ae7231e7014861c119cc657:/test/controllers/changeset_controller_test.rb diff --git a/test/controllers/changeset_controller_test.rb b/test/controllers/changeset_controller_test.rb index 96e665356..a9a838aff 100644 --- a/test/controllers/changeset_controller_test.rb +++ b/test/controllers/changeset_controller_test.rb @@ -3,7 +3,7 @@ require "changeset_controller" class ChangesetControllerTest < ActionController::TestCase api_fixtures - fixtures :friends, :changeset_comments, :changesets_subscribers + fixtures :changesets_subscribers ## # test all routes which lead to this controller @@ -102,16 +102,16 @@ class ChangesetControllerTest < ActionController::TestCase basic_authorization users(:normal_user).email, "test" # Create the first user's changeset content "" + - "" + - "" + "" + + "" put :create assert_require_public_data basic_authorization users(:public_user).email, "test" # Create the first user's changeset content "" + - "" + - "" + "" + + "" put :create assert_response :success, "Creation of changeset did not return sucess status" @@ -197,6 +197,7 @@ class ChangesetControllerTest < ActionController::TestCase assert_select "osm>changeset>discussion>comment", 0 changeset_id = changesets(:normal_user_closed_change).id + create_list(:changeset_comment, 3, :changeset_id => changeset_id) get :read, :id => changeset_id, :include_discussion => true assert_response :success, "cannot get closed changeset with comments" @@ -527,8 +528,8 @@ EOF # create a temporary changeset content "" + - "" + - "" + "" + + "" assert_difference "Changeset.count", 1 do put :create end @@ -582,9 +583,9 @@ EOF # check that the changeset bbox is within bounds cs = Changeset.find(changeset_id) assert cs.min_lon >= -180 * GeoRecord::SCALE, "Minimum longitude (#{cs.min_lon / GeoRecord::SCALE}) should be >= -180 to be valid." - assert cs.max_lon <= 180 * GeoRecord::SCALE, "Maximum longitude (#{cs.max_lon / GeoRecord::SCALE}) should be <= 180 to be valid." - assert cs.min_lat >= -90 * GeoRecord::SCALE, "Minimum latitude (#{cs.min_lat / GeoRecord::SCALE}) should be >= -90 to be valid." - assert cs.max_lat >= 90 * GeoRecord::SCALE, "Maximum latitude (#{cs.max_lat / GeoRecord::SCALE}) should be <= 90 to be valid." + assert cs.max_lon <= 180 * GeoRecord::SCALE, "Maximum longitude (#{cs.max_lon / GeoRecord::SCALE}) should be <= 180 to be valid." + assert cs.min_lat >= -90 * GeoRecord::SCALE, "Minimum latitude (#{cs.min_lat / GeoRecord::SCALE}) should be >= -90 to be valid." + assert cs.max_lat >= 90 * GeoRecord::SCALE, "Maximum latitude (#{cs.max_lat / GeoRecord::SCALE}) should be <= 90 to be valid." end ## @@ -675,7 +676,7 @@ EOF - + @@ -1102,8 +1103,8 @@ EOF basic_authorization users(:public_user).email, "test" content "" + - "" + - "" + "" + + "" put :create assert_response :success changeset_id = @response.body.to_i @@ -1114,8 +1115,8 @@ EOF 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 @@ -1140,8 +1141,8 @@ EOF basic_authorization users(:public_user).email, "test" content "" + - "" + - "" + "" + + "" put :create assert_response :success changeset_id = @response.body.to_i @@ -1181,8 +1182,7 @@ EOF ["", "", "", - "" - ].each do |diff| + ""].each do |diff| # upload it content diff post :upload, :id => changesets(:public_user_first_change).id @@ -1225,8 +1225,8 @@ EOF # create a temporary changeset content "" + - "" + - "" + "" + + "" put :create assert_response :forbidden @@ -1235,8 +1235,8 @@ EOF # create a temporary changeset content "" + - "" + - "" + "" + + "" put :create assert_response :success changeset_id = @response.body.to_i @@ -1281,8 +1281,8 @@ EOF # create a temporary changeset content "" + - "" + - "" + "" + + "" put :create assert_response :success changeset_id = @response.body.to_i @@ -1340,8 +1340,8 @@ OSMFILE # create a temporary changeset content "" + - "" + - "" + "" + + "" put :create assert_response :success changeset_id = @response.body.to_i @@ -1477,12 +1477,12 @@ EOF # 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 ## @@ -1574,7 +1574,7 @@ EOF 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" @@ -1598,8 +1598,7 @@ EOF 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 @@ -1608,8 +1607,7 @@ EOF "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 @@ -1617,8 +1615,7 @@ EOF ["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 @@ -2153,7 +2150,7 @@ EOF # test hide comment fail def test_hide_comment_fail # unauthorized - comment = changeset_comments(:normal_comment_1) + comment = create(:changeset_comment) assert_equal true, comment.visible post :hide_comment, :id => comment.id @@ -2178,7 +2175,7 @@ EOF ## # test hide comment succes def test_hide_comment_success - comment = changeset_comments(:normal_comment_1) + comment = create(:changeset_comment) assert_equal true, comment.visible basic_authorization(users(:moderator_user).email, "test") @@ -2192,7 +2189,7 @@ EOF # test unhide comment fail def test_unhide_comment_fail # unauthorized - comment = changeset_comments(:hidden_comment) + comment = create(:changeset_comment, :visible => false) assert_equal false, comment.visible post :unhide_comment, :id => comment.id @@ -2217,7 +2214,7 @@ EOF ## # test unhide comment succes def test_unhide_comment_success - comment = changeset_comments(:hidden_comment) + comment = create(:changeset_comment, :visible => false) assert_equal false, comment.visible basic_authorization(users(:moderator_user).email, "test") @@ -2230,6 +2227,8 @@ EOF ## # test comments feed def test_comments_feed + create_list(:changeset_comment, 3, :changeset_id => changesets(:normal_user_closed_change).id) + get :comments_feed, :format => "rss" assert_response :success assert_equal "application/rss+xml", @response.content_type @@ -2317,8 +2316,8 @@ EOF # 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 @@ -2334,15 +2333,16 @@ EOF # 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