Sha256: 629af8f5c657e80c1f98db1d44c9620c8cf8dc6c85756a0c2218fb711154a5ed
Contents?: true
Size: 1.32 KB
Versions: 1
Compression:
Stored size: 1.32 KB
Contents
# frozen_string_literal: true 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 post = Namespaced::Post.create(title: "Great stuff", body: "This is not", author_id: 1) @tagging = Tagging.create(taggable: post) @old = ActiveRecord::Base.store_full_sti_class end def teardown ActiveRecord::Base.store_full_sti_class = @old end def test_class_names_with_includes 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_equal @tagging, post.tagging end def test_class_names_with_eager_load ActiveRecord::Base.store_full_sti_class = false post = Namespaced::Post.eager_load(:tagging).find_by_title("Great stuff") assert_nil post.tagging ActiveRecord::Base.store_full_sti_class = true post = Namespaced::Post.eager_load(:tagging).find_by_title("Great stuff") assert_equal @tagging, post.tagging end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ruby-on-quails-0.1.0 | activerecord/test/cases/associations/eager_load_includes_full_sti_class_test.rb |