Permalink
Browse files

Revert "Merge pull request #2194 from cldwalker/after_initialize"

This reverts commit 1983007, reversing
changes made to ae65c0b.
  • Loading branch information...
1 parent 1983007 commit 434bbb0efc727cf4cd0d736e6eb576db21b736a8 @spastorino spastorino committed Jul 23, 2011
@@ -505,7 +505,8 @@ def create(attributes = nil, options = {}, &block)
if attributes.is_a?(Array)
attributes.collect { |attr| create(attr, options, &block) }
else
- object = new(attributes, options, &block)
+ object = new(attributes, options)
+ yield(object) if block_given?
object.save
object
end
@@ -21,7 +21,6 @@
require 'models/person'
require 'models/edge'
require 'models/joke'
-require 'models/wholesale_product'
require 'rexml/document'
require 'active_support/core_ext/exception'
@@ -251,20 +250,6 @@ def test_initialize_with_invalid_attribute
end
end
- def test_create_after_initialize_without_block
- wp = WholesaleProduct.create(:wholesale => 10)
- assert_equal(20, wp.msrp)
- assert_equal(10, wp.wholesale)
- end
-
- def test_create_after_initialize_with_block
- wp = WholesaleProduct.create do |w|
- w.wholesale = 10
- end
- assert_equal(20, wp.msrp)
- assert_equal(10, wp.wholesale)
- end
-
def test_load
topics = Topic.find(:all, :order => 'id')
assert_equal(4, topics.size)
@@ -1,9 +0,0 @@
-class WholesaleProduct < ActiveRecord::Base
-
- after_initialize :set_prices
-
- def set_prices
- self.msrp = 2 * wholesale if wholesale
- end
-
-end
@@ -676,11 +676,6 @@ def create_table(*args, &block)
t.references :wheelable, :polymorphic => true
end
- create_table :wholesale_products, :force => true do |t|
- t.integer :msrp
- t.integer :wholesale
- end
-
create_table :zines, :force => true do |t|
t.string :title
end

0 comments on commit 434bbb0

Please sign in to comment.