Last active
August 29, 2015 14:05
-
-
Save mfazekas/fc7cf36804efe19f0ce9 to your computer and use it in GitHub Desktop.
infinite loop in changed_for_autosave https://github.com/rails/rails/pull/7824 and https://github.com/rails/rails/issues/7809
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
unless File.exist?('Gemfile') | |
File.write('Gemfile', <<-GEMFILE) | |
source 'https://rubygems.org' | |
gem 'rails', github: 'rails/rails' | |
gem 'arel', github: 'rails/arel' | |
gem 'sqlite3' | |
gem 'byebug' | |
GEMFILE | |
system 'bundle' | |
end | |
require 'bundler' | |
Bundler.setup(:default) | |
require 'active_record' | |
require 'minitest/autorun' | |
require 'logger' | |
# 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 :users do |t| end | |
create_table :employees do |t| t.integer "user_id" end | |
end | |
class User < ActiveRecord::Base | |
has_one :employee | |
accepts_nested_attributes_for :employee | |
end | |
class Employee < ActiveRecord::Base | |
belongs_to :user | |
accepts_nested_attributes_for :user | |
end | |
class BugTest < MiniTest::Unit::TestCase | |
def test_changed_for_autosave_inf_loop | |
u = User.create! | |
e = Employee.create!(user:u) | |
u.employee=e | |
e.save! | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have this problem on 4.2. Unfortunately, the issue is locked and I can't comment. I applied the patch locally and it fixes the problem.