diff options
Diffstat (limited to 'spec/controllers/general_controller_spec.rb')
-rw-r--r-- | spec/controllers/general_controller_spec.rb | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/spec/controllers/general_controller_spec.rb b/spec/controllers/general_controller_spec.rb index 3640a8148..1ffbda90d 100644 --- a/spec/controllers/general_controller_spec.rb +++ b/spec/controllers/general_controller_spec.rb @@ -64,7 +64,7 @@ describe GeneralController, "when searching" do it "should redirect from search query URL to pretty URL" do post :search_redirect, :query => "mouse" # query hidden in POST parameters - response.should redirect_to(:action => 'search', :combined => "mouse") # URL /search/:query + response.should redirect_to(:action => 'search', :combined => "mouse", :view => "requests") # URL /search/:query/all end describe "when using different locale settings" do @@ -122,6 +122,34 @@ describe GeneralController, "when searching" do end + it "should filter results based on end of URL being 'all'" do + get :search, :combined => ['"bob"', "all"] + assigns[:xapian_requests].results.size.should == 2 + assigns[:xapian_users].results.size.should == 1 + assigns[:xapian_bodies].results.size.should == 0 + end + + it "should filter results based on end of URL being 'users'" do + get :search, :combined => ['"bob"', "users"] + assigns[:xapian_requests].should == nil + assigns[:xapian_users].results.size.should == 1 + assigns[:xapian_bodies].should == nil + end + + it "should filter results based on end of URL being 'requests'" do + get :search, :combined => ['"bob"', "requests"] + assigns[:xapian_requests].results.size.should == 2 + assigns[:xapian_users].should == nil + assigns[:xapian_bodies].should == nil + end + + it "should filter results based on end of URL being 'bodies'" do + get :search, :combined => ['"quango"', "bodies"] + assigns[:xapian_requests].should == nil + assigns[:xapian_users].should == nil + assigns[:xapian_bodies].results.size.should == 1 + end + it "should show help when searching for nothing" do get :search_redirect, :query => nil response.should render_template('search') |