Model.search("") should not raise exception
Consider query like: "users?q=some-string" or "users?q=" and controller content User.search(params[:q]) PR by @Bonias
This commit is contained in:
parent
eb5879f4ee
commit
3254bb2bae
|
@ -14,7 +14,8 @@ module Ransack
|
|||
:translate, to: :base
|
||||
|
||||
def initialize(object, params = {}, options = {})
|
||||
(params ||= {}).delete_if { |k, v| v.blank? && v != false }
|
||||
params = {} unless params.is_a?(Hash)
|
||||
params.delete_if { |k, v| v.blank? && v != false }
|
||||
@context = Context.for(object, options)
|
||||
@context.auth_object = options[:auth_object]
|
||||
@base = Nodes::Grouping.new(@context, 'and')
|
||||
|
|
|
@ -3,6 +3,12 @@ require 'spec_helper'
|
|||
module Ransack
|
||||
describe Search do
|
||||
|
||||
describe '#initialize' do
|
||||
it 'do not raise exception for string :params argument' do
|
||||
lambda { Search.new(Person, '') }.should_not raise_error
|
||||
end
|
||||
end
|
||||
|
||||
describe '#build' do
|
||||
it 'creates Conditions for top-level attributes' do
|
||||
search = Search.new(Person, name_eq: 'Ernie')
|
||||
|
|
Loading…
Reference in New Issue