diff options
| author | Seb Bacon <seb.bacon@gmail.com> | 2011-09-16 12:43:27 +0100 | 
|---|---|---|
| committer | Seb Bacon <seb.bacon@gmail.com> | 2011-09-16 12:43:27 +0100 | 
| commit | 312f9e1191dd4d7d0e976728561c4b74d8b84588 (patch) | |
| tree | 506a615c2bbb95cf7f30a1655ef6ccd7e2d2f521 /spec/controllers/request_controller_spec.rb | |
| parent | 8a0210db99a146a2700a5db0335618423ea756a0 (diff) | |
| parent | d54f405434a3b0da5f2c88fc065680caf044aff2 (diff) | |
Merge branch 'release/0.3'0.3
Diffstat (limited to 'spec/controllers/request_controller_spec.rb')
| -rw-r--r-- | spec/controllers/request_controller_spec.rb | 34 | 
1 files changed, 22 insertions, 12 deletions
| diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index f69cf414c..f3084af12 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -1,7 +1,3 @@ -# £2k p/a -# talk about margins -#  -  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')  require 'json' @@ -24,13 +20,29 @@ describe RequestController, "when listing recent requests" do          response.should render_template('list')      end +    it "should filter requests" do +        get :list, :view => 'all' +        assigns[:list_results].size.should == 2 +        get :list, :view => 'successful' +        assigns[:list_results].size.should == 0 +    end + +    it "should filter requests by date" do +        get :list, :view => 'all', :request_date_before => '13/10/2007' +        assigns[:list_results].size.should == 1 +        get :list, :view => 'all', :request_date_after => '13/10/2007' +        assigns[:list_results].size.should == 1 +        get :list, :view => 'all', :request_date_after => '10/10/2007', :request_date_before => '01/01/2010' +        assigns[:list_results].size.should == 2 +    end +      it "should assign the first page of results" do          xap_results = mock_model(ActsAsXapian::Search,                      :results => (1..25).to_a.map { |m| { :model => m } },                     :matches_estimated => 103)          InfoRequest.should_receive(:full_search). -          with([InfoRequestEvent],"variety:sent", "created_at", anything, anything, anything, anything). +          with([InfoRequestEvent]," variety:sent", "created_at", anything, anything, anything, anything).            and_return(xap_results)          get :list, :view => 'recent'          assigns[:list_results].size.should == 25 @@ -149,7 +161,7 @@ describe RequestController, "when showing one request" do              lambda {                  get :get_attachment, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 2,                       :file_name => ['http://trying.to.hack'] -            }.should raise_error(RuntimeError) +            }.should raise_error(ActiveRecord::RecordNotFound)          end          it "should censor attachments downloaded as binary" do @@ -735,18 +747,16 @@ describe RequestController, "when classifying an information request" do              response.should redirect_to(:controller => 'help', :action => 'unhappy', :url_title => @dog_request.url_title)          end -        describe "when using custom statuses from the theme" do +        it "knows about extended states" do              InfoRequest.send(:require, File.expand_path(File.join(File.dirname(__FILE__), '..', 'models', 'customstates')))              InfoRequest.send(:include, InfoRequestCustomStates)              InfoRequest.class_eval('@@custom_states_loaded = true')              RequestController.send(:require, File.expand_path(File.join(File.dirname(__FILE__), '..', 'models', 'customstates')))              RequestController.send(:include, RequestControllerCustomStates)              RequestController.class_eval('@@custom_states_loaded = true') -            it "knows about extended states" do -                Time.stub!(:now).and_return(Time.utc(2007, 11, 10, 00, 01))  -                post_status('deadline_extended') -                flash[:notice].should == 'Authority has requested extension of the deadline.' -            end +            Time.stub!(:now).and_return(Time.utc(2007, 11, 10, 00, 01))  +            post_status('deadline_extended') +            flash[:notice].should == 'Authority has requested extension of the deadline.'          end      end | 
