Sha256: b479f3c37ac2dee06f9c328dfc6475dca856eb41b9b58529d9bb89a0792aa2df
Contents?: true
Size: 1.11 KB
Versions: 9
Compression:
Stored size: 1.11 KB
Contents
require File.expand_path('../abstract_unit', __FILE__) class TestPolymorphic < ActiveSupport::TestCase fixtures :articles, :departments, :employees, :users, :comments def test_has_many user = users(:santiago) comments = user.comments assert_equal(user.id, comments[0].person_id) end def test_has_one user = users(:santiago) first_comment = user.first_comment assert_equal(user.id, first_comment.person_id) end def test_has_many_through department = departments(:accounting) comment = comments(:employee_comment) assert_equal(1, department.comments.size) assert_equal(comment, department.comments[0]) end def test_has_many_through_2 article = articles(:second) user = users(:santiago) assert_equal(user, article.user_commentators[0]) user = users(:drnic) assert_equal(user, article.user_commentators[1]) end def test_clear_has_many_through article = articles(:second) assert_equal(2, article.comments.size) article.user_commentators = [] assert_equal(0, article.comments.size) end end
Version data entries
9 entries across 9 versions & 1 rubygems