activerecord_finder 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -11,9 +11,12 @@ module ActiveRecordFinder
|
|
11
11
|
alias :condition :restrict
|
12
12
|
|
13
13
|
def new_finder(&block)
|
14
|
-
finder = create_finder(&block)
|
15
14
|
scoped_where = scoped.arel.where_clauses.map { |w| Arel.sql(w) }
|
16
|
-
|
15
|
+
if block
|
16
|
+
finder = create_finder(&block)
|
17
|
+
scoped_where << finder.arel
|
18
|
+
end
|
19
|
+
arel = Arel::Nodes::And.new(scoped_where)
|
17
20
|
ActiveRecordFinder::Finder.new(arel_table, arel)
|
18
21
|
end
|
19
22
|
|
@@ -33,4 +33,10 @@ describe ActiveRecordFinder::Where do
|
|
33
33
|
result = Person.restrict(new_finder)
|
34
34
|
result.should == [boo]
|
35
35
|
end
|
36
|
+
|
37
|
+
it 'creates a new finder without a block, using only current scope' do
|
38
|
+
person = Person.where(age: 17).where('name LIKE ?', 'B%')
|
39
|
+
new_finder = person.new_finder
|
40
|
+
Person.restrict(new_finder).should == [bar]
|
41
|
+
end
|
36
42
|
end
|