From 5e5ea017b2402f5f5939e6a40c8314f1a0a3852f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Verg=C3=A9s?= Date: Thu, 22 Feb 2024 12:20:41 +0100 Subject: [PATCH] allow official proposals to be amended in any language --- .../concerns/amendments_enforce_locale.rb | 1 + spec/system/limit_amendments_spec.rb | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/controllers/concerns/amendments_enforce_locale.rb b/app/controllers/concerns/amendments_enforce_locale.rb index b0da241d..6e798d8d 100644 --- a/app/controllers/concerns/amendments_enforce_locale.rb +++ b/app/controllers/concerns/amendments_enforce_locale.rb @@ -11,6 +11,7 @@ module AmendmentsEnforceLocale def enforce_amendment_locale(&action) if amendable.component.settings.try(:amendments_enabled) && amendable.component.current_settings.try(:amendment_creation_enabled) && + !amendable&.official? && Rails.application.secrets.gpc[:enforce_original_amendments_locale] amendable_locale = amendable.title.keys.first diff --git a/spec/system/limit_amendments_spec.rb b/spec/system/limit_amendments_spec.rb index aa7cde30..a2506623 100644 --- a/spec/system/limit_amendments_spec.rb +++ b/spec/system/limit_amendments_spec.rb @@ -177,7 +177,22 @@ def amendment_path expect(page).not_to have_field(with: "Proposition en langue anglaise") fill_in "Title", with: "New Proposal in english language" click_button "Create" - expect(page).to have_content("No similar emendations found") + expect(page).to have_content("Amendment draft has been created successfully.") + end + + context "and is an official proposal" do + let(:proposal) { create :proposal, :official, users: [creator], component: component, title: { en: "Proposal in english language", machine_translations: { fr: "Proposition en langue anglaise" } } } + + it "Does not enforce the original locale" do + expect(page).not_to have_content("Cette proposition a été initialement créée dans English") + expect(page).not_to have_content("CREATE AMENDMENT DRAFT") + expect(page).to have_content("CRÉER UN PROJET D'AMENDEMENT") + expect(page).not_to have_field(with: "Proposal in english language") + expect(page).to have_field(with: "Proposition en langue anglaise") + fill_in "Titre", with: "Nouveau proposition en langue anglaise" + click_button "Créer" + expect(page).to have_content("Aucune modification similaire trouvé.") + end end context "and not enforced" do