X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/03408b6294e0aa56d46823c1f44d47aaf69e226b..d0e45c7c8e85c5536970fc0ac98f5f9626ebf3c8:/test/controllers/old_node_controller_test.rb?ds=sidebyside diff --git a/test/controllers/old_node_controller_test.rb b/test/controllers/old_node_controller_test.rb index be4254279..346634f7d 100644 --- a/test/controllers/old_node_controller_test.rb +++ b/test/controllers/old_node_controller_test.rb @@ -40,7 +40,7 @@ class OldNodeControllerTest < ActionController::TestCase propagate_tags(node, node.old_nodes.last) ## First try this with a non-public user - basic_authorization(private_user.email, "test") + basic_authorization private_user.email, "test" # setup a simple XML node xml_doc = private_node.to_xml @@ -55,7 +55,7 @@ class OldNodeControllerTest < ActionController::TestCase versions[xml_node["version"]] = xml_doc.to_s # randomly move the node about - 20.times do + 3.times do # move the node somewhere else xml_node["lat"] = precision(rand * 180 - 90).to_s xml_node["lon"] = precision(rand * 360 - 180).to_s @@ -70,7 +70,7 @@ class OldNodeControllerTest < ActionController::TestCase end # add a bunch of random tags - 30.times do + 3.times do xml_tag = XML::Node.new("tag") xml_tag["k"] = random_string xml_tag["v"] = random_string @@ -89,7 +89,7 @@ class OldNodeControllerTest < ActionController::TestCase # probably should check that they didn't get written to the database ## Now do it with the public user - basic_authorization(user.email, "test") + basic_authorization user.email, "test" # setup a simple XML node @@ -105,7 +105,7 @@ class OldNodeControllerTest < ActionController::TestCase versions[xml_node["version"]] = xml_doc.to_s # randomly move the node about - 20.times do + 3.times do # move the node somewhere else xml_node["lat"] = precision(rand * 180 - 90).to_s xml_node["lon"] = precision(rand * 360 - 180).to_s @@ -120,7 +120,7 @@ class OldNodeControllerTest < ActionController::TestCase end # add a bunch of random tags - 30.times do + 3.times do xml_tag = XML::Node.new("tag") xml_tag["k"] = random_string xml_tag["v"] = random_string @@ -137,7 +137,7 @@ class OldNodeControllerTest < ActionController::TestCase end # check all the versions - versions.keys.each do |key| + versions.each_key do |key| get :version, :params => { :id => nodeid, :version => key.to_i } assert_response :success, @@ -161,7 +161,7 @@ class OldNodeControllerTest < ActionController::TestCase get :version, :params => { :id => id, :version => version } assert_response :not_found rescue ActionController::UrlGenerationError => ex - assert_match /No route matches/, ex.to_s + assert_match(/No route matches/, ex.to_s) end ## @@ -206,7 +206,7 @@ class OldNodeControllerTest < ActionController::TestCase # test the redaction of an old version of a node, while being # authorised as a normal user. def test_redact_node_normal_user - basic_authorization(create(:user).email, "test") + basic_authorization create(:user).email, "test" node = create(:node, :with_history, :version => 4) node_v3 = node.old_nodes.find_by(:version => 3) @@ -220,7 +220,7 @@ class OldNodeControllerTest < ActionController::TestCase # test that, even as moderator, the current version of a node # can't be redacted. def test_redact_node_current_version - basic_authorization(create(:moderator_user).email, "test") + basic_authorization create(:moderator_user).email, "test" node = create(:node, :with_history, :version => 4) node_v4 = node.old_nodes.find_by(:version => 4) @@ -242,7 +242,7 @@ class OldNodeControllerTest < ActionController::TestCase assert_response :forbidden, "Redacted node shouldn't be visible via the version API." # not even to a logged-in user - basic_authorization(create(:user).email, "test") + basic_authorization create(:user).email, "test" get :version, :params => { :id => node_v1.node_id, :version => node_v1.version } assert_response :forbidden, "Redacted node shouldn't be visible via the version API, even when logged in." end @@ -259,7 +259,7 @@ class OldNodeControllerTest < ActionController::TestCase assert_select "osm node[id='#{node_v1.node_id}'][version='#{node_v1.version}']", 0, "redacted node #{node_v1.node_id} version #{node_v1.version} shouldn't be present in the history." # not even to a logged-in user - basic_authorization(create(:user).email, "test") + basic_authorization create(:user).email, "test" get :history, :params => { :id => node_v1.node_id } assert_response :success, "Redaction shouldn't have stopped history working." assert_select "osm node[id='#{node_v1.node_id}'][version='#{node_v1.version}']", 0, "redacted node #{node_v1.node_id} version #{node_v1.version} shouldn't be present in the history, even when logged in." @@ -271,7 +271,7 @@ class OldNodeControllerTest < ActionController::TestCase def test_redact_node_moderator node = create(:node, :with_history, :version => 4) node_v3 = node.old_nodes.find_by(:version => 3) - basic_authorization(create(:moderator_user).email, "test") + basic_authorization create(:moderator_user).email, "test" do_redact_node(node_v3, create(:redaction)) assert_response :success, "should be OK to redact old version as moderator." @@ -297,13 +297,13 @@ class OldNodeControllerTest < ActionController::TestCase def test_redact_node_is_redacted node = create(:node, :with_history, :version => 4) node_v3 = node.old_nodes.find_by(:version => 3) - basic_authorization(create(:moderator_user).email, "test") + basic_authorization create(:moderator_user).email, "test" do_redact_node(node_v3, create(:redaction)) assert_response :success, "should be OK to redact old version as moderator." # re-auth as non-moderator - basic_authorization(create(:user).email, "test") + basic_authorization create(:user).email, "test" # check can't see the redacted data get :version, :params => { :id => node_v3.node_id, :version => node_v3.version } @@ -336,7 +336,7 @@ class OldNodeControllerTest < ActionController::TestCase node_v1 = node.old_nodes.find_by(:version => 1) node_v1.redact!(create(:redaction)) - basic_authorization(user.email, "test") + basic_authorization user.email, "test" post :redact, :params => { :id => node_v1.node_id, :version => node_v1.version } assert_response :forbidden, "should need to be moderator to unredact." @@ -351,7 +351,7 @@ class OldNodeControllerTest < ActionController::TestCase node_v1 = node.old_nodes.find_by(:version => 1) node_v1.redact!(create(:redaction)) - basic_authorization(moderator_user.email, "test") + basic_authorization moderator_user.email, "test" post :redact, :params => { :id => node_v1.node_id, :version => node_v1.version } assert_response :success, "should be OK to unredact old version as moderator." @@ -366,7 +366,7 @@ class OldNodeControllerTest < ActionController::TestCase assert_response :success, "Unredaction shouldn't have stopped history working." assert_select "osm node[id='#{node_v1.node_id}'][version='#{node_v1.version}']", 1, "node #{node_v1.node_id} version #{node_v1.version} should now be present in the history for moderators without passing flag." - basic_authorization(create(:user).email, "test") + basic_authorization create(:user).email, "test" # check normal user can now see the redacted data get :version, :params => { :id => node_v1.node_id, :version => node_v1.version }