mirror of
https://github.com/activerecord-hackery/ransack.git
synced 2022-11-09 13:47:45 -05:00
Uncomment TODO boolean conversion scope tests
This commit is contained in:
parent
7dcfbf38a5
commit
92e5f31ee3
1 changed files with 20 additions and 14 deletions
|
@ -65,25 +65,31 @@ module Ransack
|
|||
expect(s.result.to_sql).to (include 'age > 18')
|
||||
end
|
||||
|
||||
# TODO: Implement a way to pass true/false values like 0 or 1 to
|
||||
# scopes (e.g. with `in` / `not_in` predicates), without Ransack
|
||||
# converting them to true/false boolean values instead.
|
||||
|
||||
# it 'passes true values to scopes', focus: true do
|
||||
# s = Person.ransack('over_age' => 1)
|
||||
# expect(s.result.to_sql).to (include 'age > 1')
|
||||
# end
|
||||
|
||||
# it 'passes false values to scopes', focus: true do
|
||||
# s = Person.ransack('over_age' => 0)
|
||||
# expect(s.result.to_sql).to (include 'age > 0')
|
||||
# end
|
||||
|
||||
it 'chains scopes' do
|
||||
s = Person.ransack('over_age' => 18, 'active' => true)
|
||||
expect(s.result.to_sql).to (include 'age > 18')
|
||||
expect(s.result.to_sql).to (include 'active = 1')
|
||||
end
|
||||
|
||||
context "with sanitize_custom_scope_booleans set to false" do
|
||||
before(:all) do
|
||||
Ransack.configure { |c| c.sanitize_custom_scope_booleans = false }
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
Ransack.configure { |c| c.sanitize_custom_scope_booleans = true }
|
||||
end
|
||||
|
||||
it 'passes true values to scopes' do
|
||||
s = Person.ransack('over_age' => 1)
|
||||
expect(s.result.to_sql).to (include 'age > 1')
|
||||
end
|
||||
|
||||
it 'passes false values to scopes' do
|
||||
s = Person.ransack('over_age' => 0)
|
||||
expect(s.result.to_sql).to (include 'age > 0')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it 'does not raise exception for string :params argument' do
|
||||
|
|
Loading…
Reference in a new issue