From 33bd0e919528e1d7eda4be4200db91b042984c97 Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Fri, 26 Aug 2011 13:54:05 +0100 Subject: Fixes to get tests to pass following addition of new search / filter functionality --- spec/controllers/request_controller_spec.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'spec/controllers/request_controller_spec.rb') diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index f69cf414c..7d0cd2c1a 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' @@ -30,7 +26,7 @@ describe RequestController, "when listing recent requests" do :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 -- cgit v1.2.3 From b41edc7ae069e6071f7ff7223c1e60cca5e75e8c Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Mon, 29 Aug 2011 13:13:59 +0100 Subject: Add tests & fixes for new search/filtering functionality --- spec/controllers/request_controller_spec.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'spec/controllers/request_controller_spec.rb') diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index 7d0cd2c1a..2b153ac7a 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -20,6 +20,22 @@ 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 } }, -- cgit v1.2.3