aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/public_body.rb9
-rw-r--r--spec/models/public_body_spec.rb2
2 files changed, 7 insertions, 4 deletions
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index 1c1ddb377..d1ed74110 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -509,10 +509,13 @@ class PublicBody < ActiveRecord::Base
return self.request_email_domain
end
+ def override_request_email
+ MySociety::Config.get("OVERRIDE_ALL_PUBLIC_BODY_REQUEST_EMAILS", "")
+ end
+
def request_email
- override_email = MySociety::Config.get("OVERRIDE_ALL_PUBLIC_BODY_REQUEST_EMAILS", "")
- if override_email != ""
- override_email
+ if override_request_email != ""
+ override_request_email
else
read_attribute(:request_email)
end
diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb
index ea78e5ec5..c2e0a6353 100644
--- a/spec/models/public_body_spec.rb
+++ b/spec/models/public_body_spec.rb
@@ -456,7 +456,7 @@ 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")
+ MySociety::Config.should_receive(:get).with("OVERRIDE_ALL_PUBLIC_BODY_REQUEST_EMAILS", "").twice.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