]> git.openstreetmap.org Git - rails.git/commitdiff
Set i18n locale before writing "report a problem" on embed page
authorAnton Khorev <tony29@yandex.ru>
Sun, 30 Jun 2024 01:51:43 +0000 (04:51 +0300)
committerAnton Khorev <tony29@yandex.ru>
Sun, 30 Jun 2024 01:51:43 +0000 (04:51 +0300)
app/assets/javascripts/embed.js.erb
test/system/embed_test.rb [new file with mode: 0644]

index 4ebb89da93134a422133640e6680119c6ab9e752..9a0ec07d31d85855c06a02d0179d29f7a298d207 100644 (file)
@@ -5,13 +5,13 @@
 //= require i18n
 //= require i18n/embed
 
-window.onload = function () {
-  if (navigator.languages) {
-    I18n.locale = navigator.languages[0];
-  } else if (navigator.language) {
-    I18n.locale = navigator.language;
-  }
+if (navigator.languages) {
+  I18n.locale = navigator.languages[0];
+} else if (navigator.language) {
+  I18n.locale = navigator.language;
+}
 
+window.onload = function () {
   var query = (window.location.search || '?').slice(1),
       args  = {};
 
diff --git a/test/system/embed_test.rb b/test/system/embed_test.rb
new file mode 100644 (file)
index 0000000..6003c6f
--- /dev/null
@@ -0,0 +1,19 @@
+require "application_system_test_case"
+
+class EmbedTest < ApplicationSystemTestCase
+  test "shows localized report link" do
+    visit export_embed_path
+    assert_link "Report a problem"
+  end
+end
+
+class GermanEmbedTest < ApplicationSystemTestCase
+  driven_by :selenium, :using => :headless_firefox, :options => { :name => :selenium_de } do |options|
+    options.add_preference("intl.accept_languages", "de")
+  end
+
+  test "shows localized report link" do
+    visit export_embed_path
+    assert_link "Ein Problem melden"
+  end
+end