activerecord_finder 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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
- arel = Arel::Nodes::And.new([*scoped_where, finder.arel])
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord_finder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: