1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Add failing test that triggers the stack overflow

This commit is contained in:
Bryan Stearns 2009-09-30 23:17:50 -07:00 committed by Eloy Duran
parent 802b08da00
commit 1080351437
4 changed files with 26 additions and 0 deletions

View file

@ -3,6 +3,8 @@ require 'models/bird'
require 'models/company' require 'models/company'
require 'models/customer' require 'models/customer'
require 'models/developer' require 'models/developer'
require 'models/invoice'
require 'models/line_item'
require 'models/order' require 'models/order'
require 'models/parrot' require 'models/parrot'
require 'models/person' require 'models/person'
@ -1215,3 +1217,10 @@ class TestAutosaveAssociationValidationMethodsGeneration < ActiveRecord::TestCas
assert !@pirate.respond_to?(:validate_associated_records_for_non_validated_parrots) assert !@pirate.respond_to?(:validate_associated_records_for_non_validated_parrots)
end end
end end
class TestAutosaveAssociationWithTouch < ActiveRecord::TestCase
def test_autosave_with_touch_should_not_raise_system_stack_error
invoice = Invoice.create
assert_nothing_raised { invoice.line_items.create(:amount => 10) }
end
end

View file

@ -0,0 +1,4 @@
class Invoice < ActiveRecord::Base
has_many :line_items, :autosave => true
before_save {|record| record.balance = record.line_items.map(&:amount).sum }
end

View file

@ -0,0 +1,3 @@
class LineItem < ActiveRecord::Base
belongs_to :invoice, :touch => true
end

View file

@ -191,6 +191,11 @@ ActiveRecord::Schema.define do
t.string :info t.string :info
end end
create_table :invoices, :force => true do |t|
t.integer :balance
t.datetime :updated_at
end
create_table :items, :force => true do |t| create_table :items, :force => true do |t|
t.column :name, :integer t.column :name, :integer
end end
@ -216,6 +221,11 @@ ActiveRecord::Schema.define do
t.integer :version, :null => false, :default => 0 t.integer :version, :null => false, :default => 0
end end
create_table :line_items, :force => true do |t|
t.integer :invoice_id
t.integer :amount
end
create_table :lock_without_defaults, :force => true do |t| create_table :lock_without_defaults, :force => true do |t|
t.column :lock_version, :integer t.column :lock_version, :integer
end end