Share Globalize JavaScript interface specs

This commit is contained in:
Javi Martín
2018-09-17 20:23:23 +02:00
parent a64a290392
commit 726110c91e
5 changed files with 90 additions and 144 deletions

View File

@@ -7,6 +7,11 @@ feature "Admin custom information texts" do
login_as(admin.user)
end
it_behaves_like "translatable",
"i18n_content",
"admin_site_customization_information_texts_path",
%w[value]
scenario 'page is correctly loaded' do
visit admin_site_customization_information_texts_path
@@ -113,60 +118,6 @@ feature "Admin custom information texts" do
expect(debate_text.value_en).to eq('Custom debate text')
expect(debate_title.value_en).to eq('Custom debate title')
end
context "Javascript interface" do
scenario "Highlight current locale", :js do
visit admin_site_customization_information_texts_path
expect(find("a.js-globalize-locale-link.is-active")).to have_content "English"
select('Español', from: 'locale-switcher')
expect(find("a.js-globalize-locale-link.is-active")).to have_content "Español"
end
scenario "Highlight selected locale", :js do
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"
click_link "Español"
expect(find("a.js-globalize-locale-link.is-active")).to have_content "Español"
end
scenario "Show selected locale form", :js do
key = "debates.form.debate_title"
content = create(:i18n_content, key: key,
value_en: 'Title',
value_es: 'Título')
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("contents_content_#{key}values_value_es", with: 'Título')
end
scenario "Select a locale and add it to the form", :js do
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("contents_content_#{key}values_value_fr")
end
end
end
end