From c04d05686f4014a1f729b7194913a0fe1b36e915 Mon Sep 17 00:00:00 2001 From: Andy Allan Date: Wed, 28 Oct 2020 11:07:34 +0100 Subject: [PATCH] Resolve some extra-long lines --- .rubocop_todo.yml | 2 +- test/controllers/api/map_controller_test.rb | 26 ++++++++++++++++--- .../api/old_nodes_controller_test.rb | 21 ++++++++++----- .../api/old_relations_controller_test.rb | 21 ++++++++++----- .../api/old_ways_controller_test.rb | 21 ++++++++++----- test/helpers/browse_tags_helper_test.rb | 3 ++- test/lib/locale_test.rb | 7 ++++- 7 files changed, 73 insertions(+), 28 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 73b8cfa3f..e983c51c6 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -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. diff --git a/test/controllers/api/map_controller_test.rb b/test/controllers/api/map_controller_test.rb index 607c4e421..e9459b6a2 100644 --- a/test/controllers/api/map_controller_test.rb +++ b/test/controllers/api/map_controller_test.rb @@ -131,8 +131,17 @@ module Api end assert_response :success, "Expected scucess with the map call" assert_select "osm[version='#{Settings.api_version}'][generator='#{Settings.generator}']", :count => 1 do - assert_select "bounds[minlon='#{format('%.7f', :lon => minlon)}'][minlat='#{format('%.7f', :lat => minlat)}'][maxlon='#{format('%.7f', :lon => maxlon)}'][maxlat='#{format('%.7f', :lat => maxlat)}']", :count => 1 - assert_select "node[id='#{node.id}'][lat='#{format('%.7f', :lat => node.lat)}'][lon='#{format('%.7f', :lon => node.lon)}'][version='#{node.version}'][changeset='#{node.changeset_id}'][visible='#{node.visible}'][timestamp='#{node.timestamp.xmlschema}']", :count => 1 do + assert_select "bounds[minlon='#{format('%.7f', :lon => minlon)}']" \ + "[minlat='#{format('%.7f', :lat => minlat)}']" \ + "[maxlon='#{format('%.7f', :lon => maxlon)}']" \ + "[maxlat='#{format('%.7f', :lat => maxlat)}']", :count => 1 + assert_select "node[id='#{node.id}']" \ + "[lat='#{format('%.7f', :lat => node.lat)}']" \ + "[lon='#{format('%.7f', :lon => node.lon)}']" \ + "[version='#{node.version}']" \ + "[changeset='#{node.changeset_id}']" \ + "[visible='#{node.visible}']" \ + "[timestamp='#{node.timestamp.xmlschema}']", :count => 1 do # This should really be more generic assert_select "tag[k='#{tag.k}'][v='#{tag.v}']" end @@ -205,8 +214,17 @@ module Api get map_path(:bbox => bbox) assert_response :success, "The map call should have succeeded" assert_select "osm[version='#{Settings.api_version}'][generator='#{Settings.generator}']", :count => 1 do - assert_select "bounds[minlon='#{node.lon}'][minlat='#{node.lat}'][maxlon='#{node.lon}'][maxlat='#{node.lat}']", :count => 1 - assert_select "node[id='#{node.id}'][lat='#{format('%.7f', :lat => node.lat)}'][lon='#{format('%.7f', :lon => node.lon)}'][version='#{node.version}'][changeset='#{node.changeset_id}'][visible='#{node.visible}'][timestamp='#{node.timestamp.xmlschema}']", :count => 1 do + assert_select "bounds[minlon='#{node.lon}']" \ + "[minlat='#{node.lat}']" \ + "[maxlon='#{node.lon}']" \ + "[maxlat='#{node.lat}']", :count => 1 + assert_select "node[id='#{node.id}']" \ + "[lat='#{format('%.7f', :lat => node.lat)}']" \ + "[lon='#{format('%.7f', :lon => node.lon)}']" \ + "[version='#{node.version}']" \ + "[changeset='#{node.changeset_id}']" \ + "[visible='#{node.visible}']" \ + "[timestamp='#{node.timestamp.xmlschema}']", :count => 1 do # This should really be more generic assert_select "tag[k='#{tag.k}'][v='#{tag.v}']" end diff --git a/test/controllers/api/old_nodes_controller_test.rb b/test/controllers/api/old_nodes_controller_test.rb index 6d2303831..cc7fae416 100644 --- a/test/controllers/api/old_nodes_controller_test.rb +++ b/test/controllers/api/old_nodes_controller_test.rb @@ -262,13 +262,15 @@ module Api 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 ## @@ -292,10 +294,12 @@ module Api # 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 @@ -318,7 +322,8 @@ module Api # 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 ## @@ -370,7 +375,8 @@ module Api # 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" @@ -381,7 +387,8 @@ module Api # 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 diff --git a/test/controllers/api/old_relations_controller_test.rb b/test/controllers/api/old_relations_controller_test.rb index d5431e8af..d51665b03 100644 --- a/test/controllers/api/old_relations_controller_test.rb +++ b/test/controllers/api/old_relations_controller_test.rb @@ -103,14 +103,16 @@ module Api get api_relation_history_path(:id => relation_v1.relation_id) assert_response :success, "Redaction shouldn't have stopped history working." - assert_select "osm relation[id='#{relation_v1.relation_id}'][version='#{relation_v1.version}']", 0, "redacted relation #{relation_v1.relation_id} version #{relation_v1.version} shouldn't be present in the history." + assert_select "osm relation[id='#{relation_v1.relation_id}'][version='#{relation_v1.version}']", 0, + "redacted relation #{relation_v1.relation_id} version #{relation_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 relation_version_path(:id => relation_v1.relation_id, :version => relation_v1.version), :headers => auth_header get api_relation_history_path(:id => relation_v1.relation_id), :headers => auth_header assert_response :success, "Redaction shouldn't have stopped history working." - assert_select "osm relation[id='#{relation_v1.relation_id}'][version='#{relation_v1.version}']", 0, "redacted relation #{relation_v1.relation_id} version #{relation_v1.version} shouldn't be present in the history, even when logged in." + assert_select "osm relation[id='#{relation_v1.relation_id}'][version='#{relation_v1.version}']", 0, + "redacted relation #{relation_v1.relation_id} version #{relation_v1.version} shouldn't be present in the history, even when logged in." end ## @@ -135,10 +137,12 @@ module Api # and when accessed via history get api_relation_history_path(:id => relation_v3.relation_id), :headers => auth_header assert_response :success, "Redaction shouldn't have stopped history working." - assert_select "osm relation[id='#{relation_v3.relation_id}'][version='#{relation_v3.version}']", 0, "relation #{relation_v3.relation_id} version #{relation_v3.version} should not be present in the history for moderators when not passing flag." + assert_select "osm relation[id='#{relation_v3.relation_id}'][version='#{relation_v3.version}']", 0, + "relation #{relation_v3.relation_id} version #{relation_v3.version} should not be present in the history for moderators when not passing flag." get api_relation_history_path(:id => relation_v3.relation_id), :params => { :show_redactions => "true" }, :headers => auth_header assert_response :success, "Redaction shouldn't have stopped history working." - assert_select "osm relation[id='#{relation_v3.relation_id}'][version='#{relation_v3.version}']", 1, "relation #{relation_v3.relation_id} version #{relation_v3.version} should still be present in the history for moderators when passing flag." + assert_select "osm relation[id='#{relation_v3.relation_id}'][version='#{relation_v3.version}']", 1, + "relation #{relation_v3.relation_id} version #{relation_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 @@ -162,7 +166,8 @@ module Api # and when accessed via history get api_relation_history_path(:id => relation_v3.relation_id), :headers => auth_header assert_response :success, "Redaction shouldn't have stopped history working." - assert_select "osm relation[id='#{relation_v3.relation_id}'][version='#{relation_v3.version}']", 0, "redacted relation #{relation_v3.relation_id} version #{relation_v3.version} shouldn't be present in the history." + assert_select "osm relation[id='#{relation_v3.relation_id}'][version='#{relation_v3.version}']", 0, + "redacted relation #{relation_v3.relation_id} version #{relation_v3.version} shouldn't be present in the history." end ## @@ -212,7 +217,8 @@ module Api # and when accessed via history get api_relation_history_path(:id => relation_v1.relation_id), :headers => auth_header assert_response :success, "Redaction shouldn't have stopped history working." - assert_select "osm relation[id='#{relation_v1.relation_id}'][version='#{relation_v1.version}']", 1, "relation #{relation_v1.relation_id} version #{relation_v1.version} should still be present in the history for moderators." + assert_select "osm relation[id='#{relation_v1.relation_id}'][version='#{relation_v1.version}']", 1, + "relation #{relation_v1.relation_id} version #{relation_v1.version} should still be present in the history for moderators." auth_header = basic_authorization_header create(:user).email, "test" @@ -223,7 +229,8 @@ module Api # and when accessed via history get api_relation_history_path(:id => relation_v1.relation_id), :headers => auth_header assert_response :success, "Redaction shouldn't have stopped history working." - assert_select "osm relation[id='#{relation_v1.relation_id}'][version='#{relation_v1.version}']", 1, "relation #{relation_v1.relation_id} version #{relation_v1.version} should still be present in the history for normal users." + assert_select "osm relation[id='#{relation_v1.relation_id}'][version='#{relation_v1.version}']", 1, + "relation #{relation_v1.relation_id} version #{relation_v1.version} should still be present in the history for normal users." end private diff --git a/test/controllers/api/old_ways_controller_test.rb b/test/controllers/api/old_ways_controller_test.rb index c77117589..6c4eb16a1 100644 --- a/test/controllers/api/old_ways_controller_test.rb +++ b/test/controllers/api/old_ways_controller_test.rb @@ -144,14 +144,16 @@ module Api get api_way_history_path(:id => way_v1.way_id) assert_response :success, "Redaction shouldn't have stopped history working." - assert_select "osm way[id='#{way_v1.way_id}'][version='#{way_v1.version}']", 0, "redacted way #{way_v1.way_id} version #{way_v1.version} shouldn't be present in the history." + assert_select "osm way[id='#{way_v1.way_id}'][version='#{way_v1.version}']", 0, + "redacted way #{way_v1.way_id} version #{way_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 way_version_path(:id => way_v1.way_id, :version => way_v1.version), :headers => auth_header get api_way_history_path(:id => way_v1.way_id), :headers => auth_header assert_response :success, "Redaction shouldn't have stopped history working." - assert_select "osm way[id='#{way_v1.way_id}'][version='#{way_v1.version}']", 0, "redacted node #{way_v1.way_id} version #{way_v1.version} shouldn't be present in the history, even when logged in." + assert_select "osm way[id='#{way_v1.way_id}'][version='#{way_v1.version}']", 0, + "redacted node #{way_v1.way_id} version #{way_v1.version} shouldn't be present in the history, even when logged in." end ## @@ -175,10 +177,12 @@ module Api # and when accessed via history get api_way_history_path(:id => way_v3.way_id), :headers => auth_header assert_response :success, "Redaction shouldn't have stopped history working." - assert_select "osm way[id='#{way_v3.way_id}'][version='#{way_v3.version}']", 0, "way #{way_v3.way_id} version #{way_v3.version} should not be present in the history for moderators when not passing flag." + assert_select "osm way[id='#{way_v3.way_id}'][version='#{way_v3.version}']", 0, + "way #{way_v3.way_id} version #{way_v3.version} should not be present in the history for moderators when not passing flag." get api_way_history_path(:id => way_v3.way_id), :params => { :show_redactions => "true" }, :headers => auth_header assert_response :success, "Redaction shouldn't have stopped history working." - assert_select "osm way[id='#{way_v3.way_id}'][version='#{way_v3.version}']", 1, "way #{way_v3.way_id} version #{way_v3.version} should still be present in the history for moderators when passing flag." + assert_select "osm way[id='#{way_v3.way_id}'][version='#{way_v3.version}']", 1, + "way #{way_v3.way_id} version #{way_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 @@ -201,7 +205,8 @@ module Api # and when accessed via history get api_way_history_path(:id => way_v3.way_id), :headers => auth_header assert_response :success, "Redaction shouldn't have stopped history working." - assert_select "osm way[id='#{way_v3.way_id}'][version='#{way_v3.version}']", 0, "redacted way #{way_v3.way_id} version #{way_v3.version} shouldn't be present in the history." + assert_select "osm way[id='#{way_v3.way_id}'][version='#{way_v3.version}']", 0, + "redacted way #{way_v3.way_id} version #{way_v3.version} shouldn't be present in the history." end ## @@ -252,7 +257,8 @@ module Api # and when accessed via history get api_way_history_path(:id => way_v1.way_id), :headers => auth_header assert_response :success, "Unredaction shouldn't have stopped history working." - assert_select "osm way[id='#{way_v1.way_id}'][version='#{way_v1.version}']", 1, "way #{way_v1.way_id} version #{way_v1.version} should still be present in the history for moderators." + assert_select "osm way[id='#{way_v1.way_id}'][version='#{way_v1.version}']", 1, + "way #{way_v1.way_id} version #{way_v1.version} should still be present in the history for moderators." auth_header = basic_authorization_header create(:user).email, "test" @@ -263,7 +269,8 @@ module Api # and when accessed via history get api_way_history_path(:id => way_v1.way_id), :headers => auth_header assert_response :success, "Redaction shouldn't have stopped history working." - assert_select "osm way[id='#{way_v1.way_id}'][version='#{way_v1.version}']", 1, "way #{way_v1.way_id} version #{way_v1.version} should still be present in the history for normal users." + assert_select "osm way[id='#{way_v1.way_id}'][version='#{way_v1.version}']", 1, + "way #{way_v1.way_id} version #{way_v1.version} should still be present in the history for normal users." end private diff --git a/test/helpers/browse_tags_helper_test.rb b/test/helpers/browse_tags_helper_test.rb index fb90eb51d..5574513c2 100644 --- a/test/helpers/browse_tags_helper_test.rb +++ b/test/helpers/browse_tags_helper_test.rb @@ -43,7 +43,8 @@ class BrowseTagsHelperTest < ActionView::TestCase assert_dom_equal "Q42", html html = format_value("operator:wikidata", "Q12;Q98") - assert_dom_equal "Q12;Q98", html + assert_dom_equal "Q12;" \ + "Q98", html html = format_value("name:etymology:wikidata", "Q123") assert_dom_equal "Q123", html diff --git a/test/lib/locale_test.rb b/test/lib/locale_test.rb index a005b03d5..7b02b3f1f 100644 --- a/test/lib/locale_test.rb +++ b/test/lib/locale_test.rb @@ -91,7 +91,12 @@ class LocaleTest < ActiveSupport::TestCase assert_equal "de", Locale.available.preferred(Locale.list("zh-Hant", "de")).to_s assert_equal "zh-TW", Locale.available.preferred(Locale.list("zh-Hant-TW", "de")).to_s assert_equal "zh-TW", Locale.available.preferred(Locale.list("zh-TW", "de")).to_s - assert_equal "zh-HK", Locale.available.preferred(Locale.list("zh-HK", "zh-hk", "zh-Hant", "zh-hant", "zh-TW", "zh-tw", "zh", "zh-yue", "yue", "yue-Hant", "yue-HK", "yue-Hans", "zh-classical", "lzh", "ja-Hani", "ko-Hani", "ko_hanja", "vi-Hani", "ja-hani", "ko-hani", "vi-hani", "en-HK", "en-hk", "en-SG", "en-sg", "en-GB", "en-gb", "en-US", "en-us", "en", "ja")).to_s + assert_equal "zh-HK", Locale.available.preferred( + Locale.list("zh-HK", "zh-hk", "zh-Hant", "zh-hant", "zh-TW", "zh-tw", "zh", "zh-yue", + "yue", "yue-Hant", "yue-HK", "yue-Hans", "zh-classical", "lzh", "ja-Hani", + "ko-Hani", "ko_hanja", "vi-Hani", "ja-hani", "ko-hani", "vi-hani", "en-HK", + "en-hk", "en-SG", "en-sg", "en-GB", "en-gb", "en-US", "en-us", "en", "ja") + ).to_s assert_equal "en", Locale.available.preferred(Locale.list("yue")).to_s end end -- 2.39.5