]> git.openstreetmap.org Git - rails.git/commitdiff
Merge remote-tracking branch 'upstream/pull/5536'
authorTom Hughes <tom@compton.nu>
Sun, 26 Jan 2025 10:09:17 +0000 (10:09 +0000)
committerTom Hughes <tom@compton.nu>
Sun, 26 Jan 2025 10:09:17 +0000 (10:09 +0000)
18 files changed:
.github/workflows/tests.yml
app/assets/javascripts/edit/id.js.erb
app/assets/javascripts/embed.js.erb
app/assets/javascripts/osm.js.erb
app/controllers/api/maps_controller.rb [moved from app/controllers/api/map_controller.rb with 98% similarity]
app/controllers/api/notes_controller.rb
app/controllers/api_controller.rb
app/controllers/application_controller.rb
app/controllers/export_controller.rb
app/views/api/maps/_bounds.json.jbuilder [moved from app/views/api/map/_bounds.json.jbuilder with 100% similarity]
app/views/api/maps/_bounds.xml.builder [moved from app/views/api/map/_bounds.xml.builder with 100% similarity]
app/views/api/maps/show.json.jbuilder [moved from app/views/api/map/index.json.jbuilder with 100% similarity]
app/views/api/maps/show.xml.builder [moved from app/views/api/map/index.xml.builder with 100% similarity]
config/routes.rb
test/controllers/api/maps_controller_test.rb [moved from test/controllers/api/map_controller_test.rb with 91% similarity]
test/controllers/api/notes_controller_test.rb
test/controllers/export_controller_test.rb
yarn.lock

index 25722c1f48fc471abd09f8a6b2dfb2dbe8704bc1..5e6814451726f57a7277d0b7fcaa9ec2d82a16a7 100644 (file)
@@ -65,7 +65,7 @@ jobs:
     - name: Run javascript tests
       run: bundle exec teaspoon
     - name: Report completion to Coveralls
-      uses: coverallsapp/github-action@v2.3.4
+      uses: coverallsapp/github-action@v2.3.5
       with:
         github-token: ${{ secrets.github_token }}
         flag-name: ubuntu-${{ matrix.ubuntu }}-ruby-${{ matrix.ruby }}
@@ -77,7 +77,7 @@ jobs:
     runs-on: ubuntu-latest
     steps:
     - name: Report completion to Coveralls
-      uses: coverallsapp/github-action@v2.3.4
+      uses: coverallsapp/github-action@v2.3.5
       with:
         github-token: ${{ secrets.github_token }}
         parallel-finished: true
index 90318788c72de8342527aaeb3ab7b944d0d86ecf..08e04dcf377dacb0f868fde3a52fae1311cb4feb 100644 (file)
@@ -10,15 +10,15 @@ $(document).ready(function () {
     var params = {};
 
     if (mapParams.object) {
-      params.id = mapParams.object.type + '/' + mapParams.object.id;
+      params.id = mapParams.object.type + "/" + mapParams.object.id;
       mapParams = OSM.parseHash(location.hash);
       if (mapParams.center) {
-        params.map = mapParams.zoom + '/' + mapParams.center.lat + '/' + mapParams.center.lng;
+        params.map = mapParams.zoom + "/" + mapParams.center.lat + "/" + mapParams.center.lng;
       }
     } else if (id.data("lat") && id.data("lon")) {
       params.map = "16/" + id.data("lat") + "/" + id.data("lon");
     } else {
-      params.map = (mapParams.zoom || 17) + '/' + mapParams.lat + '/' + mapParams.lon;
+      params.map = (mapParams.zoom || 17) + "/" + mapParams.lat + "/" + mapParams.lon;
     }
 
     if (hashParams.background) params.background = hashParams.background;
index b9e9a2eaf41ee7607881ef681003080bd0456090..ef6f0067098162c0a234d5f9d268e1d6231ce191 100644 (file)
@@ -15,13 +15,13 @@ I18n.default_locale = <%= I18n.default_locale.to_json %>;
 I18n.fallbacks = true;
 
 window.onload = function () {
-  var query = (window.location.search || '?').slice(1),
-      args  = {};
+  var query = (window.location.search || "?").slice(1),
+      args = {};
 
-  var pairs = query.split('&');
+  var pairs = query.split("&");
   for (var i = 0; i < pairs.length; i++) {
-    var parts = pairs[i].split('=');
-    args[parts[0]] = decodeURIComponent(parts[1] || '');
+    var parts = pairs[i].split("=");
+    args[parts[0]] = decodeURIComponent(parts[1] || "");
   }
 
   var mapnikOptions = {
@@ -37,7 +37,7 @@ window.onload = function () {
   };
 
   var map = L.map("map");
-  map.attributionControl.setPrefix('');
+  map.attributionControl.setPrefix("");
   map.removeControl(map.attributionControl);
 
   if (args.layer === "cyclosm") {
@@ -53,19 +53,21 @@ window.onload = function () {
   }
 
   if (args.marker) {
-    L.marker(args.marker.split(','), {icon: L.icon({
+    L.marker(args.marker.split(","), { icon: L.icon({
       iconUrl: <%= asset_path('leaflet/dist/images/marker-icon.png').to_json %>,
       iconSize: new L.Point(25, 41),
       iconAnchor: new L.Point(12, 41),
       shadowUrl: <%= asset_path('leaflet/dist/images/marker-shadow.png').to_json %>,
       shadowSize: new L.Point(41, 41)
-    })}).addTo(map);
+    }) }).addTo(map);
   }
 
   if (args.bbox) {
-    var bbox = args.bbox.split(',');
-    map.fitBounds([L.latLng(bbox[1], bbox[0]),
-                   L.latLng(bbox[3], bbox[2])]);
+    var bbox = args.bbox.split(",");
+    map.fitBounds([
+      L.latLng(bbox[1], bbox[0]),
+      L.latLng(bbox[3], bbox[2])
+    ]);
   } else {
     map.fitWorld();
   }
@@ -75,14 +77,14 @@ window.onload = function () {
 
 L.Control.OSMReportAProblem = L.Control.Attribution.extend({
   options: {
-    position: 'bottomright',
-    prefix: '<a href="https://www.openstreetmap.org/fixthemap?lat={x}&lon={y}&zoom={z}" target="_blank">'+I18n.t('javascripts.embed.report_problem')+'</a>'
+    position: "bottomright",
+    prefix: "<a href=\"https://www.openstreetmap.org/fixthemap?lat={x}&lon={y}&zoom={z}\" target=\"_blank\">" + I18n.t("javascripts.embed.report_problem") + "</a>"
   },
 
   onAdd: function (map) {
     var container = L.Control.Attribution.prototype.onAdd.call(this, map);
 
-    map.on('moveend', this._update, this);
+    map.on("moveend", this._update, this);
 
     return container;
   },
@@ -92,8 +94,8 @@ L.Control.OSMReportAProblem = L.Control.Attribution.extend({
 
     this._container.innerHTML =
       this._container.innerHTML
-        .replace('{x}', this._map.getCenter().lat)
-        .replace('{y}', this._map.getCenter().lng)
-        .replace('{z}', this._map.getZoom());
+        .replace("{x}", this._map.getCenter().lat)
+        .replace("{y}", this._map.getCenter().lng)
+        .replace("{z}", this._map.getZoom());
   }
 });
index 3edd9b451d3decc9c88d19435f43655badd7b335..602d3af10afb65049f194af1dca778832686ec65 100644 (file)
@@ -58,16 +58,16 @@ OSM = {
     return url;
   },
 
-  params: function(search) {
+  params: function (search) {
     var params = {};
 
-    search = (search || window.location.search).replace('?', '').split(/&|;/);
+    search = (search || window.location.search).replace("?", "").split(/&|;/);
 
     for (var i = 0; i < search.length; ++i) {
       var pair = search[i],
-        j = pair.indexOf('='),
-        key = pair.slice(0, j),
-        val = pair.slice(++j);
+          j = pair.indexOf("="),
+          key = pair.slice(0, j),
+          val = pair.slice(++j);
 
       try {
         params[key] = decodeURIComponent(val);
@@ -90,18 +90,18 @@ OSM = {
 
     // Old-style object parameters; still in use for edit links e.g. /edit?way=1234
     if (params.node) {
-      mapParams.object = {type: 'node', id: parseInt(params.node)};
+      mapParams.object = { type: "node", id: parseInt(params.node, 10) };
     } else if (params.way) {
-      mapParams.object = {type: 'way', id: parseInt(params.way)};
+      mapParams.object = { type: "way", id: parseInt(params.way, 10) };
     } else if (params.relation) {
-      mapParams.object = {type: 'relation', id: parseInt(params.relation)};
+      mapParams.object = { type: "relation", id: parseInt(params.relation, 10) };
     } else if (params.note) {
-      mapParams.object = {type: 'note', id: parseInt(params.note)};
+      mapParams.object = { type: "note", id: parseInt(params.note, 10) };
     }
 
     var hash = OSM.parseHash(location.hash);
 
-    const loc = Cookies.get('_osm_location')?.split("|");
+    const loc = Cookies.get("_osm_location")?.split("|");
 
     // Decide on a map starting position. Various ways of doing this.
     if (hash.center) {
@@ -109,7 +109,7 @@ OSM = {
       mapParams.lat = hash.center.lat;
       mapParams.zoom = hash.zoom;
     } else if (params.bbox) {
-      var bbox = params.bbox.split(',');
+      var bbox = params.bbox.split(",");
       mapParams.bounds = L.latLngBounds(
         [parseFloat(bbox[1]), parseFloat(bbox[0])],
         [parseFloat(bbox[3]), parseFloat(bbox[2])]);
@@ -120,28 +120,27 @@ OSM = {
     } else if (params.mlon && params.mlat) {
       mapParams.lon = parseFloat(params.mlon);
       mapParams.lat = parseFloat(params.mlat);
-      mapParams.zoom = parseInt(params.zoom || 12);
+      mapParams.zoom = parseInt(params.zoom || 12, 10);
     } else if (loc) {
       mapParams.lon = parseFloat(loc[0]);
       mapParams.lat = parseFloat(loc[1]);
-      mapParams.zoom = parseInt(loc[2]);
+      mapParams.zoom = parseInt(loc[2], 10);
     } else if (OSM.home) {
       mapParams.lon = OSM.home.lon;
       mapParams.lat = OSM.home.lat;
       mapParams.zoom = 10;
     } else if (OSM.location) {
       mapParams.bounds = L.latLngBounds(
-        [OSM.location.minlat,
-         OSM.location.minlon],
-        [OSM.location.maxlat,
-         OSM.location.maxlon]);
+        [OSM.location.minlat, OSM.location.minlon],
+        [OSM.location.maxlat, OSM.location.maxlon]
+      );
     } else {
       mapParams.lon = -0.1;
       mapParams.lat = 51.5;
-      mapParams.zoom = parseInt(params.zoom || 5);
+      mapParams.zoom = parseInt(params.zoom || 5, 10);
     }
 
-    mapParams.layers = hash.layers || (loc && loc[3]) || '';
+    mapParams.layers = hash.layers || (loc && loc[3]) || "";
 
     var scale = parseFloat(params.scale);
     if (scale > 0) {
@@ -151,20 +150,20 @@ OSM = {
     return mapParams;
   },
 
-  parseHash: function(hash) {
+  parseHash: function (hash) {
     var args = {};
 
-    var i = hash.indexOf('#');
+    var i = hash.indexOf("#");
     if (i < 0) {
       return args;
     }
 
     hash = Qs.parse(hash.slice(i + 1));
 
-    var map = (hash.map || '').split('/'),
-      zoom = parseInt(map[0], 10),
-      lat = parseFloat(map[1]),
-      lon = parseFloat(map[2]);
+    var map = (hash.map || "").split("/"),
+        zoom = parseInt(map[0], 10),
+        lat = parseFloat(map[1]),
+        lon = parseFloat(map[2]);
 
     if (!isNaN(zoom) && !isNaN(lat) && !isNaN(lon)) {
       args.center = new L.LatLng(lat, lon);
@@ -178,7 +177,7 @@ OSM = {
     return args;
   },
 
-  formatHash: function(args) {
+  formatHash: function (args) {
     var center, zoom, layers;
 
     if (args instanceof L.Map) {
@@ -188,44 +187,44 @@ OSM = {
     } else {
       center = args.center || L.latLng(args.lat, args.lon);
       zoom = args.zoom;
-      layers = args.layers || '';
+      layers = args.layers || "";
     }
 
     center = center.wrap();
-    layers = layers.replace('M', '');
+    layers = layers.replace("M", "");
 
     var precision = OSM.zoomPrecision(zoom),
-      hash = '#map=' + zoom +
-        '/' + center.lat.toFixed(precision) +
-        '/' + center.lng.toFixed(precision);
+        hash = "#map=" + zoom +
+          "/" + center.lat.toFixed(precision) +
+          "/" + center.lng.toFixed(precision);
 
     if (layers) {
-      hash += '&layers=' + layers;
+      hash += "&layers=" + layers;
     }
 
     return hash;
   },
 
-  zoomPrecision: function(zoom) {
+  zoomPrecision: function (zoom) {
     var pixels = Math.pow(2, 8 + zoom);
     var degrees = 180;
     return Math.ceil(Math.log10(pixels / degrees));
   },
 
-  locationCookie: function(map) {
+  locationCookie: function (map) {
     var center = map.getCenter().wrap(),
-      zoom = map.getZoom(),
-      precision = OSM.zoomPrecision(zoom);
-    return [center.lng.toFixed(precision), center.lat.toFixed(precision), zoom, map.getLayersCode()].join('|');
+        zoom = map.getZoom(),
+        precision = OSM.zoomPrecision(zoom);
+    return [center.lng.toFixed(precision), center.lat.toFixed(precision), zoom, map.getLayersCode()].join("|");
   },
 
-  distance: function(latlng1, latlng2) {
+  distance: function (latlng1, latlng2) {
     var lat1 = latlng1.lat * Math.PI / 180,
-      lng1 = latlng1.lng * Math.PI / 180,
-      lat2 = latlng2.lat * Math.PI / 180,
-      lng2 = latlng2.lng * Math.PI / 180,
-      latdiff = lat2 - lat1,
-      lngdiff = lng2 - lng1;
+        lng1 = latlng1.lng * Math.PI / 180,
+        lat2 = latlng2.lat * Math.PI / 180,
+        lng2 = latlng2.lng * Math.PI / 180,
+        latdiff = lat2 - lat1,
+        lngdiff = lng2 - lng1;
 
     return 6372795 * 2 * Math.asin(
       Math.sqrt(
similarity index 98%
rename from app/controllers/api/map_controller.rb
rename to app/controllers/api/maps_controller.rb
index da8138597ae7b269fbb983a7eda8a4347c8a9ae7..2aa25fdd74611ecb2e3323af46ede63b8f72e5fe 100644 (file)
@@ -1,5 +1,5 @@
 module Api
-  class MapController < ApiController
+  class MapsController < ApiController
     authorize_resource :class => false
 
     before_action :set_request_formats
@@ -13,7 +13,7 @@ module Api
     # Then all the relations that reference the already found nodes and ways are
     # fetched. All the nodes and ways that are referenced by those ways are then
     # fetched. Finally all the xml is returned.
-    def index
+    def show
       # Figure out the bbox
       # check boundary is sane and area within defined
       # see /config/application.yml
index 7e2e7fb793babed86952313cc1d0703043d2f760..eca0728b65700d90d7ea2f38126c9e06fe961d7c 100644 (file)
@@ -384,11 +384,7 @@ module Api
     def add_comment(note, text, event, notify: true)
       attributes = { :visible => true, :event => event, :body => text }
 
-      if doorkeeper_token
-        author = current_user if scope_enabled?(:write_notes)
-      else
-        author = current_user
-      end
+      author = current_user if scope_enabled?(:write_notes)
 
       if author
         attributes[:author_id] = author.id
index 5a112b3cf61c4e4e35605b16086cf7bef6a6cc3e..23f35a40eeaf73662765d1d8cf137f2605f40f9c 100644 (file)
@@ -170,4 +170,10 @@ class ApiController < ApplicationController
 
     raise OSM::APIRateLimitExceeded if new_changes > max_changes
   end
+
+  def scope_enabled?(scope)
+    doorkeeper_token&.includes_scope?(scope)
+  end
+
+  helper_method :scope_enabled?
 end
index f6006fe5e4ccdc7139a6db14d5e0cf7adf5ee748..176fd8c2e060213d8264c1ccd1dd8cddca281df6 100644 (file)
@@ -304,10 +304,7 @@ class ApplicationController < ActionController::Base
   end
 
   def deny_access(_exception)
-    if doorkeeper_token
-      set_locale
-      report_error t("oauth.permissions.missing"), :forbidden
-    elsif current_user
+    if current_user
       set_locale
       respond_to do |format|
         format.html { redirect_to :controller => "/errors", :action => "forbidden" }
@@ -354,10 +351,4 @@ class ApplicationController < ActionController::Base
 
     referer&.to_s
   end
-
-  def scope_enabled?(scope)
-    doorkeeper_token&.includes_scope?(scope)
-  end
-
-  helper_method :scope_enabled?
 end
index 5a2b159ef6f991b96992367b3fd69e7c074de5a2..fdae75b9a5cee812b137a82ad947c627498f5c31 100644 (file)
@@ -19,7 +19,7 @@ class ExportController < ApplicationController
     case style
     when "osm"
       # redirect to API map get
-      redirect_to :controller => "api/map", :action => "index", :bbox => bbox
+      redirect_to api_map_path(:bbox => bbox)
 
     when "mapnik"
       # redirect to a special 'export' cgi script
index 6e5e73855c34a23e7931042703e2b3e503ff5fb1..19dfc9a7729519c26285160ff1d3d68a36c157c7 100644 (file)
@@ -62,11 +62,11 @@ OpenStreetMap::Application.routes.draw do
     put "relation/:id" => "relations#update", :id => /\d+/
     delete "relation/:id" => "relations#delete", :id => /\d+/
     get "relations" => "relations#index"
-
-    get "map" => "map#index"
   end
 
   namespace :api, :path => "api/0.6" do
+    resource :map, :only => :show
+
     resources :tracepoints, :path => "trackpoints", :only => :index
 
     resources :users, :only => :index
similarity index 91%
rename from test/controllers/api/map_controller_test.rb
rename to test/controllers/api/maps_controller_test.rb
index c050100ae0c56a0fbbbaf7906089d306367e06f6..f61a1fac2925499c3f210c52a353ddcf7d2eec20 100644 (file)
@@ -1,7 +1,7 @@
 require "test_helper"
 
 module Api
-  class MapControllerTest < ActionDispatch::IntegrationTest
+  class MapsControllerTest < ActionDispatch::IntegrationTest
     def setup
       super
       @badbigbbox = %w[-0.1,-0.1,1.1,1.1 10,10,11,11]
@@ -21,11 +21,11 @@ module Api
     def test_routes
       assert_routing(
         { :path => "/api/0.6/map", :method => :get },
-        { :controller => "api/map", :action => "index" }
+        { :controller => "api/maps", :action => "show" }
       )
       assert_routing(
         { :path => "/api/0.6/map.json", :method => :get },
-        { :controller => "api/map", :action => "index", :format => "json" }
+        { :controller => "api/maps", :action => "show", :format => "json" }
       )
     end
 
@@ -42,67 +42,67 @@ module Api
 
       # Accept: XML format -> use XML
       accept_header = accept_format_header("text/xml")
-      get map_path(:bbox => bbox), :headers => accept_header
+      get api_map_path(:bbox => bbox), :headers => accept_header
       assert_response :success, "Expected success with the map call"
       assert_equal "application/xml; charset=utf-8", @response.header["Content-Type"]
 
       # Accept: Any format -> use XML
       accept_header = accept_format_header("*/*")
-      get map_path(:bbox => bbox), :headers => accept_header
+      get api_map_path(:bbox => bbox), :headers => accept_header
       assert_response :success, "Expected success with the map call"
       assert_equal "application/xml; charset=utf-8", @response.header["Content-Type"]
 
       # Accept: Any format, .json URL suffix -> use json
       accept_header = accept_format_header("*/*")
-      get map_path(:bbox => bbox, :format => "json"), :headers => accept_header
+      get api_map_path(:bbox => bbox, :format => "json"), :headers => accept_header
       assert_response :success, "Expected success with the map call"
       assert_equal "application/json; charset=utf-8", @response.header["Content-Type"]
 
       # Accept: Firefox header -> use XML
       accept_header = accept_format_header("text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8")
-      get map_path(:bbox => bbox), :headers => accept_header
+      get api_map_path(:bbox => bbox), :headers => accept_header
       assert_response :success, "Expected success with the map call"
       assert_equal "application/xml; charset=utf-8", @response.header["Content-Type"]
 
       # Accept: JOSM header text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2 -> use XML
       # Note: JOSM's header does not comply with RFC 7231, section 5.3.1
       accept_header = accept_format_header("text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2")
-      get map_path(:bbox => bbox), :headers => accept_header
+      get api_map_path(:bbox => bbox), :headers => accept_header
       assert_response :success, "Expected success with the map call"
       assert_equal "application/xml; charset=utf-8", @response.header["Content-Type"]
 
       # Accept: text/plain, */* -> use XML
       accept_header = accept_format_header("text/plain, */*")
-      get map_path(:bbox => bbox), :headers => accept_header
+      get api_map_path(:bbox => bbox), :headers => accept_header
       assert_response :success, "Expected success with the map call"
       assert_equal "application/xml; charset=utf-8", @response.header["Content-Type"]
 
       # Accept: text/* -> use XML
       accept_header = accept_format_header("text/*")
-      get map_path(:bbox => bbox), :headers => accept_header
+      get api_map_path(:bbox => bbox), :headers => accept_header
       assert_response :success, "Expected success with the map call"
       assert_equal "application/xml; charset=utf-8", @response.header["Content-Type"]
 
       # Accept: json, */* format -> use json
       accept_header = accept_format_header("application/json, */*")
-      get map_path(:bbox => bbox), :headers => accept_header
+      get api_map_path(:bbox => bbox), :headers => accept_header
       assert_response :success, "Expected success with the map call"
       assert_equal "application/json; charset=utf-8", @response.header["Content-Type"]
 
       # Accept: json format -> use json
       accept_header = accept_format_header("application/json")
-      get map_path(:bbox => bbox), :headers => accept_header
+      get api_map_path(:bbox => bbox), :headers => accept_header
       assert_response :success, "Expected success with the map call"
       assert_equal "application/json; charset=utf-8", @response.header["Content-Type"]
 
       # text/json is in invalid format, return HTTP 406 Not acceptable
       accept_header = accept_format_header("text/json")
-      get map_path(:bbox => bbox), :headers => accept_header
+      get api_map_path(:bbox => bbox), :headers => accept_header
       assert_response :not_acceptable, "text/json should fail"
 
       # image/jpeg is a format which we don't support, return HTTP 406 Not acceptable
       accept_header = accept_format_header("image/jpeg")
-      get map_path(:bbox => bbox), :headers => accept_header
+      get api_map_path(:bbox => bbox), :headers => accept_header
       assert_response :not_acceptable, "text/json should fail"
     end
 
@@ -124,7 +124,7 @@ module Api
       maxlon = node.lon + 0.1
       maxlat = node.lat + 0.1
       bbox = "#{minlon},#{minlat},#{maxlon},#{maxlat}"
-      get map_path(:bbox => bbox)
+      get api_map_path(:bbox => bbox)
       if $VERBOSE
         print @request.to_yaml
         print @response.body
@@ -167,7 +167,7 @@ module Api
       maxlon = node.lon + 0.1
       maxlat = node.lat + 0.1
       bbox = "#{minlon},#{minlat},#{maxlon},#{maxlat}"
-      get map_path(:bbox => bbox, :format => "json")
+      get api_map_path(:bbox => bbox, :format => "json")
       if $VERBOSE
         print @request.to_yaml
         print @response.body
@@ -211,7 +211,7 @@ module Api
       relation = create(:relation_member, :member => node).relation
 
       bbox = "#{node.lon},#{node.lat},#{node.lon},#{node.lat}"
-      get map_path(:bbox => bbox)
+      get api_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}']" \
@@ -248,7 +248,7 @@ module Api
       relation = create(:relation_member, :member => way1).relation
 
       bbox = "#{node.lon},#{node.lat},#{node.lon},#{node.lat}"
-      get map_path(:bbox => bbox)
+      get api_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
@@ -265,7 +265,7 @@ module Api
     end
 
     def test_map_empty
-      get map_path(:bbox => "179.998,89.998,179.999.1,89.999")
+      get api_map_path(:bbox => "179.998,89.998,179.999.1,89.999")
       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='179.9980000'][minlat='89.9980000'][maxlon='179.9990000'][maxlat='89.9990000']", :count => 1
@@ -276,14 +276,14 @@ module Api
     end
 
     def test_map_without_bbox
-      get map_path
+      get api_map_path
       assert_response :bad_request
       assert_equal "The parameter bbox is required", @response.body, "A bbox param was expected"
     end
 
     def test_bbox_too_big
       @badbigbbox.each do |bbox|
-        get map_path(:bbox => bbox)
+        get api_map_path(:bbox => bbox)
         assert_response :bad_request, "The bbox:#{bbox} was expected to be too big"
         assert_equal "The maximum bbox size is #{Settings.max_request_area}, and your request was too large. Either request a smaller area, or use planet.osm", @response.body, "bbox: #{bbox}"
       end
@@ -291,7 +291,7 @@ module Api
 
     def test_bbox_malformed
       @badmalformedbbox.each do |bbox|
-        get map_path(:bbox => bbox)
+        get api_map_path(:bbox => bbox)
         assert_response :bad_request, "The bbox:#{bbox} was expected to be malformed"
         assert_equal "The parameter bbox must be of the form min_lon,min_lat,max_lon,max_lat", @response.body, "bbox: #{bbox}"
       end
@@ -299,7 +299,7 @@ module Api
 
     def test_bbox_lon_mixedup
       @badlonmixedbbox.each do |bbox|
-        get map_path(:bbox => bbox)
+        get api_map_path(:bbox => bbox)
         assert_response :bad_request, "The bbox:#{bbox} was expected to have the longitude mixed up"
         assert_equal "The minimum longitude must be less than the maximum longitude, but it wasn't", @response.body, "bbox: #{bbox}"
       end
@@ -307,7 +307,7 @@ module Api
 
     def test_bbox_lat_mixedup
       @badlatmixedbbox.each do |bbox|
-        get map_path(:bbox => bbox)
+        get api_map_path(:bbox => bbox)
         assert_response :bad_request, "The bbox:#{bbox} was expected to have the latitude mixed up"
         assert_equal "The minimum latitude must be less than the maximum latitude, but it wasn't", @response.body, "bbox: #{bbox}"
       end
index 5f69e6a2ac025e9eadf11a85795d040c349202c6..17ceb1b9e5b8b58b96ba2d66d22fe310978716c7 100644 (file)
@@ -230,6 +230,17 @@ module Api
       assert_equal note, subscription.note
     end
 
+    def test_create_no_scope_fail
+      user = create(:user)
+      auth_header = bearer_authorization_header user, :scopes => %w[read_prefs]
+
+      assert_no_difference "Note.count" do
+        post api_notes_path(:lat => -1.0, :lon => -1.0, :text => "This is a description", :format => "json"), :headers => auth_header
+
+        assert_response :forbidden
+      end
+    end
+
     def test_comment_success
       open_note_with_comment = create(:note_with_comments)
       user = create(:user)
index 64d5a686615e9d23988f759865eb872643b8bc4a..7f7b4ee8ce6cd2e27b267b483747a55476c7980a 100644 (file)
@@ -18,7 +18,7 @@ class ExportControllerTest < ActionDispatch::IntegrationTest
   # test the finish action for raw OSM data
   def test_finish_osm
     post export_finish_path(:minlon => 0, :minlat => 50, :maxlon => 1, :maxlat => 51, :format => "osm")
-    assert_redirected_to "controller" => "api/map", "action" => "index", "bbox" => "0.0,50.0,1.0,51.0"
+    assert_redirected_to api_map_path(:bbox => "0.0,50.0,1.0,51.0")
   end
 
   ###
index 684bbac3998398e701fc8c73306787ad72661fdf..55bc0851ba9256f34b00f0c5e9a7f67ab6576739 100644 (file)
--- a/yarn.lock
+++ b/yarn.lock
     minimatch "^3.1.2"
     strip-json-comments "^3.1.1"
 
-"@eslint/js@9.18.0":
-  version "9.18.0"
-  resolved "https://registry.yarnpkg.com/@eslint/js/-/js-9.18.0.tgz#3356f85d18ed3627ab107790b53caf7e1e3d1e84"
-  integrity sha512-fK6L7rxcq6/z+AaQMtiFTkvbHkBLNlwyRxHpKawP0x3u9+NC6MQTnFW+AdpwC6gfHTW0051cokQgtTN2FqlxQA==
+"@eslint/js@9.19.0":
+  version "9.19.0"
+  resolved "https://registry.yarnpkg.com/@eslint/js/-/js-9.19.0.tgz#51dbb140ed6b49d05adc0b171c41e1a8713b7789"
+  integrity sha512-rbq9/g38qjfqFLOVPvwjIvFFdNziEC5S65jmjPw5r6A//QH+W91akh9irMwjDN8zKUTak6W9EsAv4m/7Wnw0UQ==
 
 "@eslint/object-schema@^2.1.4":
   version "2.1.4"
@@ -278,16 +278,16 @@ eslint-visitor-keys@^4.2.0:
   integrity sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==
 
 eslint@^9.0.0:
-  version "9.18.0"
-  resolved "https://registry.yarnpkg.com/eslint/-/eslint-9.18.0.tgz#c95b24de1183e865de19f607fda6518b54827850"
-  integrity sha512-+waTfRWQlSbpt3KWE+CjrPPYnbq9kfZIYUqapc0uBXyjTp8aYXZDsUH16m39Ryq3NjAVP4tjuF7KaukeqoCoaA==
+  version "9.19.0"
+  resolved "https://registry.yarnpkg.com/eslint/-/eslint-9.19.0.tgz#ffa1d265fc4205e0f8464330d35f09e1d548b1bf"
+  integrity sha512-ug92j0LepKlbbEv6hD911THhoRHmbdXt2gX+VDABAW/Ir7D3nqKdv5Pf5vtlyY6HQMTEP2skXY43ueqTCWssEA==
   dependencies:
     "@eslint-community/eslint-utils" "^4.2.0"
     "@eslint-community/regexpp" "^4.12.1"
     "@eslint/config-array" "^0.19.0"
     "@eslint/core" "^0.10.0"
     "@eslint/eslintrc" "^3.2.0"
-    "@eslint/js" "9.18.0"
+    "@eslint/js" "9.19.0"
     "@eslint/plugin-kit" "^0.2.5"
     "@humanfs/node" "^0.16.6"
     "@humanwhocodes/module-importer" "^1.0.1"