Sha256: a9c2d693d50eee1c7e7bb3174fe1931f1df7dd40637fa0b91452a34e7c856809

Contents?: true

Size: 1.78 KB

Versions: 21

Compression:

Stored size: 1.78 KB

Contents

require "cases/helper"
require 'models/post'
require 'models/comment'
require 'models/project'
require 'models/developer'

class AssociationsExtensionsTest < ActiveRecord::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

21 entries across 21 versions & 6 rubygems

Version Path
3mix-castronaut-0.5.0.2 vendor/activerecord/test/cases/associations/extension_test.rb
masover-castronaut-0.4.4.4 vendor/activerecord/test/cases/associations/extension_test.rb
masover-castronaut-0.4.4.5 vendor/activerecord/test/cases/associations/extension_test.rb
masover-castronaut-0.5.0.1 vendor/activerecord/test/cases/associations/extension_test.rb
relevance-castronaut-0.4.1 vendor/activerecord/test/cases/associations/extension_test.rb
relevance-castronaut-0.4.2 vendor/activerecord/test/cases/associations/extension_test.rb
relevance-castronaut-0.4.3 vendor/activerecord/test/cases/associations/extension_test.rb
relevance-castronaut-0.4.4 vendor/activerecord/test/cases/associations/extension_test.rb
relevance-castronaut-0.4.5 vendor/activerecord/test/cases/associations/extension_test.rb
relevance-castronaut-0.4.6 vendor/activerecord/test/cases/associations/extension_test.rb
relevance-castronaut-0.5.0 vendor/activerecord/test/cases/associations/extension_test.rb
relevance-castronaut-0.5.1 vendor/activerecord/test/cases/associations/extension_test.rb
relevance-castronaut-0.5.2 vendor/activerecord/test/cases/associations/extension_test.rb
relevance-castronaut-0.5.3 vendor/activerecord/test/cases/associations/extension_test.rb
relevance-castronaut-0.5.4 vendor/activerecord/test/cases/associations/extension_test.rb
vibes-bj-1.2.2 spec/rails_root/vendor/rails/activerecord/test/cases/associations/extension_test.rb
vibes-bj-1.2.1 spec/rails_root/vendor/rails/activerecord/test/cases/associations/extension_test.rb
activerecord-2.1.1 test/cases/associations/extension_test.rb
activerecord-2.1.0 test/cases/associations/extension_test.rb
antfarm-0.3.0 rails/vendor/rails/activerecord/test/cases/associations/extension_test.rb