Commit b234ea9e1ed6f8c4e25849b3420f6584b5ae43b3
1 parent
feadb8f2
Exists in
master
Use AR #where instead of #order in #apply_options_to_scope for option with condition
Showing
2 changed files
with
6 additions
and
2 deletions
Show diff stats
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 |