-
-
Save jules2689/e6cc70793b3ee9c758ab1c1f293d9d0f 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
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" | |
if ENV['RAILS_NEXT'] | |
gem "rails", "6.0.0.rc2" | |
else | |
gem "rails", "5.2.3" | |
end | |
gem "sqlite3" | |
end | |
require "active_record" | |
require "minitest/autorun" | |
require "logger" | |
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:") | |
ActiveRecord::Base.logger = Logger.new(STDOUT) | |
ActiveRecord::Schema.define do | |
create_table :users do |t| | |
t.string :first_name | |
t.string :last_name | |
end | |
end | |
class User < ActiveRecord::Base | |
validates :first_name, presence: { message: 'must be there!' } | |
def self.human_attributes | |
@human_attributes | |
end | |
def self.human_attribute_name(attr, options = {}) | |
@human_attributes ||= [] | |
@human_attributes << attr.inspect | |
super | |
end | |
end | |
class BugTest < Minitest::Test | |
def test_frozen_attributes | |
user = User.new(first_name: '', last_name: 'Ketchum') | |
user.save | |
user.errors.full_messages | |
# Two symbols that were `inspect`ed | |
# In RAILS_NEXT this is [":first_name", "\"first_name\""] | |
assert_equal [":first_name", ":first_name"], User.human_attributes | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment