diff --git a/lib/acts_as_follower/followable.rb b/lib/acts_as_follower/followable.rb index 324c78e..34e6d1b 100644 --- a/lib/acts_as_follower/followable.rb +++ b/lib/acts_as_follower/followable.rb @@ -90,6 +90,12 @@ def followed_by?(follower) followings.unblocked.for_follower(follower).first.present? end + # Returns true if the current instance is blocked by the passed record + # Returns false if the current instance is not blocked by the passed record or no follow is found + def restricted?(follower) + followings.blocked.for_follower(follower).first.present? + end + # Returns true if the current instance is blocked by the passed record # Returns false if the current instance is not blocked by the passed record or no follow is found def restricted_by?(follower) diff --git a/lib/acts_as_follower/version.rb b/lib/acts_as_follower/version.rb index 52e465c..f413679 100644 --- a/lib/acts_as_follower/version.rb +++ b/lib/acts_as_follower/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module ActsAsFollower - VERSION = '0.2.3' + VERSION = '0.2.4' end diff --git a/test/acts_as_followable_test.rb b/test/acts_as_followable_test.rb index 45f9588..77e9282 100644 --- a/test/acts_as_followable_test.rb +++ b/test/acts_as_followable_test.rb @@ -13,6 +13,7 @@ class ActsAsFollowableTest < ActiveSupport::TestCase assert @sam.respond_to?(:followers) assert @sam.respond_to?(:followed_by?) assert @sam.respond_to?(:restricted_by?) + assert @sam.respond_to?(:restricted?) end end @@ -79,7 +80,7 @@ class ActsAsFollowableTest < ActiveSupport::TestCase end end - context 'restricted_by' do + context 'restricted_by?' do setup do @jon.restrict(@sam) end @@ -90,6 +91,17 @@ class ActsAsFollowableTest < ActiveSupport::TestCase end end + context 'restricted?' do + setup do + @jon.restrict(@sam) + end + + should 'return_restricted_status' do + assert_equal true, @jon.restricted?(@sam) + assert_equal false, @sam.restricted?(@jon) + end + end + context 'destroying a followable' do setup do @jon.destroy