From a9e295bc11f789ae55a67c4ba007374585a8bbbf Mon Sep 17 00:00:00 2001 From: wandji20 Date: Wed, 10 Jul 2024 00:00:09 +0100 Subject: [PATCH 1/3] (Fix) [User->New] Language is displayed twice [OFN-11513] --- app/views/spree/admin/users/_form.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/spree/admin/users/_form.html.haml b/app/views/spree/admin/users/_form.html.haml index 3eeda732830..6eb47fe834e 100644 --- a/app/views/spree/admin/users/_form.html.haml +++ b/app/views/spree/admin/users/_form.html.haml @@ -14,7 +14,7 @@ = hidden_field_tag "user[spree_role_ids][]", "" = f.field_container :locale do = f.label :locale, t(".locale") - = f.select :locale, locale_options, class: "fullwidth" + = f.select :locale, OpenFoodNetwork::I18nConfig.locale_options, class: "fullwidth" = f.field_container :enterprise_limit do = f.label :enterprise_limit, t(".enterprise_limit") = f.text_field :enterprise_limit, class: "fullwidth" From 65d4596f3b29b505d3dffcdcf433635f791569f4 Mon Sep 17 00:00:00 2001 From: wandji20 Date: Thu, 11 Jul 2024 13:13:32 +0100 Subject: [PATCH 2/3] Fix failling spec [OFN-11513] --- spec/system/admin/users_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/system/admin/users_spec.rb b/spec/system/admin/users_spec.rb index 6548dbc5586..dafb50fcc52 100644 --- a/spec/system/admin/users_spec.rb +++ b/spec/system/admin/users_spec.rb @@ -141,8 +141,8 @@ fill_in "Password", with: "user1Secret" fill_in "Confirm Password", with: "user1Secret" - expect(page).to have_select "Language", selected: "English" - select "Español", from: "Language" + expect(page).to have_select "Language", selected: "en_AU" + select "es", from: "Language" perform_enqueued_jobs do expect do From ef87cdb167748fa5f15e8550625fe2422af530fc Mon Sep 17 00:00:00 2001 From: wandji20 Date: Wed, 24 Jul 2024 03:08:29 +0100 Subject: [PATCH 3/3] Revert changes and use selectable locales for helper local_options [OFN-11513] --- app/helpers/i18n_helper.rb | 2 +- app/views/spree/admin/users/_form.html.haml | 2 +- spec/system/admin/users_spec.rb | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/helpers/i18n_helper.rb b/app/helpers/i18n_helper.rb index 3fca93a061a..8d7d5fe0a54 100644 --- a/app/helpers/i18n_helper.rb +++ b/app/helpers/i18n_helper.rb @@ -2,7 +2,7 @@ module I18nHelper def locale_options - OpenFoodNetwork::I18nConfig.available_locales.map do |locale| + OpenFoodNetwork::I18nConfig.selectable_locales.map do |locale| [t('language_name', locale:), locale] end end diff --git a/app/views/spree/admin/users/_form.html.haml b/app/views/spree/admin/users/_form.html.haml index 6eb47fe834e..3eeda732830 100644 --- a/app/views/spree/admin/users/_form.html.haml +++ b/app/views/spree/admin/users/_form.html.haml @@ -14,7 +14,7 @@ = hidden_field_tag "user[spree_role_ids][]", "" = f.field_container :locale do = f.label :locale, t(".locale") - = f.select :locale, OpenFoodNetwork::I18nConfig.locale_options, class: "fullwidth" + = f.select :locale, locale_options, class: "fullwidth" = f.field_container :enterprise_limit do = f.label :enterprise_limit, t(".enterprise_limit") = f.text_field :enterprise_limit, class: "fullwidth" diff --git a/spec/system/admin/users_spec.rb b/spec/system/admin/users_spec.rb index dafb50fcc52..6548dbc5586 100644 --- a/spec/system/admin/users_spec.rb +++ b/spec/system/admin/users_spec.rb @@ -141,8 +141,8 @@ fill_in "Password", with: "user1Secret" fill_in "Confirm Password", with: "user1Secret" - expect(page).to have_select "Language", selected: "en_AU" - select "es", from: "Language" + expect(page).to have_select "Language", selected: "English" + select "Español", from: "Language" perform_enqueued_jobs do expect do