diff options
-rw-r--r-- | app/models/public_body.rb | 9 | ||||
-rw-r--r-- | config/general.yml-example | 7 | ||||
-rw-r--r-- | spec/models/public_body_spec.rb | 8 |
3 files changed, 24 insertions, 0 deletions
diff --git a/app/models/public_body.rb b/app/models/public_body.rb index 2cf1ce8a2..1c1ddb377 100644 --- a/app/models/public_body.rb +++ b/app/models/public_body.rb @@ -509,6 +509,15 @@ class PublicBody < ActiveRecord::Base return self.request_email_domain end + def request_email + override_email = MySociety::Config.get("OVERRIDE_ALL_PUBLIC_BODY_REQUEST_EMAILS", "") + if override_email != "" + override_email + else + read_attribute(:request_email) + end + end + # Domain name of the request email def request_email_domain return PublicBody.extract_domain_from_email(self.request_email) diff --git a/config/general.yml-example b/config/general.yml-example index 7aa01e899..25e3dba46 100644 --- a/config/general.yml-example +++ b/config/general.yml-example @@ -161,3 +161,10 @@ VARNISH_HOST: localhost # Adding a value here will enable Google Analytics on all non-admin pages. GA_CODE: '' + +# If you want to override *all* the public body request emails with your own +# email so that request emails that would normally go to the public body +# go to you, then uncomment below and fill in your email. +# Useful for a staging server to play with the whole process of sending requests +# without inadvertently sending an email to a real authority +#OVERRIDE_ALL_PUBLIC_BODY_REQUEST_EMAILS: test-email@foo.com
\ No newline at end of file diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb index 011824190..ea78e5ec5 100644 --- a/spec/models/public_body_spec.rb +++ b/spec/models/public_body_spec.rb @@ -453,3 +453,11 @@ describe PublicBody do end end + +describe PublicBody, " when override all public body request emails set" do + it "should return the overridden request email" do + MySociety::Config.should_receive(:get).with("OVERRIDE_ALL_PUBLIC_BODY_REQUEST_EMAILS", "").and_return("catch_all_test_email@foo.com") + @geraldine = public_bodies(:geraldine_public_body) + @geraldine.request_email.should == "catch_all_test_email@foo.com" + end +end |