diff options
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/public_body_spec.rb | 34 | ||||
-rw-r--r-- | spec/models/purge_request_spec.rb | 32 | ||||
-rw-r--r-- | spec/models/track_thing_spec.rb | 7 |
3 files changed, 72 insertions, 1 deletions
diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb index db0de78b2..e30916dff 100644 --- a/spec/models/public_body_spec.rb +++ b/spec/models/public_body_spec.rb @@ -401,3 +401,37 @@ 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 + + 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://example.com" + end + + it "should not add http when https is present" do + public_body = PublicBody.new + public_body.home_page = "https://example.com" + public_body.calculated_home_page.should == "https://example.com" + end + end +end diff --git a/spec/models/purge_request_spec.rb b/spec/models/purge_request_spec.rb new file mode 100644 index 000000000..94fe01317 --- /dev/null +++ b/spec/models/purge_request_spec.rb @@ -0,0 +1,32 @@ +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') +require 'fakeweb' + +describe PurgeRequest, "purging things" do + before do + FakeWeb.last_request = nil + end + + it 'should issue purge requests to the server' do + req = PurgeRequest.new(:url => "/begone_from_here", + :model => "don't care", + :model_id => "don't care") + req.save() + PurgeRequest.all().count.should == 1 + PurgeRequest.purge_all() + PurgeRequest.all().count.should == 0 + end + + it 'should fail silently for a misconfigured server' do + FakeWeb.register_uri(:get, %r|brokenv|, :body => "BROKEN") + config = MySociety::Config.load_default() + config['VARNISH_HOST'] = "brokencache" + req = PurgeRequest.new(:url => "/begone_from_here", + :model => "don't care", + :model_id => "don't care") + req.save() + PurgeRequest.all().count.should == 1 + PurgeRequest.purge_all() + PurgeRequest.all().count.should == 0 + end +end + diff --git a/spec/models/track_thing_spec.rb b/spec/models/track_thing_spec.rb index bd122941a..345629bd6 100644 --- a/spec/models/track_thing_spec.rb +++ b/spec/models/track_thing_spec.rb @@ -36,7 +36,7 @@ describe TrackThing, "when tracking changes" do it "will make some sane descriptions of search-based tracks" do tests = [['bob variety:user', "users matching text 'bob'"], - ['bob (variety:sent OR variety:followup_sent OR variety:response OR variety:comment) (latest_status:successful OR latest_status:partially_successful OR latest_status:rejected OR latest_status:not_held)', "requests which are successful or unsuccessful or comments matching text 'bob'"], + ['bob (variety:sent OR variety:followup_sent OR variety:response OR variety:comment) (latest_status:successful OR latest_status:partially_successful OR latest_status:rejected OR latest_status:not_held)', "comments or requests which are successful or unsuccessful matching text 'bob'"], ['(latest_status:waiting_response OR latest_status:waiting_clarification OR waiting_classification:true)', 'requests which are awaiting a response']] for query, description in tests track_thing = TrackThing.create_track_for_search_query(query) @@ -44,5 +44,10 @@ describe TrackThing, "when tracking changes" do end end + it "will create an authority-based track when called using a 'bodies' postfix" do + track_thing = TrackThing.create_track_for_search_query('fancy dog', 'bodies') + track_thing.track_query.should =~ /variety:authority/ + end + end |