Sha256: e93855407d02f428f128bb07b6872e6bea65314c31467849e66beaf26aca5f6e

Contents?: true

Size: 845 Bytes

Versions: 38

Compression:

Stored size: 845 Bytes

Contents

require File.expand_path('../abstract_unit', __FILE__)

class TestPolymorphic < ActiveSupport::TestCase
  fixtures :users, :employees, :comments, :hacks, :articles, :readings

  def test_polymorphic_has_many
    comments = Hack.find(7).comments
    assert_equal 7, comments[0].person_id
  end

  def test_polymorphic_has_one
    first_comment = Hack.find(7).first_comment
    assert_equal 7, first_comment.person_id
  end

  def test_has_many_through
    assert_equal(2, Article.count, 'Baseline sanity check')
    user = users(:santiago)
    article_names = user.articles.collect { |a| a.name }.sort
    assert_equal ['Article One', 'Article Two'], article_names
  end

  def test_polymorphic_has_many_through
    user = users(:santiago)
    assert_equal(['andrew'], user.hacks.collect { |a| a.name }.sort)
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
composite_primary_keys-12.0.2 test/test_polymorphic.rb
composite_primary_keys-11.3.1 test/test_polymorphic.rb
composite_primary_keys-12.0.1 test/test_polymorphic.rb
composite_primary_keys-12.0.0 test/test_polymorphic.rb
composite_primary_keys-12.0.0.rc5 test/test_polymorphic.rb
composite_primary_keys-12.0.0.rc4 test/test_polymorphic.rb
composite_primary_keys-12.0.0.rc3 test/test_polymorphic.rb
composite_primary_keys-12.0.0.rc2 test/test_polymorphic.rb
composite_primary_keys-12.0.0.rc1 test/test_polymorphic.rb
composite_primary_keys-11.2.0 test/test_polymorphic.rb
composite_primary_keys-11.1.0 test/test_polymorphic.rb
composite_primary_keys-11.0.3 test/test_polymorphic.rb
composite_primary_keys-11.0.2 test/test_polymorphic.rb
composite_primary_keys-10.0.5 test/test_polymorphic.rb
composite_primary_keys-9.0.10 test/test_polymorphic.rb
composite_primary_keys-11.0.1 test/test_polymorphic.rb
composite_primary_keys-11.0.0 test/test_polymorphic.rb
composite_primary_keys-10.0.4 test/test_polymorphic.rb
composite_primary_keys-9.0.9 test/test_polymorphic.rb
composite_primary_keys-10.0.3 test/test_polymorphic.rb