Last active
March 30, 2017 21:53
-
-
Save alexcameron89/ac5f084f9793aeafa0003eaa6d2ce6cc to your computer and use it in GitHub Desktop.
Bug Report for Rails Issue #28599
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" | |
gem "rails", github: "rails/rails" | |
gem "arel", github: "rails/arel" | |
gem "sqlite3" | |
gem "byebug" | |
gem "pry" | |
end | |
require "active_record" | |
require "minitest/autorun" | |
require "logger" | |
require "byebug" | |
require "pry" | |
#byebug | |
# 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 :orders do |t| | |
t.string :name | |
end | |
create_table :details do |t| | |
t.integer :order_id | |
end | |
end | |
class Order < ActiveRecord::Base | |
has_many :details | |
validate :validate_name, if: lambda { |obj| obj.name_changed? } | |
def validate_name | |
puts "validate_name" | |
end | |
end | |
class Detail < ActiveRecord::Base | |
belongs_to :order | |
before_save :update_order | |
def update_order | |
order.name += ' (updated)' | |
order.save | |
end | |
end | |
class BugTest < Minitest::Test | |
def test_association_stuff | |
o = Order.create! name: 'An order' | |
o.details.create! | |
assert_equal 'An order (updated)', o.name | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment