Last active
August 29, 2015 14:15
-
-
Save jarmo/0c5ff28b32a9bfd8a9af 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
# Activate the gem you are reporting the issue against. | |
gem 'activerecord', '4.2.0' | |
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 :posts do |t| | |
t.text :bar | |
end | |
end | |
class Post < ActiveRecord::Base | |
serialize :bar, Hash | |
attr_accessor :bar | |
after_initialize -> { | |
self.bar.merge!(foo: "bar") | |
} | |
end | |
class BugTest < Minitest::Test | |
def test_association_stuff | |
post = Post.new | |
expected = {foo: "bar"} | |
assert_equal expected, post.bar | |
end | |
end | |
$ ruby rails-4.2-test.rb | |
-- create_table(:posts) | |
D, [2015-02-14T11:44:49.413052 #60774] DEBUG -- : (0.4ms) CREATE TABLE "posts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "bar" text) | |
-> 0.0024s | |
Run options: --seed 61615 | |
# Running: | |
E | |
Finished in 0.009806s, 101.9784 runs/s, 0.0000 assertions/s. | |
1) Error: | |
BugTest#test_association_stuff: | |
NoMethodError: undefined method `merge!' for nil:NilClass | |
../rails-4.2-test.rb:25:in `block in <class:Post>' | |
/Users/jarmo/.rbenv/versions/1.9.3-p547/lib/ruby/gems/1.9.1/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:441:in `instance_exec' | |
/Users/jarmo/.rbenv/versions/1.9.3-p547/lib/ruby/gems/1.9.1/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:441:in `block in make_lambda' | |
/Users/jarmo/.rbenv/versions/1.9.3-p547/lib/ruby/gems/1.9.1/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:225:in `call' | |
/Users/jarmo/.rbenv/versions/1.9.3-p547/lib/ruby/gems/1.9.1/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:225:in `block in halting_and_conditional' | |
/Users/jarmo/.rbenv/versions/1.9.3-p547/lib/ruby/gems/1.9.1/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:92:in `call' | |
/Users/jarmo/.rbenv/versions/1.9.3-p547/lib/ruby/gems/1.9.1/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:92:in `_run_callbacks' | |
/Users/jarmo/.rbenv/versions/1.9.3-p547/lib/ruby/gems/1.9.1/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:734:in `_run_initialize_callbacks' | |
/Users/jarmo/.rbenv/versions/1.9.3-p547/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0/lib/active_record/core.rb:283:in `initialize' | |
/Users/jarmo/.rbenv/versions/1.9.3-p547/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0/lib/active_record/inheritance.rb:61:in `new' | |
/Users/jarmo/.rbenv/versions/1.9.3-p547/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0/lib/active_record/inheritance.rb:61:in `new' | |
../rails-4.2-test.rb:31:in `test_association_stuff' | |
1 runs, 0 assertions, 0 failures, 1 errors, 0 skips |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment