aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/public_body.rb12
-rw-r--r--app/views/request/new_bad_contact.html.erb2
-rwxr-xr-xscript/switch-theme.rb2
-rw-r--r--spec/models/public_body_spec.rb27
-rw-r--r--spec/views/public_body/show.html.erb_spec.rb1
5 files changed, 32 insertions, 12 deletions
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index cb412f9dc..5bce8ecc7 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -577,17 +577,11 @@ class PublicBody < ActiveRecord::Base
return self.request_email_domain
end
- # Returns nil if configuration variable not set
- def override_request_email
- e = AlaveteliConfiguration::override_all_public_body_request_emails
- e if e != ""
- end
-
def request_email
- if override_request_email
- override_request_email
- else
+ if AlaveteliConfiguration::override_all_public_body_request_emails.blank? || read_attribute(:request_email).blank?
read_attribute(:request_email)
+ else
+ AlaveteliConfiguration::override_all_public_body_request_emails
end
end
diff --git a/app/views/request/new_bad_contact.html.erb b/app/views/request/new_bad_contact.html.erb
index 56f3f4168..f9881b62b 100644
--- a/app/views/request/new_bad_contact.html.erb
+++ b/app/views/request/new_bad_contact.html.erb
@@ -5,6 +5,6 @@
<p><%= _('Unfortunately, we do not have a working {{info_request_law_used_full}}
address for', :info_request_law_used_full => @info_request.law_used_full) %> <%=h @info_request.public_body.name %>. <%= _('You may be able to find
one on their website, or by phoning them up and asking. If you manage
-to find one, then please <a href="{{help_url}}">send it to us</a>.', :help_url => help_contact_path) %>
+to find one, then please <a href="{{help_url}}">send it to us</a>.', :help_url => new_change_request_path(:body => @info_request.public_body.url_name)) %>
</p>
diff --git a/script/switch-theme.rb b/script/switch-theme.rb
index 980853687..146d1bf0c 100755
--- a/script/switch-theme.rb
+++ b/script/switch-theme.rb
@@ -129,5 +129,5 @@ STDERR.puts """Switched to #{requested_theme}!
You will need to:
1. restart any development server you have running.
2. run: bundle exec rake assets:clean
- 3. run: bundle exec rake assets:precompile
+ 3. run: bundle exec rake assets:precompile (if running in production mode)
"""
diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb
index 7b55efda1..cce017424 100644
--- a/spec/models/public_body_spec.rb
+++ b/spec/models/public_body_spec.rb
@@ -1237,6 +1237,33 @@ describe PublicBody do
end
+ describe :request_email do
+ context "when the email is set" do
+ subject(:public_body) { FactoryGirl.create(:public_body, :request_email => "request@example.com") }
+
+ it "should return the set email address" do
+ expect(public_body.request_email).to eq("request@example.com")
+ end
+
+ it "should return a different email address when overridden in configuration" do
+ AlaveteliConfiguration.stub!(:override_all_public_body_request_emails).and_return("tester@example.com")
+ expect(public_body.request_email).to eq("tester@example.com")
+ end
+ end
+
+ context "when no email is set" do
+ subject(:public_body) { FactoryGirl.create(:public_body, :request_email => "") }
+
+ it "should return a blank email address" do
+ expect(public_body.request_email).to be_blank
+ end
+
+ it "should still return a blank email address when overridden in configuration" do
+ AlaveteliConfiguration.stub!(:override_all_public_body_request_emails).and_return("tester@example.com")
+ expect(public_body.request_email).to be_blank
+ end
+ end
+ end
end
describe PublicBody::Translation do
diff --git a/spec/views/public_body/show.html.erb_spec.rb b/spec/views/public_body/show.html.erb_spec.rb
index 6ebc39caa..2a4c21d04 100644
--- a/spec/views/public_body/show.html.erb_spec.rb
+++ b/spec/views/public_body/show.html.erb_spec.rb
@@ -13,7 +13,6 @@ describe "public_body/show" do
:publication_scheme => '',
:disclosure_log => '',
:calculated_home_page => '')
- @pb.stub!(:override_request_email).and_return(nil)
@pb.stub!(:is_requestable?).and_return(true)
@pb.stub!(:special_not_requestable_reason?).and_return(false)
@pb.stub!(:has_notes?).and_return(false)