diff options
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/admin_request_controller_spec.rb | 6 | ||||
-rw-r--r-- | spec/controllers/api_controller_spec.rb | 11 | ||||
-rw-r--r-- | spec/controllers/public_body_change_requests_controller_spec.rb | 18 |
3 files changed, 32 insertions, 3 deletions
diff --git a/spec/controllers/admin_request_controller_spec.rb b/spec/controllers/admin_request_controller_spec.rb index 63b219c88..7c5253f49 100644 --- a/spec/controllers/admin_request_controller_spec.rb +++ b/spec/controllers/admin_request_controller_spec.rb @@ -60,6 +60,12 @@ describe AdminRequestController, "when administering requests" do get :fully_destroy, { :id => info_request } end + it 'uses a different flash message to avoid trying to fetch a non existent user record' do + info_request = info_requests(:external_request) + post :fully_destroy, { :id => info_request.id } + request.flash[:notice].should include('external') + end + end end diff --git a/spec/controllers/api_controller_spec.rb b/spec/controllers/api_controller_spec.rb index 7b1d73e8a..323ef4cd4 100644 --- a/spec/controllers/api_controller_spec.rb +++ b/spec/controllers/api_controller_spec.rb @@ -514,7 +514,7 @@ describe ApiController, "when using the API" do assigns[:event_data].should == [first_event] end - it 'should honour the since_date parameter for the Atom feed' do + it 'should honour the since_date parameter' do get :body_request_events, :id => public_bodies(:humpadink_public_body).id, :k => public_bodies(:humpadink_public_body).api_key, @@ -527,6 +527,15 @@ describe ApiController, "when using the API" do assigns[:events].each do |event| event.created_at.should >= Date.new(2010, 1, 1) end + + get :body_request_events, + :id => public_bodies(:humpadink_public_body).id, + :k => public_bodies(:humpadink_public_body).api_key, + :since_date => '2010-01-01', + :feed_type => 'json' + assigns[:events].each do |event| + event.created_at.should >= Date.new(2010, 1, 1) + end end end end diff --git a/spec/controllers/public_body_change_requests_controller_spec.rb b/spec/controllers/public_body_change_requests_controller_spec.rb index 7b878b893..8fe7befeb 100644 --- a/spec/controllers/public_body_change_requests_controller_spec.rb +++ b/spec/controllers/public_body_change_requests_controller_spec.rb @@ -22,7 +22,8 @@ describe PublicBodyChangeRequestsController, "creating a change request" do :public_body_name => 'New Body', :public_body_email => 'new_body@example.com', :notes => 'Please', - :source => 'http://www.example.com'} + :source => 'http://www.example.com', + :comment => '' } end it "should send an email to the site contact address" do @@ -51,6 +52,18 @@ describe PublicBodyChangeRequestsController, "creating a change request" do response.should redirect_to frontpage_url end + it 'has rudimentary spam protection' do + spam_request_params = @change_request_params.merge({ :comment => 'I AM A SPAMBOT' }) + + post :create, { :public_body_change_request => spam_request_params } + + response.should redirect_to(frontpage_path) + + deliveries = ActionMailer::Base.deliveries + deliveries.size.should == 0 + deliveries.clear + end + end context 'when handling a request for an update to an existing authority' do @@ -64,7 +77,8 @@ describe PublicBodyChangeRequestsController, "creating a change request" do :public_body_id => @public_body.id, :public_body_email => 'new_body@example.com', :notes => 'Please', - :source => 'http://www.example.com'} + :source => 'http://www.example.com', + :comment => '' } end it 'should send an email to the site contact address' do |