Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Methods blocks and followers from acts_as_followable now accept's AR …

…options
  • Loading branch information...
commit 90bb116faef7e42c18511a7495e1ce72e1626604 1 parent 861d276
@arthurgeek arthurgeek authored
Showing with 31 additions and 4 deletions.
  1. +10 −4 lib/acts_as_followable.rb
  2. +21 −0 test/acts_as_followable_test.rb
View
14 lib/acts_as_followable.rb
@@ -31,12 +31,18 @@ def blocked_followers_count
end
# Returns the following records.
- def followers
- self.followings.unblocked.all(:include => [:follower]).collect{|f| f.follower}
+ def followers(options={})
+ options = {
+ :include => [:follower]
+ }.merge(options)
+ self.followings.unblocked.all(options).collect{|f| f.follower}
end
- def blocks
- self.followings.blocked.all(:include => [:follower]).collect{|f| f.follower}
+ def blocks(options={})
+ options = {
+ :include => [:follower]
+ }.merge(options)
+ self.followings.blocked.all(options).collect{|f| f.follower}
end
# Returns true if the current instance is followed by the passed record
View
21 test/acts_as_followable_test.rb
@@ -26,6 +26,7 @@ class ActsAsFollowableTest < Test::Unit::TestCase
assert_equal 0, @sam.followers_count
assert_equal 1, @jon.followers_count
end
+
should "return the proper number of multiple followers" do
@bob = Factory(:bob)
@sam.follow(@bob)
@@ -40,6 +41,7 @@ class ActsAsFollowableTest < Test::Unit::TestCase
assert_equal [], @sam.followers
assert_equal [@sam], @jon.followers
end
+
should "return users (multiple followers)" do
@bob = Factory(:bob)
@sam.follow(@bob)
@@ -47,6 +49,7 @@ class ActsAsFollowableTest < Test::Unit::TestCase
assert_equal [@sam], @jon.followers
assert_equal [@sam], @bob.followers
end
+
should "return users (multiple followers, complex)" do
@bob = Factory(:bob)
@sam.follow(@bob)
@@ -55,6 +58,12 @@ class ActsAsFollowableTest < Test::Unit::TestCase
assert_equal [@sam], @jon.followers
assert_equal [@sam, @jon], @bob.followers
end
+
+ should "accept AR options" do
+ @bob = Factory(:bob)
+ @bob.follow(@jon)
+ assert_equal 1, @jon.followers(:limit => 1).count
+ end
end
context "followed_by" do
@@ -73,6 +82,18 @@ class ActsAsFollowableTest < Test::Unit::TestCase
should_change("@sam.all_following.size", :by => -1) { @sam.all_following.size }
end
+ context "blocks" do
+ setup do
+ @bob = Factory(:bob)
+ @jon.block(@sam)
+ @jon.block(@bob)
+ end
+
+ should "accept AR options" do
+ assert_equal 1, @jon.blocks(:limit => 1).count
+ end
+ end
+
context "blocking a follower" do
context "in my following list" do
setup do
Please sign in to comment.
Something went wrong with that request. Please try again.