Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Searching works, but currently only on zones. [#2 state:open]
- Loading branch information
keegan
committed
Jul 15, 2008
1 parent
aff8f8c
commit 80b1d06
Showing
6 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class SearchController < ApplicationController | ||
|
||
def results | ||
@search_parameter = params[:search][:parameter] | ||
if @search_parameter.blank? | ||
redirect_to root_path | ||
else | ||
@results = Zone.search(@search_parameter) | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module SearchHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require File.dirname(__FILE__) + '/../spec_helper' | ||
|
||
describe SearchController do | ||
fixtures :all | ||
|
||
before(:each) do | ||
session[:user_id] = users(:admin).id | ||
end | ||
|
||
it "should return results when searched legally" do | ||
post :results, :search => { :parameter => 'exa' } | ||
|
||
assigns['results'].should_not be_nil | ||
response.should render_template('results') | ||
end | ||
|
||
it "should redirect to the index page when nothing has been searched for" do | ||
post :results, :search => { :parameter => "" } | ||
|
||
response.should be_redirect | ||
response.should redirect_to( root_path ) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require File.dirname(__FILE__) + '/../spec_helper' | ||
|
||
describe SearchHelper do | ||
|
||
#Delete this example and add some real ones or delete this file | ||
it "should include the SearchHelper" do | ||
included_modules = self.metaclass.send :included_modules | ||
included_modules.should include(SearchHelper) | ||
end | ||
|
||
end |