Merge pull request #2912 from consul/backport-make-collaborative-legislation-translatable
Make collaborative legislation translatable
This commit is contained in:
@@ -7,6 +7,11 @@ feature 'Admin legislation draft versions' do
|
||||
login_as(admin.user)
|
||||
end
|
||||
|
||||
it_behaves_like "translatable",
|
||||
"legislation_draft_version",
|
||||
"edit_admin_legislation_process_draft_version_path",
|
||||
%w[title changelog]
|
||||
|
||||
context "Feature flag" do
|
||||
|
||||
scenario 'Disabled with a feature flag' do
|
||||
@@ -53,9 +58,9 @@ feature 'Admin legislation draft versions' do
|
||||
|
||||
click_link 'Create version'
|
||||
|
||||
fill_in 'legislation_draft_version_title', with: 'Version 3'
|
||||
fill_in 'legislation_draft_version_changelog', with: 'Version 3 changes'
|
||||
fill_in 'legislation_draft_version_body', with: 'Version 3 body'
|
||||
fill_in 'legislation_draft_version_title_en', with: 'Version 3'
|
||||
fill_in 'legislation_draft_version_changelog_en', with: 'Version 3 changes'
|
||||
fill_in 'legislation_draft_version_body_en', with: 'Version 3 body'
|
||||
|
||||
within('.end') do
|
||||
click_button 'Create version'
|
||||
@@ -86,11 +91,11 @@ feature 'Admin legislation draft versions' do
|
||||
|
||||
click_link 'Version 1'
|
||||
|
||||
fill_in 'legislation_draft_version_title', with: 'Version 1b'
|
||||
fill_in 'legislation_draft_version_title_en', with: 'Version 1b'
|
||||
|
||||
click_link 'Launch text editor'
|
||||
|
||||
fill_in 'legislation_draft_version_body', with: '# Version 1 body\r\n\r\nParagraph\r\n\r\n>Quote'
|
||||
fill_in 'legislation_draft_version_body_en', with: '# Version 1 body\r\n\r\nParagraph\r\n\r\n>Quote'
|
||||
|
||||
within('.fullscreen') do
|
||||
click_link 'Close text editor'
|
||||
@@ -101,4 +106,31 @@ feature 'Admin legislation draft versions' do
|
||||
expect(page).to have_content 'Version 1b'
|
||||
end
|
||||
end
|
||||
|
||||
context "Special translation behaviour" do
|
||||
|
||||
let!(:draft_version) { create(:legislation_draft_version) }
|
||||
|
||||
scenario 'Add body translation through markup editor', :js do
|
||||
edit_path = edit_admin_legislation_process_draft_version_path(draft_version.process, draft_version)
|
||||
|
||||
visit edit_path
|
||||
|
||||
select "Français", from: "translation_locale"
|
||||
|
||||
click_link 'Launch text editor'
|
||||
|
||||
fill_in 'legislation_draft_version_body_fr', with: 'Texte en Français'
|
||||
|
||||
click_link 'Close text editor'
|
||||
click_button "Save changes"
|
||||
|
||||
visit edit_path
|
||||
|
||||
click_link "Français"
|
||||
click_link 'Launch text editor'
|
||||
|
||||
expect(page).to have_field('legislation_draft_version_body_fr', with: 'Texte en Français')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,6 +7,11 @@ feature 'Admin legislation processes' do
|
||||
login_as(admin.user)
|
||||
end
|
||||
|
||||
it_behaves_like "translatable",
|
||||
"legislation_process",
|
||||
"edit_admin_legislation_process_path",
|
||||
%w[title summary description additional_info]
|
||||
|
||||
context "Feature flag" do
|
||||
|
||||
scenario 'Disabled with a feature flag' do
|
||||
@@ -38,9 +43,9 @@ feature 'Admin legislation processes' do
|
||||
|
||||
click_link "New process"
|
||||
|
||||
fill_in 'legislation_process_title', with: 'An example legislation process'
|
||||
fill_in 'legislation_process_summary', with: 'Summary of the process'
|
||||
fill_in 'legislation_process_description', with: 'Describing the process'
|
||||
fill_in 'legislation_process_title_en', with: 'An example legislation process'
|
||||
fill_in 'legislation_process_summary_en', with: 'Summary of the process'
|
||||
fill_in 'legislation_process_description_en', with: 'Describing the process'
|
||||
|
||||
base_date = Date.current
|
||||
fill_in 'legislation_process[start_date]', with: base_date.strftime("%d/%m/%Y")
|
||||
@@ -93,7 +98,7 @@ feature 'Admin legislation processes' do
|
||||
expect(find("#legislation_process_debate_phase_enabled")).to be_checked
|
||||
expect(find("#legislation_process_published")).to be_checked
|
||||
|
||||
fill_in 'legislation_process_summary', with: ''
|
||||
fill_in 'legislation_process_summary_en', with: ''
|
||||
click_button "Save changes"
|
||||
|
||||
expect(page).to have_content "Process updated successfully"
|
||||
@@ -125,5 +130,16 @@ feature 'Admin legislation processes' do
|
||||
|
||||
expect(page).not_to have_content 'Draft publication'
|
||||
end
|
||||
|
||||
scenario "Change proposal categories" do
|
||||
visit edit_admin_legislation_process_path(process)
|
||||
within(".admin-content") { click_link "Proposals" }
|
||||
|
||||
fill_in "Categories", with: "recycling,bicycles"
|
||||
click_button "Save changes"
|
||||
|
||||
visit admin_legislation_process_proposals_path(process)
|
||||
expect(page).to have_field("Categories", with: "bicycles, recycling")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,6 +7,11 @@ feature 'Admin legislation questions' do
|
||||
login_as(admin.user)
|
||||
end
|
||||
|
||||
it_behaves_like "translatable",
|
||||
"legislation_question",
|
||||
"edit_admin_legislation_process_question_path",
|
||||
%w[title]
|
||||
|
||||
context "Feature flag" do
|
||||
|
||||
background do
|
||||
@@ -60,7 +65,7 @@ feature 'Admin legislation questions' do
|
||||
|
||||
click_link 'Create question'
|
||||
|
||||
fill_in 'legislation_question_title', with: 'Question 3'
|
||||
fill_in 'legislation_question_title_en', with: 'Question 3'
|
||||
click_button 'Create question'
|
||||
|
||||
expect(page).to have_content 'Question 3'
|
||||
@@ -87,7 +92,7 @@ feature 'Admin legislation questions' do
|
||||
|
||||
click_link 'Question 2'
|
||||
|
||||
fill_in 'legislation_question_title', with: 'Question 2b'
|
||||
fill_in 'legislation_question_title_en', with: 'Question 2b'
|
||||
click_button 'Save changes'
|
||||
|
||||
expect(page).to have_content 'Question 2b'
|
||||
@@ -111,4 +116,60 @@ feature 'Admin legislation questions' do
|
||||
expect(page).not_to have_content 'Question 2'
|
||||
end
|
||||
end
|
||||
|
||||
context "Special translation behaviour" do
|
||||
|
||||
let!(:question) { create(:legislation_question,
|
||||
title_en: "Title in English",
|
||||
title_es: "Título en Español") }
|
||||
|
||||
before do
|
||||
@edit_question_url = edit_admin_legislation_process_question_path(question.process, question)
|
||||
end
|
||||
|
||||
scenario 'Add translation for question option', :js do
|
||||
visit @edit_question_url
|
||||
|
||||
click_on 'Add option'
|
||||
|
||||
find('#nested-question-options input').set('Option 1')
|
||||
|
||||
click_link "Español"
|
||||
|
||||
find('#nested-question-options input').set('Opción 1')
|
||||
|
||||
click_button "Save changes"
|
||||
visit @edit_question_url
|
||||
|
||||
expect(page).to have_field('legislation_question_question_options_attributes_0_value_en', with: 'Option 1')
|
||||
|
||||
click_link "Español"
|
||||
|
||||
expect(page).to have_field('legislation_question_question_options_attributes_0_value_es', with: 'Opción 1')
|
||||
end
|
||||
|
||||
scenario 'Add new question option after changing active locale', :js do
|
||||
visit @edit_question_url
|
||||
|
||||
click_link "Español"
|
||||
|
||||
click_on 'Add option'
|
||||
|
||||
find('#nested-question-options input').set('Opción 1')
|
||||
|
||||
click_link "English"
|
||||
|
||||
find('#nested-question-options input').set('Option 1')
|
||||
|
||||
click_button "Save changes"
|
||||
|
||||
visit @edit_question_url
|
||||
|
||||
expect(page).to have_field('legislation_question_question_options_attributes_0_value_en', with: 'Option 1')
|
||||
|
||||
click_link "Español"
|
||||
|
||||
expect(page).to have_field('legislation_question_question_options_attributes_0_value_es', with: 'Opción 1')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user