require 'abstract_unit' class InvisibleModelAssocTest < Test::Unit::TestCase fixtures :fun_users, :groups, :group_memberships def setup @group = groups(:first) @user = fun_users(:first) @membership = group_memberships(:first_first) end def test_has_some assert_equal @membership, @user.group_membership assert_equal [@membership], @user.group_memberships assert_equal @membership, @group.group_membership assert_equal [@membership], @group.group_memberships end def test_belongs_to assert_equal @user, @membership.fun_user assert_equal @group, @membership.group GroupTag.find(:all, :conditions => ['group_id = ?', @group.id]).each do |group_tag| assert_equal @group, group_tag.group end end def test_indirect assert_equal [@user], @group.fun_users assert_equal [@group], @user.groups end # TODO - Support these #def test_more_indirect # group_tags = GroupTag.find(:all, :conditions => ['group_id = ?', @group.id]) # assert_equal group_tags, @user.group_tags #end #def test_more_indirect_via_belongs_to # @group_tag = group_tag(:first) # assert_equal [@user], @group_tag.fun_users #end end