Skip to content

Commit

Permalink
follower should not be able to block himself
Browse files Browse the repository at this point in the history
issue tcocca#57
  • Loading branch information
Amol Udage authored and jrasanen committed Mar 18, 2016
1 parent c376bfa commit 629bc4d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/acts_as_follower/followable.rb
Expand Up @@ -86,6 +86,7 @@ def followed_by?(follower)
end

def block(follower)
return if follower == self
get_follow_for(follower) ? block_existing_follow(follower) : block_future_follow(follower)
end

Expand Down
10 changes: 10 additions & 0 deletions test/acts_as_followable_test.rb
Expand Up @@ -131,6 +131,16 @@ class ActsAsFollowableTest < ActiveSupport::TestCase
end

context "blocking a follower" do
context "self blocking" do
setup do
@jon.block(@jon)
end

should "not be able to block" do
assert_equal 0, @jon.blocked_followers_count
end
end

context "in my following list" do
setup do
@jon.block(@sam)
Expand Down

0 comments on commit 629bc4d

Please sign in to comment.