Get specs passing in 1.8.7

This commit is contained in:
Ernie Miller 2011-07-18 09:51:28 -04:00
parent 74ff6c7930
commit ce0b0a7d22
2 changed files with 7 additions and 2 deletions

View File

@ -95,7 +95,7 @@ module Ransack
end
def unpolymorphize_association(str)
if (match = str.match(/_of_(.+?)_type$/)) && Kernel.const_defined?(match.captures.first)
if (match = str.match(/_of_(.+?)_type$/))
[match.pre_match, Kernel.const_get(match.captures.first)]
else
[str, nil]

View File

@ -126,7 +126,12 @@ module Ransack
)
search.result.should be_an ActiveRecord::Relation
where = search.result.where_values.first
where.to_sql.should match /\("people"."name" = 'Ernie' OR "children_people"."name" = 'Ernie'\) AND \("people"."name" = 'Bert' OR "children_people"."name" = 'Bert'\)/
sql = where.to_sql
first, second = sql.split(/ AND /)
first.should match /"people"."name" = 'Ernie'/
first.should match /"children_people"."name" = 'Ernie'/
second.should match /"people"."name" = 'Bert'/
second.should match /"children_people"."name" = 'Bert'/
end
it 'returns distinct records when passed :distinct => true' do