Updates translatable custom pages

This commit is contained in:
Papaya Labs
2018-09-27 13:46:17 +02:00
parent 2c22ab347d
commit 914bfa645e
10 changed files with 210 additions and 91 deletions

View File

@@ -5,10 +5,9 @@ feature "Custom Pages" do
scenario "See default content when custom page is not published" do
custom_page = create(:site_customization_page,
slug: "conditions",
title: "Custom conditions",
content: "New text for conditions page",
print_content_flag: true,
locale: "en"
title_en: "Custom conditions",
content_en: "New text for conditions page",
print_content_flag: true
)
visit custom_page.url
@@ -22,10 +21,9 @@ feature "Custom Pages" do
scenario "See custom content when custom page is published" do
custom_page = create(:site_customization_page, :published,
slug: "conditions",
title: "Custom conditions",
content: "New text for conditions page",
print_content_flag: true,
locale: "en"
title_en: "Custom conditions",
content_en: "New text for conditions page",
print_content_flag: true
)
visit custom_page.url
@@ -42,10 +40,9 @@ feature "Custom Pages" do
scenario "See page" do
custom_page = create(:site_customization_page,
slug: "other-slug",
title: "Custom page",
content: "Text for new custom page",
print_content_flag: false,
locale: "en"
title_en: "Custom page",
content_en: "Text for new custom page",
print_content_flag: false
)
visit custom_page.url
@@ -58,10 +55,9 @@ feature "Custom Pages" do
scenario "See page" do
custom_page = create(:site_customization_page, :published,
slug: "other-slug",
title: "Custom page",
content: "Text for new custom page",
print_content_flag: false,
locale: "en"
title_en: "Custom page",
content_en: "Text for new custom page",
print_content_flag: false
)
visit custom_page.url
@@ -75,11 +71,10 @@ feature "Custom Pages" do
scenario "Show all fields and text with links" do
custom_page = create(:site_customization_page, :published,
slug: "slug-with-all-fields-filled",
title: "Custom page",
subtitle: "This is my new custom page",
content: "Text for new custom page with a link to https://consul.dev",
print_content_flag: true,
locale: "en"
title_en: "Custom page",
subtitle_en: "This is my new custom page",
content_en: "Text for new custom page with a link to https://consul.dev",
print_content_flag: true
)
visit custom_page.url
@@ -95,11 +90,10 @@ feature "Custom Pages" do
scenario "Don't show subtitle if its blank" do
custom_page = create(:site_customization_page, :published,
slug: "slug-without-subtitle",
title: "Custom page",
subtitle: "",
content: "Text for new custom page",
print_content_flag: false,
locale: "en"
title_en: "Custom page",
subtitle_en: "",
content_en: "Text for new custom page",
print_content_flag: false
)
visit custom_page.url
@@ -113,10 +107,10 @@ feature "Custom Pages" do
scenario "Listed in more information page" do
custom_page = create(:site_customization_page, :published,
slug: "another-slug", title: "Another custom page",
subtitle: "Subtitle for custom page",
more_info_flag: true,
locale: "en"
slug: "another-slug",
title_en: "Another custom page",
subtitle_en: "Subtitle for custom page",
more_info_flag: true
)
visit help_path
@@ -126,10 +120,9 @@ feature "Custom Pages" do
scenario "Not listed in more information page" do
custom_page = create(:site_customization_page, :published,
slug: "another-slug", title: "Another custom page",
subtitle: "Subtitle for custom page",
more_info_flag: false,
locale: "en"
slug: "another-slug", title_en: "Another custom page",
subtitle_en: "Subtitle for custom page",
more_info_flag: false
)
visit help_path
@@ -142,24 +135,124 @@ feature "Custom Pages" do
expect(page).to have_selector("h1", text: "Another custom page")
expect(page).to have_content("Subtitle for custom page")
end
end
end
context "Translation" do
let(:custom_page) { create(:site_customization_page, :published,
slug: "example-page",
title_en: "Title in English",
title_es: "Titulo en Español",
subtitle_en: "Subtitle in English",
subtitle_es: "Subtitulo en Español",
content_en: "Content in English",
content_es: "Contenido en Español"
) }
scenario "Not listed in more information page due to different locale" do
custom_page = create(:site_customization_page, :published,
slug: "another-slug", title: "Ce texte est en français",
subtitle: "Subtitle for custom page",
more_info_flag: false,
locale: "fr"
)
background do
admin = create(:administrator)
login_as(admin.user)
end
visit help_path
before do
@edit_page_url = edit_admin_site_customization_page_path(custom_page)
end
expect(page).not_to have_content("Ce texte est en français")
scenario "Add a translation in Português", :js do
visit @edit_page_url
visit custom_page.url
select "Português", from: "translation_locale"
fill_in 'site_customization_page_title_pt_br', with: 'Titulo em Português'
expect(page).to have_title("Ce texte est en français")
expect(page).to have_selector("h1", text: "Ce texte est en français")
expect(page).to have_content("Subtitle for custom page")
click_button 'Update Custom page'
expect(page).to have_content "Page updated successfully"
visit @edit_page_url
expect(page).to have_field('site_customization_page_title_en', with: 'Title in English')
click_link "Español"
expect(page).to have_field('site_customization_page_title_es', with: 'Titulo en Español')
click_link "Português"
expect(page).to have_field('site_customization_page_title_pt_br', with: 'Titulo em Português')
end
scenario "Update a translation", :js do
visit @edit_page_url
click_link "Español"
fill_in 'site_customization_page_title_es', with: 'Titulo correcta en Español'
click_button 'Update Custom page'
expect(page).to have_content "Page updated successfully"
visit custom_page.url
select('English', from: 'locale-switcher')
expect(page).to have_content("Title in English")
select('Español', from: 'locale-switcher')
expect(page).to have_content("Titulo correcta en Español")
end
scenario "Remove a translation", :js do
visit @edit_page_url
click_link "Español"
click_link "Remove language"
expect(page).not_to have_link "Español"
click_button "Update Custom page"
visit @edit_page_url
expect(page).not_to have_link "Español"
end
context "Globalize javascript interface" do
scenario "Highlight current locale", :js do
visit @edit_page_url
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
visit @edit_page_url
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
visit @edit_page_url
expect(page).to have_field('site_customization_page_title_en', with: 'Title in English')
click_link "Español"
expect(page).to have_field('site_customization_page_title_es', with: 'Titulo en Español')
end
scenario "Select a locale and add it to the milestone form", :js do
visit @edit_page_url
select "Français", from: "translation_locale"
expect(page).to have_link "Français"
click_link "Français"
expect(page).to have_field('site_customization_page_title_fr')
end
end
end