From: Tom Hughes Date: Wed, 28 Oct 2020 11:29:57 +0000 (+0000) Subject: Merge remote-tracking branch 'upstream/pull/2918' into master X-Git-Tag: live~1867 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/93e49daee21b64f0af0ba7fa3035904843a028ea?hp=-c Merge remote-tracking branch 'upstream/pull/2918' into master --- 93e49daee21b64f0af0ba7fa3035904843a028ea diff --combined .rubocop_todo.yml index e983c51c6,fda213aeb..d70618e76 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@@ -18,7 -18,7 +18,7 @@@ require # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. # URISchemes: http, https Layout/LineLength: - Max: 370 + Max: 250 # Offense count: 36 # Configuration parameters: AllowSafeAssignment. @@@ -84,21 -84,6 +84,6 @@@ Metrics/PerceivedComplexity Minitest/MultipleAssertions: Max: 81 - # Offense count: 26 - # Cop supports --auto-correct. - Minitest/TestMethodName: - Exclude: - - 'test/abilities/api_capability_test.rb' - - 'test/controllers/api/nodes_controller_test.rb' - - 'test/controllers/api/old_nodes_controller_test.rb' - - 'test/controllers/api/relations_controller_test.rb' - - 'test/controllers/api/ways_controller_test.rb' - - 'test/helpers/browse_helper_test.rb' - - 'test/integration/client_applications_test.rb' - - 'test/integration/short_links_test.rb' - - 'test/integration/user_blocks_test.rb' - - 'test/integration/user_creation_test.rb' - # Offense count: 6 Naming/AccessorMethodName: Exclude: diff --combined test/controllers/api/old_nodes_controller_test.rb index cc7fae416,de3ab3f75..e85bc86f8 --- a/test/controllers/api/old_nodes_controller_test.rb +++ b/test/controllers/api/old_nodes_controller_test.rb @@@ -161,13 -161,6 +161,6 @@@ module Ap check_not_found_id_version(24356, create(:node).version) end - def check_not_found_id_version(id, version) - get node_version_path(:id => id, :version => version) - assert_response :not_found - rescue ActionController::UrlGenerationError => e - assert_match(/No route matches/, e.to_s) - end - ## # Test that getting the current version is identical to picking # that version with the version URI call. @@@ -262,15 -255,13 +255,15 @@@ get api_node_history_path(: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." + 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 auth_header = basic_authorization_header create(:user).email, "test" get api_node_history_path(:id => node_v1.node_id), :headers => auth_header 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." + 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." end ## @@@ -294,12 -285,10 +287,12 @@@ # and when accessed via history get api_node_history_path(:id => node_v3.node_id) assert_response :success, "Redaction shouldn't have stopped history working." - assert_select "osm node[id='#{node_v3.node_id}'][version='#{node_v3.version}']", 0, "node #{node_v3.node_id} version #{node_v3.version} should not be present in the history for moderators when not passing flag." + assert_select "osm node[id='#{node_v3.node_id}'][version='#{node_v3.version}']", 0, + "node #{node_v3.node_id} version #{node_v3.version} should not be present in the history for moderators when not passing flag." get api_node_history_path(:id => node_v3.node_id), :params => { :show_redactions => "true" }, :headers => auth_header assert_response :success, "Redaction shouldn't have stopped history working." - assert_select "osm node[id='#{node_v3.node_id}'][version='#{node_v3.version}']", 1, "node #{node_v3.node_id} version #{node_v3.version} should still be present in the history for moderators when passing flag." + assert_select "osm node[id='#{node_v3.node_id}'][version='#{node_v3.version}']", 1, + "node #{node_v3.node_id} version #{node_v3.version} should still be present in the history for moderators when passing flag." end # testing that if the moderator drops auth, he can't see the @@@ -322,8 -311,7 +315,8 @@@ # and when accessed via history get api_node_history_path(:id => node_v3.node_id), :headers => auth_header assert_response :success, "Redaction shouldn't have stopped history working." - assert_select "osm node[id='#{node_v3.node_id}'][version='#{node_v3.version}']", 0, "redacted node #{node_v3.node_id} version #{node_v3.version} shouldn't be present in the history." + assert_select "osm node[id='#{node_v3.node_id}'][version='#{node_v3.version}']", 0, + "redacted node #{node_v3.node_id} version #{node_v3.version} shouldn't be present in the history." end ## @@@ -375,8 -363,7 +368,8 @@@ # and when accessed via history get api_node_history_path(:id => node_v1.node_id) 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." + 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." auth_header = basic_authorization_header create(:user).email, "test" @@@ -387,8 -374,7 +380,8 @@@ # and when accessed via history get api_node_history_path(:id => node_v1.node_id) 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 normal users without passing flag." + 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 normal users without passing flag." end private @@@ -419,6 -405,13 +412,13 @@@ assert_nodes_are_equal current_node, old_node end + def check_not_found_id_version(id, version) + get node_version_path(:id => id, :version => version) + assert_response :not_found + rescue ActionController::UrlGenerationError => e + assert_match(/No route matches/, e.to_s) + end + ## # returns a 16 character long string with some nasty characters in it. # this ought to stress-test the tag handling as well as the versioning.