Related to Rails issue report: rails/rails#38881
original template https://github.com/rails/rails/blob/master/guides/bug_report_templates/active_record_master.rb
Related to Rails issue report: rails/rails#38881
original template https://github.com/rails/rails/blob/master/guides/bug_report_templates/active_record_master.rb
| # frozen_string_literal: true | |
| require "bundler/inline" | |
| gemfile(true) do | |
| source "https://rubygems.org" | |
| git_source(:github) { |repo| "https://github.com/#{repo}.git" } | |
| gem "rails", github: "rails/rails" | |
| gem "sqlite3" | |
| end | |
| require "active_record" | |
| require 'active_support/test_case' | |
| require "minitest/autorun" | |
| require "logger" | |
| # This connection will do for database-independent bug reports. | |
| ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:") | |
| ActiveRecord::Base.logger = Logger.new(STDOUT) | |
| ActiveRecord::Schema.define do | |
| create_table :posts, force: true do |t| | |
| end | |
| create_table :comments, force: true do |t| | |
| t.integer :post_id | |
| t.string :source | |
| end | |
| end | |
| class Post < ActiveRecord::Base | |
| has_many :comments | |
| end | |
| class Comment < ActiveRecord::Base | |
| SOURCE_INTERFACE='interface' | |
| belongs_to :post | |
| scope :interface, -> { where(source: Comment::SOURCE_INTERFACE) } | |
| end | |
| class BugTest < Minitest::Test | |
| include ActiveSupport::Testing::Deprecation | |
| def test_association_stuff | |
| post = Post.create! | |
| assert_deprecated do | |
| post.comments.interface.create! | |
| end | |
| end | |
| end |
| # frozen_string_literal: true | |
| require "bundler/inline" | |
| gemfile(true) do | |
| source "https://rubygems.org" | |
| git_source(:github) { |repo| "https://github.com/#{repo}.git" } | |
| gem "rails", github: "rails/rails" | |
| gem "sqlite3" | |
| end | |
| require "active_record" | |
| require 'active_support/test_case' | |
| require "minitest/autorun" | |
| require "logger" | |
| # This connection will do for database-independent bug reports. | |
| ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:") | |
| ActiveRecord::Base.logger = Logger.new(STDOUT) | |
| ActiveRecord::Schema.define do | |
| create_table :posts, force: true do |t| | |
| end | |
| create_table :comments, force: true do |t| | |
| t.integer :post_id | |
| t.string :type | |
| end | |
| end | |
| class Post < ActiveRecord::Base | |
| has_many :comments | |
| end | |
| class Comment < ActiveRecord::Base | |
| SOURCE_INTERFACE='interface' | |
| belongs_to :post | |
| self.inheritance_column = :_type_disabled | |
| scope :interface, -> { where(type: BusinessLogic::SomeBusinessLogic) } | |
| end | |
| module BusinessLogic | |
| class SomeBusinessLogic | |
| end | |
| end | |
| class BugTest < Minitest::Test | |
| include ActiveSupport::Testing::Deprecation | |
| def test_association_stuff | |
| post = Post.create! | |
| assert_deprecated do | |
| post.comments.interface.create! | |
| end | |
| end | |
| end |
I've runned it on Rails 6.0.2.2 and 6.0.2.1