Sha256: 53c40c0a10d6c583a6ec5fdc5e103bfabc244f33150280b7c6b12ba5771aa498

Contents?: true

Size: 1018 Bytes

Versions: 96

Compression:

Stored size: 1018 Bytes

Contents

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

module Namespaced
  class Post < ActiveRecord::Base
    set_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 = 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.find_by_title( 'Great stuff', :include => :tagging )
    assert_nil post.tagging

    ActiveRecord::Base.store_full_sti_class = true
    post = Namespaced::Post.find_by_title( 'Great stuff', :include => :tagging )
    assert_equal 'Tagging', post.tagging.class.name
  ensure
    ActiveRecord::Base.store_full_sti_class = old
  end
end

Version data entries

96 entries across 93 versions & 18 rubygems

Version Path
activerecord-2.3.6 test/cases/associations/eager_load_includes_full_sti_class_test.rb
radiant-0.8.2 vendor/rails/activerecord/test/cases/associations/eager_load_includes_full_sti_class_test.rb
radiant-0.9.0.rc2 vendor/rails/activerecord/test/cases/associations/eager_load_includes_full_sti_class_test.rb
webroar-0.3.1 src/admin_panel/vendor/rails/activerecord/test/cases/associations/eager_load_includes_full_sti_class_test.rb
webroar-0.3.0 src/admin_panel/vendor/rails/activerecord/test/cases/associations/eager_load_includes_full_sti_class_test.rb
usher-0.7.0 spec/rails2_2/vendor/rails/vendor/rails/activerecord/test/cases/associations/eager_load_includes_full_sti_class_test.rb
usher-0.7.0 spec/rails2_3/vendor/rails/vendor/rails/activerecord/test/cases/associations/eager_load_includes_full_sti_class_test.rb
usher-0.7.0 spec/rails2_3/vendor/rails/vendor/rails/activerecord/pkg/activerecord-2.3.3/test/cases/associations/eager_load_includes_full_sti_class_test.rb
usher-0.7.0 spec/rails2_2/vendor/rails/vendor/rails/activerecord/pkg/activerecord-2.2.2/test/cases/associations/eager_load_includes_full_sti_class_test.rb
simply_stated-0.0.5 vendor/gems/ruby/1.8/gems/activerecord-2.3.5/test/cases/associations/eager_load_includes_full_sti_class_test.rb
simply_stated-0.0.4 vendor/gems/ruby/1.8/gems/activerecord-2.3.5/test/cases/associations/eager_load_includes_full_sti_class_test.rb
factorylabs-castronaut-0.7.5 vendor/activerecord/test/cases/associations/eager_load_includes_full_sti_class_test.rb
ginst-2009.12.8 vendor/rails/activerecord/test/cases/associations/eager_load_includes_full_sti_class_test.rb
activerecord-2.3.5 test/cases/associations/eager_load_includes_full_sti_class_test.rb
ginst-2009.11.24 vendor/rails/activerecord/test/cases/associations/eager_load_includes_full_sti_class_test.rb
ginst-2009.11.23 vendor/rails/activerecord/test/cases/associations/eager_load_includes_full_sti_class_test.rb
ginst-2.0.1 vendor/rails/activerecord/test/cases/associations/eager_load_includes_full_sti_class_test.rb
ginst-2.0.0 vendor/rails/activerecord/test/cases/associations/eager_load_includes_full_sti_class_test.rb
gemstreamer-1.2.0 spec/assets/testapp/vendor/rails/activerecord/test/cases/associations/eager_load_includes_full_sti_class_test.rb
gemstreamer-1.1.1 spec/assets/testapp/vendor/rails/activerecord/test/cases/associations/eager_load_includes_full_sti_class_test.rb