Skip to content

Commit

Permalink
Use AR #where instead of #order in #apply_options_to_scope for option…
Browse files Browse the repository at this point in the history
… with condition
  • Loading branch information
Maxim Stukalo committed Jun 25, 2014
1 parent feadb8f commit b234ea9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/acts_as_follower/follower_lib.rb
Expand Up @@ -22,7 +22,7 @@ def apply_options_to_scope(scope, options = {})
scope = scope.joins(options[:joins])
end
if options.has_key?(:where)
scope = scope.order(options[:where])
scope = scope.where(options[:where])
end
if options.has_key?(:order)
scope = scope.order(options[:order])
Expand Down
6 changes: 5 additions & 1 deletion test/acts_as_follower_test.rb
Expand Up @@ -134,9 +134,13 @@ class ActsAsFollowerTest < ActiveSupport::TestCase
assert_equal [], @jon.all_following
end

should "accept AR options" do
should "accept AR limit option" do
assert_equal 1, @sam.all_following(:limit => 1).count
end

should "accept AR where option" do
assert_equal 1, @sam.all_following(:where => { :id => @oasis.id }).count
end
end

context "following_by_type" do
Expand Down

0 comments on commit b234ea9

Please sign in to comment.