aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/public_body.rb7
-rw-r--r--spec/models/public_body_spec.rb6
2 files changed, 12 insertions, 1 deletions
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index 961fa3cbb..23f71333d 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -284,7 +284,12 @@ class PublicBody < ActiveRecord::Base
def calculated_home_page
# manual override for ones we calculate wrongly
if self.home_page != ''
- return self.home_page
+ # Add standard URL prefix
+ if home_page[0..10] == 'http://www.'
+ return self.home_page
+ else
+ return "http://www.#{self.home_page}"
+ end
end
# extract the domain name from the FOI request email
diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb
index 17d877b68..142735cb0 100644
--- a/spec/models/public_body_spec.rb
+++ b/spec/models/public_body_spec.rb
@@ -421,5 +421,11 @@ describe PublicBody do
public_body.stub!(:request_email_domain).and_return nil
public_body.calculated_home_page.should be_nil
end
+
+ it "should ensure home page URLs start with http://" do
+ public_body = PublicBody.new
+ public_body.home_page = "example.com"
+ public_body.calculated_home_page.should == "http://www.example.com"
+ end
end
end