Permalink
Browse files

Merge pull request #8 from listrophy/master

Use block form of create to work across AR versions.
  • Loading branch information...
2 parents 205af83 + 46d5da4 commit 2b2617061120817976b9fcacd6e997d6d5b3a9cc @cmer committed Apr 17, 2012
View
@@ -8,4 +8,5 @@ memory
Gemfile.lock
log
doc
-.yardoc
+.yardoc
+gemfiles
@@ -1,6 +0,0 @@
-# This file was generated by Appraisal
-
-source "http://rubygems.org"
-
-gem "activerecord", "~> 3.0.10"
-
@@ -1,23 +0,0 @@
-GEM
- remote: http://rubygems.org/
- specs:
- activemodel (3.0.11)
- activesupport (= 3.0.11)
- builder (~> 2.1.2)
- i18n (~> 0.5.0)
- activerecord (3.0.11)
- activemodel (= 3.0.11)
- activesupport (= 3.0.11)
- arel (~> 2.0.10)
- tzinfo (~> 0.3.23)
- activesupport (3.0.11)
- arel (2.0.10)
- builder (2.1.2)
- i18n (0.5.0)
- tzinfo (0.3.31)
-
-PLATFORMS
- ruby
-
-DEPENDENCIES
- activerecord (~> 3.0.10)
@@ -1,6 +0,0 @@
-# This file was generated by Appraisal
-
-source "http://rubygems.org"
-
-gem "activerecord", "~> 3.1.1"
-
@@ -1,25 +0,0 @@
-GEM
- remote: http://rubygems.org/
- specs:
- activemodel (3.1.3)
- activesupport (= 3.1.3)
- builder (~> 3.0.0)
- i18n (~> 0.6)
- activerecord (3.1.3)
- activemodel (= 3.1.3)
- activesupport (= 3.1.3)
- arel (~> 2.2.1)
- tzinfo (~> 0.3.29)
- activesupport (3.1.3)
- multi_json (~> 1.0)
- arel (2.2.2)
- builder (3.0.0)
- i18n (0.6.0)
- multi_json (1.1.0)
- tzinfo (0.3.31)
-
-PLATFORMS
- ruby
-
-DEPENDENCIES
- activerecord (~> 3.1.1)
@@ -1,6 +0,0 @@
-# This file was generated by Appraisal
-
-source "http://rubygems.org"
-
-gem "activerecord", "~> 3.2.1"
-
@@ -1,25 +0,0 @@
-GEM
- remote: http://rubygems.org/
- specs:
- activemodel (3.2.1)
- activesupport (= 3.2.1)
- builder (~> 3.0.0)
- activerecord (3.2.1)
- activemodel (= 3.2.1)
- activesupport (= 3.2.1)
- arel (~> 3.0.0)
- tzinfo (~> 0.3.29)
- activesupport (3.2.1)
- i18n (~> 0.6)
- multi_json (~> 1.0)
- arel (3.0.1)
- builder (3.0.0)
- i18n (0.6.0)
- multi_json (1.1.0)
- tzinfo (0.3.31)
-
-PLATFORMS
- ruby
-
-DEPENDENCIES
- activerecord (~> 3.2.1)
@@ -28,7 +28,10 @@ def is_follower?
def follow!(followable)
raise ArgumentError, "#{followable} is not followable!" unless followable.is_followable?
raise ArgumentError, "#{self} cannot follow itself!" unless self != followable
- Follow.create!({ :follower => self, :followable => followable }, :without_protection => true)
+ Follow.create! do |follow|
+ follow.follower = self
+ follow.followable = followable
+ end
end
# Delete a {FollowStore follow} relationship.
@@ -28,7 +28,10 @@ def is_liker?
def like!(likeable)
ensure_likeable!(likeable)
raise ArgumentError, "#{self} cannot like itself!" unless self != likeable
- Like.create!({ :liker => self, :likeable => likeable }, :without_protection => true)
+ Like.create! do |like|
+ like.liker = self
+ like.likeable = likeable
+ end
end
# Delete a {LikeStore like} relationship.
@@ -27,7 +27,10 @@ def is_mentioner?
# @return [MentionStore] the newly created {MentionStore mention} record.
def mention!(mentionable)
ensure_mentionable!(mentionable)
- Mention.create!({ :mentioner => self, :mentionable => mentionable }, :without_protection => true)
+ Mention.create! do |mention|
+ mention.mentioner = self
+ mention.mentionable = mentionable
+ end
end
# Delete a {MentionStore mention} relationship.
View
@@ -129,7 +129,8 @@ class FollowTest < Test::Unit::TestCase
context "acts_as_follow_store" do
should "touch associated record when touch_follower and/or touch_followable are set" do
class Foo < ActiveRecord::Base
- self.table_name = 'follows'; acts_as_follow_store :touch_follower => true, :touch_followable => true
+ self.table_name = 'follows'
+ acts_as_follow_store :touch_follower => true, :touch_followable => true
end
f = Foo.new
assert f.methods.map {|x| x.to_s}.include?('belongs_to_touch_after_save_or_destroy_for_followable')

0 comments on commit 2b26170

Please sign in to comment.