Permalink
Browse files

Updated filtering to use metasearch compatibility method instead of j…

…ust #search.

Active Admin should now be compatible with ThinkingSphynx or any other
app that implements the #search method on ActiveRecord::Base.

Fixes #28.
  • Loading branch information...
1 parent e7b4cc8 commit 033665d4345a86aa5b16da1ccb8b121b164bf266 @gregbell gregbell committed May 13, 2011
View
2 lib/active_admin/resource_controller/collection.rb
@@ -63,7 +63,7 @@ def active_admin_collection
end
def search(chain)
- @search = chain.search(clean_search_params(params[:q]))
+ @search = chain.metasearch(clean_search_params(params[:q]))
@search.relation
end
View
25 spec/unit/resource_controller/collection_spec.rb
@@ -0,0 +1,25 @@
+require 'spec_helper'
+
+describe ActiveAdmin::ResourceController::Collection do
+ let(:params) do
+ {}
+ end
+
+ let(:controller) do
+ rc = ActiveAdmin::ResourceController.new
+ rc.stub!(:params) do
+ params
+ end
+ rc
+ end
+
+ describe ActiveAdmin::ResourceController::Collection::Search do
+ let(:params){ {:q => {} }}
+ it "should call the metasearch method" do
+ chain = mock("ChainObj")
+ chain.should_receive(:metasearch).with(params[:q]).once.and_return(Post.search)
+ controller.send :search, chain
+ end
+ end
+
+end

0 comments on commit 033665d

Please sign in to comment.