Permalink
Browse files

Added tests for inherited models

  • Loading branch information...
1 parent 9d2a164 commit 6deb6733e5a411f868f06febc1b7497d0ee38ca5 @cmer committed Mar 1, 2012
Showing with 44 additions and 14 deletions.
  1. +19 −0 test/follow_test.rb
  2. +10 −3 test/like_test.rb
  3. +9 −2 test/mention_test.rb
  4. +6 −9 test/test_helper.rb
View
@@ -137,6 +137,25 @@ class Foo < ActiveRecord::Base
end
end
+ context "Inherited models" do
+ setup do
+ @follower = ImAFollower.create
+ @followable = ImAFollowable.create
+ @follower_child = ImAFollowerChild.create
+ @followable_child = ImAFollowableChild.create
+ end
+
+ should "be able to follow a model inheriting from followable" do
+ assert @follower.follow!(@followable_child)
+ assert_true @follower.follows?(@followable_child)
+ end
+
+ should "be able to be followed by a model inheriting from follower" do
+ assert @follower_child.follow!(@followable)
+ assert_true @follower_child.follows?(@followable)
+ end
+ end
+
def seed
@follower1 = ImAFollower.create
@follower2 = ImAFollower.create
View
@@ -137,15 +137,22 @@ class Foo < ActiveRecord::Base
end
end
- context "Single Table Inheritance" do
+ context "Inherited models" do
setup do
- @liker = ImALiker.create
+ @liker = ImALiker.create
+ @likeable = ImALikeable.create
+ @liker_child = ImALikerChild.create
@likeable_child = ImALikeableChild.create
end
should "be able to like a model inheriting from a Likeable" do
assert @liker.like!(@likeable_child)
- assert_true @liker.likes?(@likeable_child)
+ assert_true @liker.likes?(@likeable_child)
+ end
+
+ should "be able to be liked by a model inheriting from liker" do
+ assert @liker_child.like!(@likeable)
+ assert_true @liker_child.likes?(@likeable)
end
end
View
@@ -143,13 +143,20 @@ class Foo < ActiveRecord::Base
context "Single Table Inheritance" do
setup do
- @mentioner = ImAMentioner.create
+ @mentioner = ImAMentioner.create
+ @mentioner_child = ImAMentionerChild.create
+ @mentionable = ImAMentionable.create
@mentionable_child = ImAMentionableChild.create
end
should "be able to mention a model inheriting from mentionable" do
assert @mentioner.mention!(@mentionable_child)
- assert_true @mentioner.mentions?(@mentionable_child)
+ assert_true @mentioner.mentions?(@mentionable_child)
+ end
+
+ should "be able to be mentioned by a model inheriting from mentioner" do
+ assert @mentioner_child.mention!(@mentionable)
+ assert_true @mentioner_child.mentions?(@mentionable)
end
end
View
@@ -141,35 +141,32 @@ class Mention < ActiveRecord::Base
class ImAFollower < ActiveRecord::Base
acts_as_follower
end
+class ImAFollowerChild < ImAFollower; end
class ImAFollowable < ActiveRecord::Base
acts_as_followable
end
-
-class ImAFollowableChild < ImAFollowable
-end
+class ImAFollowableChild < ImAFollowable; end
class ImALiker < ActiveRecord::Base
acts_as_liker
end
+class ImALikerChild < ImALiker; end
class ImALikeable < ActiveRecord::Base
acts_as_likeable
end
-
-class ImALikeableChild < ImALikeable
-end
+class ImALikeableChild < ImALikeable; end
class ImAMentioner < ActiveRecord::Base
acts_as_mentioner
end
+class ImAMentionerChild < ImAMentioner; end
class ImAMentionable < ActiveRecord::Base
acts_as_mentionable
end
-
-class ImAMentionableChild < ImAMentionable
-end
+class ImAMentionableChild < ImAMentionable; end
class ImAMentionerAndMentionable < ActiveRecord::Base
acts_as_mentioner

0 comments on commit 6deb673

Please sign in to comment.