Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge remote-tracking branch 'karmi/master'

  • Loading branch information...
commit 5207680f6b5f0b8792d222ee01c6442b63d21ab1 2 parents 604bc7d + 9412ef0
Davide authored
View
3  lib/tire/model/search.rb
@@ -72,8 +72,8 @@ def search(*args, &block)
options ||= {}
end
- sort = Array( options[:order] || options[:sort] )
options = default_options.update(options)
+ sort = Array( options.delete(:order) || options.delete(:sort) )
s = Tire::Search::Search.new(options.delete(:index), options)
s.size( options[:per_page].to_i ) if options[:per_page]
@@ -300,7 +300,6 @@ def #{method}(*args, &block) # def to_indexed_json(*arg
Results::Item.send :include, Loader
end
-
end
end
View
6 test/unit/model_persistence_test.rb
@@ -24,16 +24,16 @@ class PersistenceTest < Test::Unit::TestCase
setup do
Model::Search.index_prefix 'prefix'
end
-
+
teardown do
Model::Search.index_prefix nil
end
-
+
should "have configured prefix in index_name" do
assert_equal 'prefix_persistent_articles', PersistentArticle.index_name
assert_equal 'prefix_persistent_articles', PersistentArticle.new(:title => 'Test').index_name
end
-
+
end
should "have document_type" do
View
10 test/unit/model_search_test.rb
@@ -121,6 +121,16 @@ class SearchTest < Test::Unit::TestCase
assert_equal 'Article', document.title
end
+ should "not pass the search option as URL parameter" do
+ Configuration.client.
+ expects(:get).with do |url, payload|
+ assert ! url.include?('sort')
+ end.
+ returns( mock_response({ 'hits' => { 'hits' => [] } }.to_json) )
+
+ ActiveModelArticle.search(@q, :sort => 'title DESC').results
+ end
+
context "searching with a block" do
setup do
Tire::Search::Search.any_instance.expects(:perform).returns(@stub)
Please sign in to comment.
Something went wrong with that request. Please try again.