Last active
October 4, 2023 14:15
-
-
Save ohbarye/45bf79e8d43d55acfcc6626b7d4d58ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require 'bundler/inline' | |
gemfile(true) do | |
source 'https://rubygems.org' | |
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | |
gem 'activerecord', '7.1.0.rc1' | |
gem 'activesupport', '7.1.0.rc1' | |
gem 'sqlite3' | |
end | |
require 'active_record' | |
require 'active_support/core_ext/object/with_options' | |
require 'minitest/autorun' | |
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:') | |
ActiveRecord::Base.logger = Logger.new(STDOUT) | |
ActiveRecord::Schema.define do | |
create_table 'users', force: :true do |t| | |
end | |
create_table 'user_accounts', force: :true do |t| | |
t.bigint 'user_id' | |
t.bigint 'account_id' | |
end | |
create_table 'accounts', force: :true do |t| | |
end | |
create_table 'foo_bars', force: :true do |t| | |
t.bigint 'user_id' | |
end | |
end | |
class User < ActiveRecord::Base | |
with_options dependent: :restrict_with_error do | |
has_one :foo_bar, class_name: '::Foo::Bar' | |
has_many :user_accounts | |
has_many :accounts, through: :user_accounts | |
end | |
end | |
class UserAccount < ActiveRecord::Base | |
belongs_to :user | |
belongs_to :account | |
end | |
module Foo | |
class Bar < ActiveRecord::Base | |
end | |
end | |
class Account < ActiveRecord::Base | |
end | |
class BugTest < Minitest::Test | |
def test_association_stuff | |
foo = User.new.accounts # it is expected to raise ActiveRecord::HasManyThroughSourceAssociationNotFoundError | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment