diff options
author | Henare Degan <henare.degan@gmail.com> | 2012-02-16 16:59:59 +1100 |
---|---|---|
committer | Henare Degan <henare.degan@gmail.com> | 2012-02-16 16:59:59 +1100 |
commit | d07f09d2407a7455dea2e835de791a0a92fc15a4 (patch) | |
tree | c7763537ca2f975f039235470b52f7e471648aa1 | |
parent | 506af7a640f63b17000ccfc5e1344bbc3039c913 (diff) |
Add some tests for the public body home page calculation
-rw-r--r-- | spec/models/public_body_spec.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb index db0de78b2..17d877b68 100644 --- a/spec/models/public_body_spec.rb +++ b/spec/models/public_body_spec.rb @@ -401,3 +401,25 @@ describe PublicBody, " when loading CSV files" do PublicBody.count.should == original_count end end + +describe PublicBody do + describe "calculated home page" do + it "should return the home page verbatim if it's present" do + public_body = PublicBody.new + public_body.home_page = "http://www.example.com" + public_body.calculated_home_page.should == "http://www.example.com" + end + + it "should return the home page based on the request email domain if it has one" do + public_body = PublicBody.new + public_body.stub!(:request_email_domain).and_return "public-authority.com" + public_body.calculated_home_page.should == "http://www.public-authority.com" + end + + it "should return nil if there's no home page and the email domain can't be worked out" do + public_body = PublicBody.new + public_body.stub!(:request_email_domain).and_return nil + public_body.calculated_home_page.should be_nil + end + end +end |