From 9b2351fad9c56e5c02764c2665e56991c7aecdc4 Mon Sep 17 00:00:00 2001 From: Stephen Daly Date: Wed, 24 Jun 2026 12:46:12 +0100 Subject: [PATCH] Add setting to globally disable asking for a copy of answers There is a setting on the form to configure whether or not the user is asked if they want to ask for a copy of their answers by logging in with One Login. Add a global setting to allow us to disable this feature for all forms in the case that One Login is unavailable. --- app/models/form.rb | 1 + config/settings.yml | 3 +++ spec/models/form_spec.rb | 10 ++++++++++ 3 files changed, 14 insertions(+) diff --git a/app/models/form.rb b/app/models/form.rb index cd2ce9e32..2519f982a 100644 --- a/app/models/form.rb +++ b/app/models/form.rb @@ -65,6 +65,7 @@ def welsh? end def copy_of_answers_enabled? + return false unless Settings.copy_of_answers_enabled return false unless form_document.respond_to?(:send_copy_of_answers) form_document.send_copy_of_answers == "enabled" diff --git a/config/settings.yml b/config/settings.yml index dc4cdf200..12910e9ee 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -74,3 +74,6 @@ show_browser_during_tests: false cloudwatch_metrics_enabled: false analytics_enabled: false + +# Allows us to globally disable users getting a copy of their answers in the case that One Login is unavailable. +copy_of_answers_enabled: true diff --git a/spec/models/form_spec.rb b/spec/models/form_spec.rb index 6270b54d9..7c4ae178c 100644 --- a/spec/models/form_spec.rb +++ b/spec/models/form_spec.rb @@ -186,6 +186,16 @@ it "returns true" do expect(form.copy_of_answers_enabled?).to be true end + + context "when the global copy_of_answers_enabled setting is set to false" do + before do + allow(Settings).to receive(:copy_of_answers_enabled).and_return(false) + end + + it "returns false" do + expect(form.copy_of_answers_enabled?).to be false + end + end end context "when send_copy_of_answers is \"disabled\"" do