Sha256: 670ed1b7047e1854189fa71cb9cfad08ac3b4c98aa3b9b22abbec7aad4c01847

Contents?: true

Size: 1.79 KB

Versions: 13

Compression:

Stored size: 1.79 KB

Contents

require 'abstract_unit'
require 'fixtures/post'
require 'fixtures/comment'
require 'fixtures/project'
require 'fixtures/developer'

class AssociationsExtensionsTest < Test::Unit::TestCase
  fixtures :projects, :developers, :developers_projects, :comments, :posts

  def test_extension_on_has_many
    assert_equal comments(:more_greetings), posts(:welcome).comments.find_most_recent
  end
  
  def test_extension_on_habtm
    assert_equal projects(:action_controller), developers(:david).projects.find_most_recent
  end

  def test_named_extension_on_habtm
    assert_equal projects(:action_controller), developers(:david).projects_extended_by_name.find_most_recent
  end

  def test_named_two_extensions_on_habtm
    assert_equal projects(:action_controller), developers(:david).projects_extended_by_name_twice.find_most_recent
    assert_equal projects(:active_record), developers(:david).projects_extended_by_name_twice.find_least_recent
  end

  def test_named_extension_and_block_on_habtm
    assert_equal projects(:action_controller), developers(:david).projects_extended_by_name_and_block.find_most_recent
    assert_equal projects(:active_record), developers(:david).projects_extended_by_name_and_block.find_least_recent
  end

  def test_marshalling_extensions
    david = developers(:david)
    assert_equal projects(:action_controller), david.projects.find_most_recent

    david = Marshal.load(Marshal.dump(david))
    assert_equal projects(:action_controller), david.projects.find_most_recent
  end

  def test_marshalling_named_extensions
    david = developers(:david)
    assert_equal projects(:action_controller), david.projects_extended_by_name.find_most_recent

    david = Marshal.load(Marshal.dump(david))
    assert_equal projects(:action_controller), david.projects_extended_by_name.find_most_recent
  end
end

Version data entries

13 entries across 13 versions & 3 rubygems

Version Path
activerecord-2.0.2 test/associations/extension_test.rb
activerecord-2.0.5 test/associations/extension_test.rb
activerecord-2.0.1 test/associations/extension_test.rb
activerecord-2.0.4 test/associations/extension_test.rb
activerecord-2.0.0 test/associations/extension_test.rb
radiant-0.6.5.1 vendor/rails/activerecord/test/associations/extension_test.rb
radiant-0.6.5 vendor/rails/activerecord/test/associations/extension_test.rb
radiant-0.6.7 vendor/rails/activerecord/test/associations/extension_test.rb
radiant-0.6.6 vendor/rails/activerecord/test/associations/extension_test.rb
radiant-0.6.8 vendor/rails/activerecord/test/associations/extension_test.rb
radiant-0.6.9 vendor/rails/activerecord/test/associations/extension_test.rb
spree-0.0.9 vendor/rails/activerecord/test/associations/extension_test.rb
spree-0.2.0 vendor/rails/activerecord/test/associations/extension_test.rb