Skip to content

Commit

Permalink
Add failing test that triggers the stack overflow for #2578.
Browse files Browse the repository at this point in the history
Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com>
  • Loading branch information
bryanstearns authored and alloy committed Jan 8, 2010
1 parent d5ba7c3 commit 2aef092
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
9 changes: 9 additions & 0 deletions activerecord/test/cases/autosave_association_test.rb
Expand Up @@ -3,6 +3,8 @@
require 'models/company'
require 'models/customer'
require 'models/developer'
require 'models/invoice'
require 'models/line_item'
require 'models/order'
require 'models/parrot'
require 'models/person'
Expand Down Expand Up @@ -1169,3 +1171,10 @@ def setup
assert !@pirate.respond_to?(:validate_associated_records_for_non_validated_parrots)
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
4 changes: 4 additions & 0 deletions activerecord/test/models/invoice.rb
@@ -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
3 changes: 3 additions & 0 deletions activerecord/test/models/line_item.rb
@@ -0,0 +1,3 @@
class LineItem < ActiveRecord::Base
belongs_to :invoice, :touch => true
end
10 changes: 10 additions & 0 deletions activerecord/test/schema/schema.rb
Expand Up @@ -192,6 +192,11 @@ def create_table(*args, &block)
t.string :info
end

create_table :invoices, :force => true do |t|
t.integer :balance
t.datetime :updated_at
end

create_table :items, :force => true do |t|
t.column :name, :integer
end
Expand All @@ -217,6 +222,11 @@ def create_table(*args, &block)
t.integer :version, :null => false, :default => 0
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|
t.column :lock_version, :integer
end
Expand Down

0 comments on commit 2aef092

Please sign in to comment.