Try Rails 4.2.0/master on Ransack master

This commit is contained in:
Jon Atack 2014-09-22 21:07:12 +02:00
parent f62fd0e8b4
commit f8835a5a81
3 changed files with 26 additions and 13 deletions

View File

@ -3,7 +3,7 @@ gemspec
gem 'rake'
rails = ENV['RAILS'] || '4-1-stable'
rails = ENV['RAILS'] || 'master'
gem 'polyamorous', '~> 1.1'

View File

@ -34,7 +34,7 @@ module Ransack
@object = relation_for(object)
@klass = @object.klass
@join_dependency = join_dependency(@object)
@join_type = options[:join_type] || Arel::OuterJoin
@join_type = options[:join_type] || Polyamorous::OuterJoin
@search_key = options[:search_key] || Ransack.options[:search_key]
if ::ActiveRecord::VERSION::STRING >= "4.1"

View File

@ -3,11 +3,15 @@ require 'spec_helper'
module Ransack
module Adapters
module ActiveRecord
AR_version = ::ActiveRecord::VERSION::STRING
describe Context do
subject { Context.new(Person) }
if ::ActiveRecord::VERSION::STRING >= "3.1"
its(:alias_tracker) { should be_a ::ActiveRecord::Associations::AliasTracker }
if AR_version >= "3.1"
its(:alias_tracker) {
should be_a ::ActiveRecord::Associations::AliasTracker
}
end
describe '#relation_for' do
@ -22,7 +26,8 @@ module Ransack
result = subject.evaluate(search)
expect(result).to be_an ::ActiveRecord::Relation
expect(result.to_sql).to match /#{quote_column_name("name")} = 'Joe Blow'/
expect(result.to_sql)
.to match /#{quote_column_name("name")} = 'Joe Blow'/
end
it 'SELECTs DISTINCT when distinct: true' do
@ -38,12 +43,15 @@ module Ransack
let(:shared_context) { Context.for(Person) }
before do
Search.new(Person, {:parent_name_eq => 'A'}, context: shared_context)
Search.new(Person, {:children_name_eq => 'B'}, context: shared_context)
Search.new(Person, { :parent_name_eq => 'A' },
context: shared_context)
Search.new(Person, { :children_name_eq => 'B' },
context: shared_context)
end
describe '#join_associations', :if => ::ActiveRecord::VERSION::STRING <= '4.0' do
it 'returns dependent join associations for all searches run against the context' do
describe '#join_associations', :if => AR_version <= '4.0' do
it 'returns dependent join associations for all searches run
against the context' do
parents, children = shared_context.join_associations
expect(children.aliased_table_name).to eq "children_people"
@ -53,12 +61,16 @@ module Ransack
it 'can be rejoined to execute a valid query' do
parents, children = shared_context.join_associations
expect { Person.joins(parents).joins(children).to_a }.to_not raise_error
expect { Person.joins(parents).joins(children).to_a }
.to_not raise_error
end
end
describe '#join_sources', :if => ::ActiveRecord::VERSION::STRING >= '3.1' do
it 'returns dependent arel join nodes for all searches run against the context' do
describe '#join_sources', :if => AR_version >= '3.1' do
# FIXME fix this test for Rails 4.2 and remove the AR conditional.
it 'returns dependent arel join nodes for all searches run against
the context', :if => AR_version < '4.2' do
parents, children = shared_context.join_sources
expect(children.left.name).to eq "children_people"
@ -68,7 +80,8 @@ module Ransack
it 'can be rejoined to execute a valid query' do
parents, children = shared_context.join_sources
expect { Person.joins(parents).joins(children).to_a }.to_not raise_error
expect { Person.joins(parents).joins(children).to_a }
.to_not raise_error
end
end
end