2011-03-31 00:31:39 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
module Ransack
|
|
|
|
describe Configuration do
|
2011-06-04 22:01:12 +00:00
|
|
|
it 'yields Ransack on configure' do
|
|
|
|
Ransack.configure do |config|
|
|
|
|
config.should eq Ransack
|
2011-03-31 00:31:39 +00:00
|
|
|
end
|
|
|
|
end
|
2011-07-17 23:04:00 +00:00
|
|
|
|
|
|
|
it 'adds predicates' do
|
|
|
|
Ransack.configure do |config|
|
|
|
|
config.add_predicate :test_predicate
|
|
|
|
end
|
|
|
|
|
|
|
|
Ransack.predicates.should have_key 'test_predicate'
|
|
|
|
Ransack.predicates.should have_key 'test_predicate_any'
|
|
|
|
Ransack.predicates.should have_key 'test_predicate_all'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'avoids creating compound predicates if :compounds => false' do
|
|
|
|
Ransack.configure do |config|
|
|
|
|
config.add_predicate :test_predicate_without_compound, :compounds => false
|
|
|
|
end
|
|
|
|
|
|
|
|
Ransack.predicates.should have_key 'test_predicate_without_compound'
|
|
|
|
Ransack.predicates.should_not have_key 'test_predicate_without_compound_any'
|
|
|
|
Ransack.predicates.should_not have_key 'test_predicate_without_compound_all'
|
|
|
|
end
|
2011-03-31 00:31:39 +00:00
|
|
|
end
|
|
|
|
end
|