X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/c273b4b1faa6dd3d8aba3d5556605f683326948a..f9fee045acc2f5e3befd11ef93e26e37f9fd0c2a:/test/functional/changeset_controller_test.rb diff --git a/test/functional/changeset_controller_test.rb b/test/functional/changeset_controller_test.rb index ce739b96c..e7c19c769 100644 --- a/test/functional/changeset_controller_test.rb +++ b/test/functional/changeset_controller_test.rb @@ -95,6 +95,15 @@ class ChangesetControllerTest < ActionController::TestCase assert_select "osm>changeset[id=#{changeset_id}]", 1 end + ## + # check that a changeset that doesn't exist returns an appropriate message + def test_read_not_found + [0, -32, 233455644, "afg", "213"].each do |id| + get :read, :id => id + assert_response :not_found, "should get a not found" + end + end + ## # test that the user who opened a change can close it def test_close @@ -131,6 +140,38 @@ class ChangesetControllerTest < ActionController::TestCase assert_response :conflict assert_equal "The user doesn't own that changeset", @response.body end + + ## + # test that you can't close using another method + def test_close_method_invalid + basic_authorization users(:public_user).email, "test" + + cs_id = changesets(:public_user_first_change).id + get :close, :id => cs_id + assert_response :method_not_allowed + + post :close, :id => cs_id + assert_response :method_not_allowed + end + + ## + # check that you can't close a changeset that isn't found + def test_close_not_found + cs_ids = [0, -132, "123"] + + # First try to do it with no auth + cs_ids.each do |id| + put :close, :id => id + assert_response :unauthorized, "Shouldn't be able close the non-existant changeset #{id}, when not authorized" + end + + # Now try with auth + basic_authorization users(:public_user).email, "test" + cs_ids.each do |id| + put :close, :id => id + assert_response :not_found, "The changeset #{id} doesn't exist, so can't be closed" + end + end ## # upload something simple, but valid and check that it can @@ -1382,7 +1423,7 @@ EOF assert_template "list" # Now check that all 20 (or however many were returned) changesets are in the html assert_select "h1", :text => "Recent Changes", :count => 1 - assert_select "table[id='keyvalue'] tr", :count => @changesets.size + 1 + assert_select "table[id='changeset_list'] tr", :count => @changesets.size + 1 @changesets.each do |changeset| # FIXME this test needs rewriting - test for table contents end