2017-08-13 13:02:48 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-10-28 17:12:48 +00:00
|
|
|
require "bundler/inline"
|
2015-06-05 20:28:11 +00:00
|
|
|
|
|
|
|
gemfile(true) do
|
2016-08-06 17:21:59 +00:00
|
|
|
source "https://rubygems.org"
|
2017-09-27 08:55:43 +00:00
|
|
|
|
2017-09-26 21:02:11 +00:00
|
|
|
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
2017-09-27 08:55:43 +00:00
|
|
|
|
2015-06-05 20:28:11 +00:00
|
|
|
# Activate the gem you are reporting the issue against.
|
2018-04-10 01:25:14 +00:00
|
|
|
gem "activerecord", "5.2.0"
|
2019-02-04 22:35:46 +00:00
|
|
|
gem "sqlite3", "~> 1.3.6"
|
2015-06-05 20:28:11 +00:00
|
|
|
end
|
|
|
|
|
2016-08-06 17:21:59 +00:00
|
|
|
require "active_record"
|
|
|
|
require "minitest/autorun"
|
|
|
|
require "logger"
|
2013-04-01 07:42:23 +00:00
|
|
|
|
|
|
|
# This connection will do for database-independent bug reports.
|
2016-08-06 17:21:59 +00:00
|
|
|
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
|
2013-04-02 15:55:58 +00:00
|
|
|
ActiveRecord::Base.logger = Logger.new(STDOUT)
|
2013-04-01 07:42:23 +00:00
|
|
|
|
|
|
|
ActiveRecord::Schema.define do
|
2015-01-19 03:33:02 +00:00
|
|
|
create_table :posts, force: true do |t|
|
2013-04-01 07:42:23 +00:00
|
|
|
end
|
|
|
|
|
2015-01-19 03:33:02 +00:00
|
|
|
create_table :comments, force: true do |t|
|
2013-04-01 07:42:23 +00:00
|
|
|
t.integer :post_id
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class Post < ActiveRecord::Base
|
|
|
|
has_many :comments
|
|
|
|
end
|
|
|
|
|
|
|
|
class Comment < ActiveRecord::Base
|
|
|
|
belongs_to :post
|
|
|
|
end
|
|
|
|
|
2013-12-26 22:54:03 +00:00
|
|
|
class BugTest < Minitest::Test
|
2013-04-01 07:42:23 +00:00
|
|
|
def test_association_stuff
|
|
|
|
post = Post.create!
|
|
|
|
post.comments << Comment.create!
|
|
|
|
|
|
|
|
assert_equal 1, post.comments.count
|
|
|
|
assert_equal 1, Comment.count
|
|
|
|
assert_equal post.id, Comment.first.post.id
|
|
|
|
end
|
|
|
|
end
|