Share translatable specs
This commit is contained in:
@@ -188,78 +188,4 @@ feature 'Admin banners magement' do
|
||||
visit admin_root_path
|
||||
expect(page).not_to have_content 'Ugly banner'
|
||||
end
|
||||
|
||||
context "Translations" do
|
||||
|
||||
let(:banner) { create(:banner, title_en: "Title in English",
|
||||
title_es: "Título en Español",
|
||||
target_url: 'http://url.com',
|
||||
description_en: "Description in English",
|
||||
description_es: "Descripción en Español") }
|
||||
|
||||
before do
|
||||
@edit_banner_url = edit_admin_banner_path(banner)
|
||||
end
|
||||
|
||||
scenario "Add a translation", :js do
|
||||
visit @edit_banner_url
|
||||
|
||||
select "Français", from: "translation_locale"
|
||||
fill_in 'banner_title_fr', with: 'Titre en Français'
|
||||
fill_in 'banner_description_fr', with: 'Description en Français'
|
||||
|
||||
click_button 'Save changes'
|
||||
|
||||
visit @edit_banner_url
|
||||
expect(page).to have_field('banner_description_en', with: 'Description in English')
|
||||
|
||||
click_link "Español"
|
||||
expect(page).to have_field('banner_description_es', with: 'Descripción en Español')
|
||||
|
||||
click_link "Français"
|
||||
expect(page).to have_field('banner_description_fr', with: 'Description en Français')
|
||||
end
|
||||
|
||||
scenario "Update a translation", :js do
|
||||
banner.update_attributes(target_url: 'http://www.url.com',
|
||||
post_started_at: (Time.current - 4.days),
|
||||
post_ended_at: (Time.current + 10.days))
|
||||
|
||||
section = create(:web_section, name: 'debates')
|
||||
create(:banner_section, web_section: section, banner_id: banner.id)
|
||||
|
||||
visit @edit_banner_url
|
||||
|
||||
click_link "Español"
|
||||
fill_in 'banner_title_es', with: 'Título correcto en Español'
|
||||
|
||||
click_button 'Save changes'
|
||||
|
||||
visit debates_path
|
||||
|
||||
within('.banner') do
|
||||
expect(page).to have_content("Description in English")
|
||||
end
|
||||
|
||||
select('Español', from: 'locale-switcher')
|
||||
|
||||
within('.banner') do
|
||||
expect(page).to have_content('Título correcto en Español')
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Remove a translation", :js do
|
||||
|
||||
visit @edit_banner_url
|
||||
|
||||
click_link "Español"
|
||||
click_link "Remove language"
|
||||
|
||||
expect(page).not_to have_link "Español"
|
||||
|
||||
click_button "Save changes"
|
||||
visit @edit_banner_url
|
||||
expect(page).not_to have_link "Español"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user