Skip to content

Commit

Permalink
allow official proposals to be amended in any language
Browse files Browse the repository at this point in the history
  • Loading branch information
microstudi committed Feb 22, 2024
1 parent d9984a9 commit 5e5ea01
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/controllers/concerns/amendments_enforce_locale.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
17 changes: 16 additions & 1 deletion spec/system/limit_amendments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5e5ea01

Please sign in to comment.