]> git.openstreetmap.org Git - rails.git/commitdiff
Merge remote-tracking branch 'upstream/pull/2918' into master
authorTom Hughes <tom@compton.nu>
Wed, 28 Oct 2020 11:29:57 +0000 (11:29 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 28 Oct 2020 11:29:57 +0000 (11:29 +0000)
1  2 
.rubocop_todo.yml
test/controllers/api/old_nodes_controller_test.rb

diff --combined .rubocop_todo.yml
index e983c51c64fed85fe13a3ed4c69bd605da32e884,fda213aebe4b647b6b560a858a890e9f3f60b957..d70618e766295c2b5cb72271929d60db0bac136a
@@@ -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:
index cc7fae416247474926a6351bf92b58b035013b60,de3ab3f75018ca396293ba6989703593bb3e12aa..e85bc86f85044592d895fc2a6186db818464a7ae
@@@ -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.
  
        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
  
      ##
        # 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
        # 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
  
      ##
        # 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"
  
        # 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
        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.