From 78a5c0356ebcf1168ab0b7cbdf03605c77944f02 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Fri, 27 Jul 2018 00:13:29 +0200 Subject: [PATCH] Add globalization javascript interface specs --- app/helpers/site_customization_helper.rb | 2 +- .../information_texts_spec.rb | 26 ++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/app/helpers/site_customization_helper.rb b/app/helpers/site_customization_helper.rb index 52fb3a940..d9318fd9b 100644 --- a/app/helpers/site_customization_helper.rb +++ b/app/helpers/site_customization_helper.rb @@ -1,5 +1,5 @@ module SiteCustomizationHelper def site_customization_display_translation?(locale) - I18nContentTranslation.existing_languages.include?(neutral_locale(locale)) ? "" : "display: none" + I18nContentTranslation.existing_languages.include?(neutral_locale(locale)) || locale == I18n.locale ? "" : "display: none" end end diff --git a/spec/features/admin/site_customization/information_texts_spec.rb b/spec/features/admin/site_customization/information_texts_spec.rb index ba0a3f9cc..b3300eaf6 100644 --- a/spec/features/admin/site_customization/information_texts_spec.rb +++ b/spec/features/admin/site_customization/information_texts_spec.rb @@ -183,10 +183,10 @@ feature "Admin custom information texts" do expect(debate_title.value_en).to eq('Custom debate title') end - context "Globalize javascript interface" do + context "Javascript interface" do scenario "Highlight current locale", :js do - visit @edit_milestone_url + visit admin_site_customization_information_texts_path expect(find("a.js-globalize-locale-link.is-active")).to have_content "English" @@ -196,7 +196,10 @@ feature "Admin custom information texts" do end scenario "Highlight selected locale", :js do - visit @edit_milestone_url + key = "debates.form.debate_title" + content = create(:i18n_content, key: key, value_es: 'Título') + + visit admin_site_customization_information_texts_path expect(find("a.js-globalize-locale-link.is-active")).to have_content "English" @@ -206,25 +209,30 @@ feature "Admin custom information texts" do end scenario "Show selected locale form", :js do - visit @edit_milestone_url + key = "debates.form.debate_title" + content = create(:i18n_content, key: key, + value_en: 'Title', + value_es: 'Título') - expect(page).to have_field('budget_investment_milestone_description_en', with: 'Description in English') + visit admin_site_customization_information_texts_path + + expect(page).to have_field("contents_content_#{key}values_value_en", with: 'Title') click_link "Español" - expect(page).to have_field('budget_investment_milestone_description_es', with: 'Descripción en Español') + expect(page).to have_field("contents_content_#{key}values_value_es", with: 'Título') end scenario "Select a locale and add it to the milestone form", :js do - visit @edit_milestone_url + key = "debates.form.debate_title" + visit admin_site_customization_information_texts_path select "Français", from: "translation_locale" expect(page).to have_link "Français" click_link "Français" - - expect(page).to have_field('budget_investment_milestone_description_fr') + expect(page).to have_field("contents_content_#{key}values_value_fr") end end