Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

expose get_follow_for on followable through the public api, get_follo…

…w was already exposed in follower, this standardizes what can be accessed through each module
  • Loading branch information...
commit 7ba0a8d7409170f98dbeb07984f36cd4a0d38b43 1 parent 2f6857d
@tcocca authored
View
4 Rakefile
@@ -25,7 +25,6 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
end
namespace :rcov do
-
desc "Generate a coverage report in coverage/"
task :gen do
sh "rcov --output coverage test/*_test.rb --exclude 'gems/*'"
@@ -35,5 +34,4 @@ namespace :rcov do
task :clobber do
sh "rm -rdf coverage"
end
-
-end
+end
View
13 lib/acts_as_follower/followable.rb
@@ -24,11 +24,10 @@ def followers_count
def followers_by_type(follower_type, options={})
follows = follower_type.constantize.
includes(:follows).
- where('blocked = ?', false).
- where(
- "follows.followable_id = ? AND follows.followable_type = ? AND follows.follower_type = ?",
- self.id, parent_class_name(self), follower_type
- )
+ where('follows.blocked' => false,
+ 'follows.followable_id' => self.id,
+ 'follows.followable_type' => parent_class_name(self),
+ 'follows.follower_type' => follower_type)
if options.has_key?(:limit)
follows = follows.limit(options[:limit])
end
@@ -80,12 +79,12 @@ def unblock(follower)
get_follow_for(follower).try(:delete)
end
- private
-
def get_follow_for(follower)
self.followings.for_follower(follower).first
end
+ private
+
def block_future_follow(follower)
follows.create(:followable => self, :follower => follower, :blocked => true)
end
View
15 test/acts_as_followable_test.rb
@@ -84,6 +84,21 @@ class ActsAsFollowableTest < ActiveSupport::TestCase
should_change("@sam.all_following.size", :by => -1) { @sam.all_following.size }
end
+ context "get follow record" do
+ setup do
+ @bob = Factory(:bob)
+ @follow = @bob.follow(@sam)
+ end
+
+ should "return follow record" do
+ assert_equal @follow, @sam.get_follow_for(@bob)
+ end
+
+ should "return nil" do
+ assert_nil @sam.get_follow_for(@jon)
+ end
+ end
+
context "blocks" do
setup do
@bob = Factory(:bob)
Please sign in to comment.
Something went wrong with that request. Please try again.