Commit a1e766d2a6fc621000165966306caa7c34cdd6aa
1 parent
fb2daa76
Exists in
staging
and in
42 other branches
ActionItem751: remove the 10 results limit in find_by_contents
Showing
4 changed files
with
35 additions
and
0 deletions
Show diff stats
lib/acts_as_searchable.rb
| ... | ... | @@ -9,6 +9,8 @@ class << ActiveRecord::Base |
| 9 | 9 | if ferret_options[:per_page] |
| 10 | 10 | db_options[:per_page] = ferret_options.delete(:per_page) |
| 11 | 11 | end |
| 12 | + | |
| 13 | + ferret_options[:limit] = :all | |
| 12 | 14 | |
| 13 | 15 | ids = find_ids_with_ferret(query, ferret_options)[1].map{|r|r[:id].to_i} |
| 14 | 16 | if ids.empty? | ... | ... |
test/functional/search_controller_test.rb
| ... | ... | @@ -946,6 +946,17 @@ class SearchControllerTest < Test::Unit::TestCase |
| 946 | 946 | assert_tag :tag => 'h1', :content => 'Communities' |
| 947 | 947 | end |
| 948 | 948 | |
| 949 | + should 'indicate more than page for total_entries' do | |
| 950 | + Enterprise.destroy_all | |
| 951 | + ('1'..'20').each do |n| | |
| 952 | + Enterprise.create!(:name => 'test ' + n, :identifier => 'test_' + n) | |
| 953 | + end | |
| 954 | + | |
| 955 | + get :index, :query => 'test' | |
| 956 | + | |
| 957 | + assert_equal 20, assigns(:results)[:enterprises].total_entries | |
| 958 | + end | |
| 959 | + | |
| 949 | 960 | ################################################################## |
| 950 | 961 | ################################################################## |
| 951 | 962 | ... | ... |
test/unit/environment_finder_test.rb
| ... | ... | @@ -311,4 +311,16 @@ class EnvironmentFinderTest < ActiveSupport::TestCase |
| 311 | 311 | assert_equal 2, counts[pc2.id] |
| 312 | 312 | assert_nil counts[pc3.id] |
| 313 | 313 | end |
| 314 | + | |
| 315 | + should 'should retrieve more than 10 entries' do | |
| 316 | + Enterprise.destroy_all | |
| 317 | + finder = EnvironmentFinder.new(Environment.default) | |
| 318 | + | |
| 319 | + ('1'..'20').each do |n| | |
| 320 | + Enterprise.create!(:name => 'test ' + n, :identifier => 'test_' + n) | |
| 321 | + end | |
| 322 | + | |
| 323 | + assert_equal 20, finder.find(:enterprises, 'test').total_entries | |
| 324 | + end | |
| 325 | + | |
| 314 | 326 | end | ... | ... |
test/unit/environment_test.rb
| ... | ... | @@ -434,4 +434,14 @@ class EnvironmentTest < Test::Unit::TestCase |
| 434 | 434 | assert_equal 'default', Environment.new.layout_template |
| 435 | 435 | end |
| 436 | 436 | |
| 437 | + should 'return more than 10 enterprises by contents' do | |
| 438 | + env = Environment.default | |
| 439 | + Enterprise.destroy_all | |
| 440 | + ('1'..'20').each do |n| | |
| 441 | + Enterprise.create!(:name => 'test ' + n, :identifier => 'test_' + n) | |
| 442 | + end | |
| 443 | + | |
| 444 | + assert_equal 20, env.enterprises.find_by_contents('test').total_entries | |
| 445 | + end | |
| 446 | + | |
| 437 | 447 | end | ... | ... |