Commit a04dfa0574d6f6d3306658470ce146ef1fe2de32

Authored by Tom Cocca
2 parents feadb8f2 b234ea9e
Exists in master

Merge pull request #41 from MaximSt/bug/fix-where-scope-option

Use AR #where instead of #order in #apply_options_to_scope for option wi...
lib/acts_as_follower/follower_lib.rb
@@ -22,7 +22,7 @@ module ActsAsFollower @@ -22,7 +22,7 @@ module ActsAsFollower
22 scope = scope.joins(options[:joins]) 22 scope = scope.joins(options[:joins])
23 end 23 end
24 if options.has_key?(:where) 24 if options.has_key?(:where)
25 - scope = scope.order(options[:where]) 25 + scope = scope.where(options[:where])
26 end 26 end
27 if options.has_key?(:order) 27 if options.has_key?(:order)
28 scope = scope.order(options[:order]) 28 scope = scope.order(options[:order])
test/acts_as_follower_test.rb
@@ -134,9 +134,13 @@ class ActsAsFollowerTest < ActiveSupport::TestCase @@ -134,9 +134,13 @@ class ActsAsFollowerTest < ActiveSupport::TestCase
134 assert_equal [], @jon.all_following 134 assert_equal [], @jon.all_following
135 end 135 end
136 136
137 - should "accept AR options" do 137 + should "accept AR limit option" do
138 assert_equal 1, @sam.all_following(:limit => 1).count 138 assert_equal 1, @sam.all_following(:limit => 1).count
139 end 139 end
  140 +
  141 + should "accept AR where option" do
  142 + assert_equal 1, @sam.all_following(:where => { :id => @oasis.id }).count
  143 + end
140 end 144 end
141 145
142 context "following_by_type" do 146 context "following_by_type" do