Skip to content

Instantly share code, notes, and snippets.

@alexcameron89
Created April 4, 2017 00:36
Show Gist options
  • Save alexcameron89/11b77a2d2da66757062cfcf9d52eb490 to your computer and use it in GitHub Desktop.
Save alexcameron89/11b77a2d2da66757062cfcf9d52eb490 to your computer and use it in GitHub Desktop.
This test script shows a regression in ActiveRecord from 4-2 to 5 on frozen records that are saved.
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
gem "rails", github: "rails/rails"
gem "arel", github: "rails/arel"
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 :users, force: true do |t|
end
end
class User < ActiveRecord::Base
end
class BugTest < Minitest::Test
def test_destroyed_frozen
user = User.new
user.save
user.destroy
user.save
assert user.frozen?, "user should be frozen"
end
def test_saved_frozen
user = User.new
user.save
user.freeze
user.save
assert user.frozen?, "user should be frozen"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment