]> git.openstreetmap.org Git - rails.git/commitdiff
Merge remote-tracking branch 'upstream/pull/5702'
authorTom Hughes <tom@compton.nu>
Wed, 19 Feb 2025 18:10:22 +0000 (18:10 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 19 Feb 2025 18:10:22 +0000 (18:10 +0000)
14 files changed:
.overcommit.yml
.vscode/settings.json
Gemfile.lock
app/assets/javascripts/index/directions.js
app/assets/javascripts/index/search.js
app/controllers/dashboards_controller.rb
app/views/dashboards/_contact.html.erb
app/views/dashboards/show.html.erb
config/eslint.config.mjs [moved from config/eslint.js with 94% similarity]
lib/tasks/eslint.rake
package.json
test/controllers/api/changesets_controller_test.rb
test/controllers/dashboards_controller_test.rb
yarn.lock

index eab8eb2ae90e02dff71964c8710457473be82439..18bd5851f4526d8850cd736180fd80c027cfcdaa 100644 (file)
@@ -22,7 +22,7 @@ PreCommit:
     enabled: true
   EsLint:
     enabled: true
-    command: ["bin/yarn", "eslint", "-c", "config/eslint.js"]
+    command: ["bin/yarn", "eslint", "-c", "config/eslint.config.mjs"]
     exclude:
       - vendor/**/*.js
   RailsSchemaUpToDate:
index 8a3d341d48ce67d2541e9255b90bc5d7b6c18729..3545f07279b2b802c2be21b034336862152aa504 100644 (file)
@@ -1,5 +1,5 @@
 {
   "eslint.options": {
-    "overrideConfigFile": "config/eslint.js"
+    "overrideConfigFile": "config/eslint.config.mjs"
   }
 }
index f0dd7a22587c9137442668e077a7d901a08ff5f7..c5f6f4b796538c69d49992ce0037c41db4c16b0a 100644 (file)
@@ -399,7 +399,7 @@ GEM
     net-smtp (0.5.1)
       net-protocol
     nio4r (2.7.4)
-    nokogiri (1.18.2)
+    nokogiri (1.18.3)
       mini_portile2 (~> 2.8.2)
       racc (~> 1.4)
     oauth (1.1.0)
index 2338f537f581224b3e141636e83b662857de8236..3d6da84fc8d279d51e723dc0babfd3f721833ebb 100644 (file)
@@ -73,8 +73,8 @@ OSM.Directions = function (map) {
 
   $(".directions_form .btn-close").on("click", function (e) {
     e.preventDefault();
-    $(".describe_location").toggle(!endpoints[0].value);
-    $(".search_form input[name='query']").val(endpoints[0].value);
+    $(".describe_location").toggle(!endpoints[1].value);
+    $(".search_form input[name='query']").val(endpoints[1].value);
     OSM.router.route("/" + OSM.formatHash(map));
   });
 
index 42294576b7bb0fba584a1c181107b9c66f06db7a..b33d904a97613ca3c5369bfa453a9b3b3de9eb44 100644 (file)
@@ -11,7 +11,7 @@ OSM.Search = function (map) {
     e.preventDefault();
     const query = $(this).closest("form").find("input[name=query]").val();
     let search = "";
-    if (query) search = "?" + new URLSearchParams({ from: query });
+    if (query) search = "?" + new URLSearchParams({ to: query });
     OSM.router.route("/directions" + search + OSM.formatHash(map));
   });
 
index 540683d25ea0e89c2ed63b55f8d7949d5cdbfe9d..cb73cc38f35baaa76214ca5f15c19d12c400140d 100644 (file)
@@ -9,6 +9,7 @@ class DashboardsController < ApplicationController
   before_action :check_database_readable
 
   def show
-    @user = current_user
+    @followings = current_user.followings
+    @nearby_users = current_user.nearby - @followings
   end
 end
index 8e78524decb463730cfc2f863151aba6639b8fa1..021f1a33585e7e5dac88e25bdfe894eb211c310b 100644 (file)
@@ -11,8 +11,8 @@
   <div class="col">
     <p class='text-body-secondary mb-0'>
       <%= link_to contact.display_name, contact %>
-      <% if @user.home_location? and contact.home_location? %>
-        <% distance = @user.distance(contact) %>
+      <% if current_user.home_location? and contact.home_location? %>
+        <% distance = current_user.distance(contact) %>
         <% if distance < 1 %>
           (<%= t ".m away", :count => (distance * 1000).round %>)
         <% else %>
index 70dae774e86eef0a3e5e9567b2f75d46d9791755..e110ad531f1f11ad66b4464e24a39a3e52f7ead9 100644 (file)
@@ -3,63 +3,58 @@
 <% end %>
 
 <div class="row">
-  <% if current_user and @user.id == current_user.id %>
-    <div class="col-md order-md-last">
-      <% if !@user.home_location? %>
-        <div id="map" class="content_map border border-secondary-subtle">
-          <p class="m-3"><%= t(".no_home_location_html", :edit_profile_link => link_to(t(".edit_your_profile"), edit_profile_path)) %></p>
-        </div>
-      <% else %>
-        <% content_for :head do %>
-          <%= javascript_include_tag "user" %>
-        <% end %>
-        <% user_data = {
-             :lon => current_user.home_lon,
-             :lat => current_user.home_lat,
-             :icon => image_path("marker-red.png"),
-             :description => render(:partial => "popup", :object => current_user, :locals => { :type => "your location" })
-           } %>
-        <%= tag.div "", :id => "map", :class => "content_map border border-secondary-subtle rounded z-0", :data => { :user => user_data } %>
+  <div class="col-md order-md-last">
+    <% if !current_user.home_location? %>
+      <div id="map" class="content_map border border-secondary-subtle">
+        <p class="m-3"><%= t(".no_home_location_html", :edit_profile_link => link_to(t(".edit_your_profile"), edit_profile_path)) %></p>
+      </div>
+    <% else %>
+      <% content_for :head do %>
+        <%= javascript_include_tag "user" %>
       <% end %>
+      <% user_data = {
+           :lon => current_user.home_lon,
+           :lat => current_user.home_lat,
+           :icon => image_path("marker-red.png"),
+           :description => render(:partial => "popup", :object => current_user, :locals => { :type => "your location" })
+         } %>
+      <%= tag.div "", :id => "map", :class => "content_map border border-secondary-subtle rounded z-0", :data => { :user => user_data } %>
+    <% end %>
+  </div>
 
-      <% followings = @user.followings %>
-      <% nearby = @user.nearby - followings %>
-    </div>
+  <div class="col-md">
+    <h2><%= t ".followings" %></h2>
 
-    <div class="col-md">
-      <h2><%= t ".followings" %></h2>
+    <% if @followings.empty? %>
+      <%= t ".no followings" %>
+    <% else %>
+      <nav class='secondary-actions mb-3'>
+        <ul class='clearfix'>
+          <li><%= link_to t(".followed_changesets"), friend_changesets_path %></li>
+          <li><%= link_to t(".followed_diaries"), friends_diary_entries_path %></li>
+        </ul>
+      </nav>
+      <div>
+        <%= render :partial => "contact", :collection => @followings, :locals => { :type => "following" } %>
+      </div>
+    <% end %>
 
-      <% if followings.empty? %>
-        <%= t ".no followings" %>
-      <% else %>
-        <nav class='secondary-actions mb-3'>
-          <ul class='clearfix'>
-            <li><%= link_to t(".followed_changesets"), friend_changesets_path %></li>
-            <li><%= link_to t(".followed_diaries"), friends_diary_entries_path %></li>
-          </ul>
-        </nav>
-        <div>
-          <%= render :partial => "contact", :collection => followings, :locals => { :type => "following" } %>
-        </div>
-      <% end %>
-
-      <hr>
+    <hr>
 
-      <h2><%= t ".nearby users" %></h2>
+    <h2><%= t ".nearby users" %></h2>
 
-      <% if nearby.empty? %>
-        <%= t ".no nearby users" %>
-      <% else %>
-        <nav class='secondary-actions mb-3'>
-          <ul class='clearfix'>
-            <li><%= link_to t(".nearby_changesets"), nearby_changesets_path %></li>
-            <li><%= link_to t(".nearby_diaries"), nearby_diary_entries_path %></li>
-          </ul>
-        </nav>
-        <div id="nearbyusers">
-          <%= render :partial => "contact", :collection => nearby, :locals => { :type => "nearby mapper" } %>
-        </div>
-      <% end %>
-    </div>
-  <% end %>
+    <% if @nearby_users.empty? %>
+      <%= t ".no nearby users" %>
+    <% else %>
+      <nav class='secondary-actions mb-3'>
+        <ul class='clearfix'>
+          <li><%= link_to t(".nearby_changesets"), nearby_changesets_path %></li>
+          <li><%= link_to t(".nearby_diaries"), nearby_diary_entries_path %></li>
+        </ul>
+      </nav>
+      <div id="nearbyusers">
+        <%= render :partial => "contact", :collection => @nearby_users, :locals => { :type => "nearby mapper" } %>
+      </div>
+    <% end %>
+  </div>
 </div>
similarity index 94%
rename from config/eslint.js
rename to config/eslint.config.mjs
index 6055634aa5a7ef6afab684f4adbb8d988f2a12a6..d695f0131db7b1f916cf42c64514ce64806f1dbe 100644 (file)
@@ -1,9 +1,9 @@
-const globals = require("globals");
-const js = require("@eslint/js");
-const erb = require("eslint-plugin-erb");
-const stylisticJs = require("@stylistic/eslint-plugin-js");
+import globals from "globals";
+import js from "@eslint/js";
+import erb from "eslint-plugin-erb";
+import stylisticJs from "@stylistic/eslint-plugin-js";
 
-module.exports = [
+export default [
   js.configs.recommended,
   erb.configs.recommended,
   {
@@ -164,13 +164,9 @@ module.exports = [
     }
   },
   {
-    files: ["config/eslint.js"],
+    files: ["config/eslint.config.mjs"],
     languageOptions: {
-      ecmaVersion: 2019,
-      sourceType: "commonjs",
-      globals: {
-        ...globals.commonjs
-      }
+      sourceType: "module"
     },
     rules: {
       "sort-keys": ["error", "asc", { minKeys: 5 }]
index 17f28a4e9cb4ef134a4ac205690159499ff3b9ad..8a8d7c8a44cf65da918491d5f187c39a535a316a 100644 (file)
@@ -5,7 +5,7 @@ def yarn_path
 end
 
 def config_file
-  Rails.root.join("config/eslint.js").to_s
+  Rails.root.join("config/eslint.config.mjs").to_s
 end
 
 namespace "eslint" do
index f4eacf962b456f837bcc8d4c50157786533a0d86..f8eac3db914233eda8262f34e18f2a05cd80be97 100644 (file)
@@ -9,11 +9,11 @@
     "osm-community-index": "^5.2.0"
   },
   "devDependencies": {
-    "@types/jquery": "^3.5.32",
-    "@types/leaflet": "^1.9.16",
+    "@types/jquery": "^3.5.0",
+    "@types/leaflet": "^1.9.0",
     "eslint": "^9.0.0",
     "eslint-plugin-erb": "^2.1.0",
-    "@stylistic/eslint-plugin-js": "^3.0.0",
+    "@stylistic/eslint-plugin-js": "^4.0.0",
     "eslint-formatter-compact": "^8.40.0"
   }
 }
index a1880f0534a03b87650ab4e7fa59d2b40dcb46ed..ff77ef6cec43a4f3c6debe7c477c492efad3a9ff 100644 (file)
@@ -249,6 +249,22 @@ module Api
       end
     end
 
+    def test_show_tags
+      changeset = create(:changeset, :closed)
+      create(:changeset_tag, :changeset => changeset, :k => "created_by", :v => "JOSM/1.5 (18364)")
+      create(:changeset_tag, :changeset => changeset, :k => "comment", :v => "changeset comment")
+
+      get changeset_show_path(changeset)
+
+      assert_response :success
+      assert_dom "osm[version='#{Settings.api_version}'][generator='#{Settings.generator}']", 1
+      assert_single_changeset changeset do
+        assert_dom "> tag", 2
+        assert_dom "> tag[k='created_by'][v='JOSM/1.5 (18364)']", 1
+        assert_dom "> tag[k='comment'][v='changeset comment']", 1
+      end
+    end
+
     def test_show_json
       changeset = create(:changeset)
 
@@ -358,26 +374,22 @@ module Api
       assert js["changeset"]["comments"][2]["visible"]
     end
 
-    def test_show_tag_and_discussion_json
+    def test_show_tags_json
       changeset = create(:changeset, :closed)
       create(:changeset_tag, :changeset => changeset, :k => "created_by", :v => "JOSM/1.5 (18364)")
       create(:changeset_tag, :changeset => changeset, :k => "comment", :v => "changeset comment")
-      create_list(:changeset_comment, 3, :changeset_id => changeset.id)
 
-      get changeset_show_path(changeset), :params => { :format => "json", :include_discussion => true }
-      assert_response :success, "cannot get closed changeset with comments"
+      get changeset_show_path(changeset, :format => "json")
 
+      assert_response :success
       js = ActiveSupport::JSON.decode(@response.body)
-
       assert_not_nil js
       assert_equal Settings.api_version, js["version"]
       assert_equal Settings.generator, js["generator"]
       assert_single_changeset_json changeset, js
       assert_equal 2, js["changeset"]["tags"].count
-      assert_equal 3, js["changeset"]["comments"].count
-      assert_not_nil js["changeset"]["comments"][0]["uid"]
-      assert_not_nil js["changeset"]["comments"][0]["user"]
-      assert_not_nil js["changeset"]["comments"][0]["text"]
+      assert_equal "JOSM/1.5 (18364)", js["changeset"]["tags"]["created_by"]
+      assert_equal "changeset comment", js["changeset"]["tags"]["comment"]
     end
 
     def test_show_bbox_json
index 0adf58a9e4b4cb368c3758a074eba24c83d5541e..c55636585ed97044eafbee1d7e53b64770bf7965 100644 (file)
@@ -9,4 +9,10 @@ class DashboardsControllerTest < ActionDispatch::IntegrationTest
       { :controller => "dashboards", :action => "show" }
     )
   end
+
+  def test_show_unauthorized
+    get dashboard_path
+
+    assert_redirected_to login_path(:referer => dashboard_path)
+  end
 end
index 10dff40232e92f9b02027b6cf7ec8fa631574f81..71a706e4590dd048c5a612aa0eeb4454abe80f96 100644 (file)
--- a/yarn.lock
+++ b/yarn.lock
   resolved "https://registry.yarnpkg.com/@humanwhocodes/retry/-/retry-0.4.1.tgz#9a96ce501bc62df46c4031fbd970e3cc6b10f07b"
   integrity sha512-c7hNEllBlenFTHBky65mhq8WD2kbN9Q6gk0bTk8lSBvc554jpXSkST1iePudpt7+A/AQvuHs9EMqjHDXMY1lrA==
 
-"@stylistic/eslint-plugin-js@^3.0.0":
-  version "3.1.0"
-  resolved "https://registry.yarnpkg.com/@stylistic/eslint-plugin-js/-/eslint-plugin-js-3.1.0.tgz#b36292b09bd810ea1b34e0720512f137335ef745"
-  integrity sha512-lQktsOiCr8S6StG29C5fzXYxLOD6ID1rp4j6TRS+E/qY1xd59Fm7dy5qm9UauJIEoSTlYx6yGsCHYh5UkgXPyg==
+"@stylistic/eslint-plugin-js@^4.0.0":
+  version "4.0.1"
+  resolved "https://registry.yarnpkg.com/@stylistic/eslint-plugin-js/-/eslint-plugin-js-4.0.1.tgz#c55e59ad2f00914f9eb103ba9e7be00aff7715dd"
+  integrity sha512-2EGKM6WHnZSidWKCu6ePJCqdpgWiEU1Bt26ktWEfTpCmRP+2vRQ6ViK8X6DLwu4+F0zPLy/Txe2HhI3qJFUvqA==
   dependencies:
     eslint-visitor-keys "^4.2.0"
     espree "^10.3.0"
   resolved "https://registry.yarnpkg.com/@types/geojson/-/geojson-7946.0.16.tgz#8ebe53d69efada7044454e3305c19017d97ced2a"
   integrity sha512-6C8nqWur3j98U6+lXDfTUWIfgvZU+EumvpHKcYjujKH7woYyLj2sUmff0tRhrqM7BohUw7Pz3ZB1jj2gW9Fvmg==
 
-"@types/jquery@^3.5.32":
+"@types/jquery@^3.5.0":
   version "3.5.32"
   resolved "https://registry.yarnpkg.com/@types/jquery/-/jquery-3.5.32.tgz#3eb0da20611b92c7c49ebed6163b52a4fdc57def"
   integrity sha512-b9Xbf4CkMqS02YH8zACqN1xzdxc3cO735Qe5AbSUFmyOiaWAbcpqh9Wna+Uk0vgACvoQHpWDg2rGdHkYPLmCiQ==
   resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841"
   integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==
 
-"@types/leaflet@^1.9.16":
+"@types/leaflet@^1.9.0":
   version "1.9.16"
   resolved "https://registry.yarnpkg.com/@types/leaflet/-/leaflet-1.9.16.tgz#3e3abc103e106523cde01625057e2294f332ec3b"
   integrity sha512-wzZoyySUxkgMZ0ihJ7IaUIblG8Rdc8AbbZKLneyn+QjYsj5q1QU7TEKYqwTr10BGSzY5LI7tJk9Ifo+mEjdFRw==