Skip to content

Commit

Permalink
fix the bug Followable#respond_to? and Follower#respond_to? actually …
Browse files Browse the repository at this point in the history
…return nil when called with a nonexistent method.
  • Loading branch information
bealking committed Mar 23, 2015
1 parent a04dfa0 commit 8296168
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/acts_as_follower/followable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def method_missing(m, *args)
end

def respond_to?(m, include_private = false)
super || m.to_s[/count_(.+)_followers/] || m.to_s[/(.+)_followers/]
super || !!m.to_s[/count_(.+)_followers/] || !!m.to_s[/(.+)_followers/]
end

def blocked_followers_count
Expand Down
2 changes: 1 addition & 1 deletion lib/acts_as_follower/follower.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def method_missing(m, *args)
end

def respond_to?(m, include_private = false)
super || m.to_s[/following_(.+)_count/] || m.to_s[/following_(.+)/]
super || !!m.to_s[/following_(.+)_count/] || !!m.to_s[/following_(.+)/]
end

# Returns a follow record for the current instance and followable object.
Expand Down
2 changes: 1 addition & 1 deletion test/acts_as_followable_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ class ActsAsFollowableTest < ActiveSupport::TestCase
end

should "return false when called with a nonexistent method" do
assert (not @oasis.respond_to?(:foobar))
assert (@oasis.respond_to?(:foobar) == false)
end
end

Expand Down
2 changes: 1 addition & 1 deletion test/acts_as_follower_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class ActsAsFollowerTest < ActiveSupport::TestCase
end

should "return false when called with a nonexistent method" do
assert (not @sam.respond_to?(:foobar))
assert (@sam.respond_to?(:foobar) == false)
end
end

Expand Down

0 comments on commit 8296168

Please sign in to comment.