]> git.openstreetmap.org Git - rails.git/commitdiff
Merge remote-tracking branch 'upstream/pull/4998'
authorTom Hughes <tom@compton.nu>
Wed, 17 Jul 2024 17:25:03 +0000 (18:25 +0100)
committerTom Hughes <tom@compton.nu>
Wed, 17 Jul 2024 17:25:03 +0000 (18:25 +0100)
app/assets/javascripts/index/search.js
test/system/search_test.rb [new file with mode: 0644]

index 2f3882e3ae126e9486d7a9fd6929e0b182365102..476ad30a1ac11de80ad555ecf430ca6ef61923b1 100644 (file)
@@ -118,8 +118,13 @@ OSM.Search = function (map) {
 
   page.pushstate = page.popstate = function (path) {
     var params = Qs.parse(path.substring(path.indexOf("?") + 1));
-    $(".search_form input[name=query]").val(params.query);
-    $(".describe_location").hide();
+    if (params.query) {
+      $(".search_form input[name=query]").val(params.query);
+      $(".describe_location").hide();
+    } else if (params.lat && params.lon) {
+      $(".search_form input[name=query]").val(params.lat + ", " + params.lon);
+      $(".describe_location").hide();
+    }
     OSM.loadSidebarContent(path, page.load);
   };
 
diff --git a/test/system/search_test.rb b/test/system/search_test.rb
new file mode 100644 (file)
index 0000000..8cda1f7
--- /dev/null
@@ -0,0 +1,14 @@
+require "application_system_test_case"
+
+class SearchTest < ApplicationSystemTestCase
+  test "click on 'where is this' sets search input value" do
+    stub_request(:get, %r{^https://nominatim\.openstreetmap\.org/reverse\?})
+      .to_return(:status => 404)
+
+    visit "/#map=7/1.234/6.789"
+
+    assert_field "Search", :with => ""
+    click_on "Where is this?"
+    assert_field "Search", :with => "1.234, 6.789"
+  end
+end