Sha256: 8c0577431409e6f0d79b05d1a32d6f3c86a3ec53b8fd6ce976bdbabf27506a2e

Contents?: true

Size: 994 Bytes

Versions: 20

Compression:

Stored size: 994 Bytes

Contents

require 'cases/helper'
require 'models/post'
require 'models/tagging'

module Namespaced
  class Post < ActiveRecord::Base
    self.table_name = 'posts'
    has_one :tagging, :as => :taggable, :class_name => 'Tagging'
  end
end

class EagerLoadIncludeFullStiClassNamesTest < ActiveRecord::TestCase

  def setup
    generate_test_objects
  end

  def generate_test_objects
    post = Namespaced::Post.create( :title => 'Great stuff', :body => 'This is not', :author_id => 1 )
    Tagging.create( :taggable => post )
  end

  def test_class_names
    old = ActiveRecord::Base.store_full_sti_class

    ActiveRecord::Base.store_full_sti_class = false
    post = Namespaced::Post.includes(:tagging).find_by_title('Great stuff')
    assert_nil post.tagging

    ActiveRecord::Base.store_full_sti_class = true
    post = Namespaced::Post.includes(:tagging).find_by_title('Great stuff')
    assert_instance_of Tagging, post.tagging
  ensure
    ActiveRecord::Base.store_full_sti_class = old
  end
end

Version data entries

20 entries across 20 versions & 3 rubygems

Version Path
ibm_db-5.2.0 test/cases/associations/eager_load_includes_full_sti_class_test.rb
ibm_db-5.1.0 test/cases/associations/eager_load_includes_full_sti_class_test.rb
ibm_db-5.0.5 test/cases/associations/eager_load_includes_full_sti_class_test.rb
ibm_db-5.0.4 test/cases/associations/eager_load_includes_full_sti_class_test.rb
ibm_db-5.0.3 test/cases/associations/eager_load_includes_full_sti_class_test.rb
ibm_db-5.0.2 test/cases/associations/eager_load_includes_full_sti_class_test.rb
ibm_db-4.0.0-x86-mingw32 test/cases/associations/eager_load_includes_full_sti_class_test.rb
ibm_db-4.0.0 test/cases/associations/eager_load_includes_full_sti_class_test.rb
ibm_db-3.0.4-x86-mingw32 test/cases/associations/eager_load_includes_full_sti_class_test.rb
ibm_db-3.0.4 test/cases/associations/eager_load_includes_full_sti_class_test.rb
ibm_db-3.0.3-x86-mingw32 test/cases/associations/eager_load_includes_full_sti_class_test.rb
ibm_db-3.0.3 test/cases/associations/eager_load_includes_full_sti_class_test.rb
ibm_db-3.0.2-x86-mingw32 test/cases/associations/eager_load_includes_full_sti_class_test.rb
ibm_db-3.0.2 test/cases/associations/eager_load_includes_full_sti_class_test.rb
activejob-lock-0.0.2 rails/activerecord/test/cases/associations/eager_load_includes_full_sti_class_test.rb
ibm_db-3.0.1 test/cases/associations/eager_load_includes_full_sti_class_test.rb
ibm_db-3.0.1-x86-mingw32 test/cases/associations/eager_load_includes_full_sti_class_test.rb
activejob-lock-0.0.1 rails/activerecord/test/cases/associations/eager_load_includes_full_sti_class_test.rb
activerecord-nuodb-adapter-1.1 test/cases/associations/eager_load_includes_full_sti_class_test.rb
activerecord-nuodb-adapter-1.0.4 test/cases/associations/eager_load_includes_full_sti_class_test.rb