Created
July 13, 2017 01:32
-
-
Save willnet/b31b7ddc354aa60f2850ff274879b625 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
begin | |
require "bundler/inline" | |
rescue LoadError => e | |
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler" | |
raise e | |
end | |
gemfile(true) do | |
source "https://rubygems.org" | |
# Activate the gem you are reporting the issue against. | |
gem "rails", "5.1.2" | |
gem "activerecord", "5.1.2" | |
gem "sqlite3" | |
end | |
require "active_record" | |
require "minitest/autorun" | |
require "logger" | |
# Ensure backward compatibility with Minitest 4 | |
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test) | |
# 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 :posting_posts, force: true do |t| | |
end | |
create_table :posting_comments, force: true do |t| | |
t.references :posts | |
end | |
end | |
module Posting | |
class Engine < ::Rails::Engine | |
isolate_namespace Posting | |
end | |
end | |
module Posting | |
class Post < ActiveRecord::Base | |
has_many :comments | |
end | |
class Comment < ActiveRecord::Base | |
belongs_to :post | |
end | |
end | |
class BugTest < Minitest::Test | |
def test_association_stuff | |
post = Posting::Post.create! | |
post.comments << Posting::Comment.create! | |
assert_equal 1, post.comments.count | |
assert_equal 1, Posting::Comment.count | |
assert_equal post.id, Posting::Comment.first.post.id | |
end | |
end |
Author
willnet
commented
Jul 13, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment