]> git.openstreetmap.org Git - rails.git/blob - vendor/gems/composite_primary_keys-2.2.2/test/test_polymorphic.rb
Allow the format to be selected for note API responses
[rails.git] / vendor / gems / composite_primary_keys-2.2.2 / test / test_polymorphic.rb
1 require 'abstract_unit'
2 require 'fixtures/comment'
3 require 'fixtures/user'
4 require 'fixtures/employee'
5 require 'fixtures/hack'
6
7 class TestPolymorphic < Test::Unit::TestCase
8   fixtures :users, :employees, :comments, :hacks
9   
10   def test_polymorphic_has_many
11     comments = Hack.find('andrew').comments
12     assert_equal 'andrew', comments[0].person_id
13   end
14   
15   def test_polymorphic_has_one
16     first_comment = Hack.find('andrew').first_comment
17     assert_equal 'andrew', first_comment.person_id
18   end
19   
20   def test_has_many_through
21     user = users(:santiago)
22     article_names = user.articles.collect { |a| a.name }.sort
23     assert_equal ['Article One', 'Article Two'], article_names
24   end
25   
26   def test_polymorphic_has_many_through
27     user = users(:santiago)
28     assert_equal ['andrew'], user.hacks.collect { |a| a.name }.sort
29   end
30
31 end