diff options
| author | mo khan <mo@mokhan.ca> | 2013-05-09 07:12:42 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2013-05-09 07:12:42 -0600 |
| commit | 3c282dd665dfdb6cd5880da5d3394b347f4739e8 (patch) | |
| tree | 3d8d1b21c2f9ecf0141464d9da479586bceed007 /spec | |
| parent | fdb71218fcf4f514cfbceb5ceb0df54166839923 (diff) | |
redirect to root url instead of route that does not exist.
https://cakeside.airbrake.io/groups/57695470
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/controllers/search_controller_spec.rb | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/spec/controllers/search_controller_spec.rb b/spec/controllers/search_controller_spec.rb index 741963f2..10f804e8 100644 --- a/spec/controllers/search_controller_spec.rb +++ b/spec/controllers/search_controller_spec.rb @@ -2,31 +2,40 @@ require 'spec_helper' describe SearchController do describe "GET 'index'" do - let!(:user) { FactoryGirl.create(:user, :name => 'cake') } - let!(:bob) { FactoryGirl.create(:user, :name => 'bob') } - let!(:cake) { FactoryGirl.create(:creation, :name => 'cake') } - let!(:donut) { FactoryGirl.create(:creation, :name => 'donut') } + context "when no search query is given" do + before { get :index } - before { get :index, { :q => 'cake' } } - - it "should be successful" do - response.should be_success + it "should redirect you to the home page" do + response.should redirect_to(root_url) + end end + context "when a valid search query is given" do + let!(:user) { FactoryGirl.create(:user, :name => 'cake') } + let!(:bob) { FactoryGirl.create(:user, :name => 'bob') } + let!(:cake) { FactoryGirl.create(:creation, :name => 'cake') } + let!(:donut) { FactoryGirl.create(:creation, :name => 'donut') } - it "should return all creations that have a matching name" do - assigns(:creations).should include(cake) - end + before { get :index, { :q => 'cake' } } - it "should not include cakes that do not match" do - assigns(:creations).should_not include(donut) - end + it "should be successful" do + response.should be_success + end - it "should return all makers that match" do - assigns(:members).should include(user) - end + it "should return all creations that have a matching name" do + assigns(:creations).should include(cake) + end + + it "should not include cakes that do not match" do + assigns(:creations).should_not include(donut) + end + + it "should return all makers that match" do + assigns(:members).should include(user) + end - it "should not include makers with names that do not match" do - assigns(:members).should_not include(bob) + it "should not include makers with names that do not match" do + assigns(:members).should_not include(bob) + end end end end |
