-
Nick Hengeveld authored
Co-authored-by:
Adam Hess <hparker@github.com> Fixes an issue where parameterizing strings was mutating the source, eg: ```ruby require "bundler/inline" gemfile(true) do source "https://rubygems.org" git_source(:github) { |repo| "https://github.com/#{repo}.git" } gem "rails", github: "rails/rails", branch: "main" 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 :posts, force: true do |t| t.text :name t.text :slug end end class Post < ActiveRecord::Base validate :generate_slug def generate_slug self.slug = name.parameterize end end class BugTest < Minitest::Test def test_name_gets_corrupted post = Post.create!(name: "hi there") assert_equal "hi there", post.name # This test fails, "hi-there" end end ```
Nick Hengeveld authoredCo-authored-by:
Adam Hess <hparker@github.com> Fixes an issue where parameterizing strings was mutating the source, eg: ```ruby require "bundler/inline" gemfile(true) do source "https://rubygems.org" git_source(:github) { |repo| "https://github.com/#{repo}.git" } gem "rails", github: "rails/rails", branch: "main" 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 :posts, force: true do |t| t.text :name t.text :slug end end class Post < ActiveRecord::Base validate :generate_slug def generate_slug self.slug = name.parameterize end end class BugTest < Minitest::Test def test_name_gets_corrupted post = Post.create!(name: "hi there") assert_equal "hi there", post.name # This test fails, "hi-there" end end ```
Loading