diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..8a9c610 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +rvm: + - 1.8.7 + - 1.9.2 + - ree + - rbx + - rbx-2.0 + - ruby-head \ No newline at end of file diff --git a/Gemfile b/Gemfile index 71ed672..d036dcc 100644 --- a/Gemfile +++ b/Gemfile @@ -1,14 +1,39 @@ source "http://rubygems.org" gemspec -if ENV['RAILS_VERSION'] == 'release' - gem 'activesupport' - gem 'activerecord' - gem 'actionpack' +gem 'rake' + +rails = ENV['RAILS'] || 'master' +arel = ENV['AREL'] || 'master' + +arel_opts = case arel +when /\// # A path + {:path => arel} +when /^v/ # A tagged version + {:git => 'git://github.com/rails/arel.git', :tag => arel} else - gem 'arel', :git => 'git://github.com/rails/arel.git' - git 'git://github.com/rails/rails.git' do + {:git => 'git://github.com/rails/arel.git', :branch => arel} +end + +gem 'arel', arel_opts + +case rails +when /\// # A path + gem 'activesupport', :path => "#{rails}/activesupport" + gem 'activemodel', :path => "#{rails}/activemodel" + gem 'activerecord', :path => "#{rails}/activerecord" + gem 'actionpack', :path => "#{rails}/activerecord" +when /^v/ # A tagged version + git 'git://github.com/rails/rails.git', :tag => rails do gem 'activesupport' + gem 'activemodel' + gem 'activerecord' + gem 'actionpack' + end +else + git 'git://github.com/rails/rails.git', :branch => rails do + gem 'activesupport' + gem 'activemodel' gem 'activerecord' gem 'actionpack' end diff --git a/spec/ransack/configuration_spec.rb b/spec/ransack/configuration_spec.rb index d15bfbf..fd7d49b 100644 --- a/spec/ransack/configuration_spec.rb +++ b/spec/ransack/configuration_spec.rb @@ -7,5 +7,25 @@ module Ransack config.should eq Ransack end end + + 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 end end \ No newline at end of file