Last active
April 16, 2021 14:10
-
-
Save Tonkpils/06524f6e48e383ed1ef70502b0c00d15 to your computer and use it in GitHub Desktop.
SystemStackError reproduction script
This file contains hidden or 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
# frozen_string_literal: true | |
## SystemStackError introduced by https://github.com/rails/rails/pull/41860 | |
require "bundler/inline" | |
gemfile(true) do | |
source "https://rubygems.org" | |
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | |
# Good | |
# gem "rails", github: "rails/rails", ref: "2bbb519" | |
# Bad | |
gem "rails", github: "rails/rails", ref: "ae56ecd" | |
gem "sqlite3" | |
end | |
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 :comments, force: true do |t| | |
t.string :body | |
t.integer :public | |
end | |
end | |
class Comment < ActiveRecord::Base | |
after_update :update_again, if: :saved_change_to_public? | |
def update_again | |
update_attribute :body, nil | |
end | |
end | |
class BugTest < Minitest::Test | |
def test_association_stuff | |
comment = Comment.create(public: false, body: nil) | |
comment.update(public: true) | |
assert_equal 1, Comment.count | |
assert Comment.first.public? | |
assert_nil Comment.first.body | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment