Skip to content

Commit 629bc4d

Browse files
Amol Udagejrasanen
Amol Udage
authored andcommitted
follower should not be able to block himself
issue tcocca#57
1 parent c376bfa commit 629bc4d

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lib/acts_as_follower/followable.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ def followed_by?(follower)
8686
end
8787

8888
def block(follower)
89+
return if follower == self
8990
get_follow_for(follower) ? block_existing_follow(follower) : block_future_follow(follower)
9091
end
9192

test/acts_as_followable_test.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,16 @@ class ActsAsFollowableTest < ActiveSupport::TestCase
131131
end
132132

133133
context "blocking a follower" do
134+
context "self blocking" do
135+
setup do
136+
@jon.block(@jon)
137+
end
138+
139+
should "not be able to block" do
140+
assert_equal 0, @jon.blocked_followers_count
141+
end
142+
end
143+
134144
context "in my following list" do
135145
setup do
136146
@jon.block(@sam)

0 commit comments

Comments
 (0)