2015-06-05 20:28:11 +00:00
|
|
|
require 'bundler/inline'
|
|
|
|
|
|
|
|
gemfile(true) do
|
|
|
|
source 'https://rubygems.org'
|
|
|
|
# Activate the gem you are reporting the issue against.
|
|
|
|
gem 'activerecord', '4.2.0'
|
|
|
|
gem 'sqlite3'
|
|
|
|
end
|
|
|
|
|
2013-04-01 07:42:23 +00:00
|
|
|
require 'active_record'
|
2013-04-02 15:55:58 +00:00
|
|
|
require 'minitest/autorun'
|
|
|
|
require 'logger'
|
2013-04-01 07:42:23 +00:00
|
|
|
|
2013-12-27 10:30:53 +00:00
|
|
|
# Ensure backward compatibility with Minitest 4
|
|
|
|
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
|
|
|
|
|
2013-04-01 07:42:23 +00:00
|
|
|
# This connection will do for database-independent bug reports.
|
|
|
|
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
|