diff options
author | José Valim <jose.valim@gmail.com> | 2009-09-08 10:10:14 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-09-08 10:26:39 -0500 |
commit | 4f37b97033f596ec2c95eb53e9964e051c224981 (patch) | |
tree | b7dd859f4d1b1835178eec795711f8619963c23c /activerecord/test/models | |
parent | aeab739bd56c0bff6d1b5685eee35e557484ab4c (diff) | |
download | rails-4f37b97033f596ec2c95eb53e9964e051c224981.tar.gz rails-4f37b97033f596ec2c95eb53e9964e051c224981.tar.bz2 rails-4f37b97033f596ec2c95eb53e9964e051c224981.zip |
Changed ActiveRecord to use new callbacks and speed up observers by only notifying events that are actually being consumed.
Signed-off-by: Joshua Peek <josh@joshpeek.com>
Diffstat (limited to 'activerecord/test/models')
-rw-r--r-- | activerecord/test/models/company.rb | 5 | ||||
-rw-r--r-- | activerecord/test/models/reply.rb | 8 | ||||
-rw-r--r-- | activerecord/test/models/topic.rb | 2 |
3 files changed, 10 insertions, 5 deletions
diff --git a/activerecord/test/models/company.rb b/activerecord/test/models/company.rb index ab09f88a9f..9242c209ea 100644 --- a/activerecord/test/models/company.rb +++ b/activerecord/test/models/company.rb @@ -111,6 +111,8 @@ class Client < Company true end + before_destroy :overwrite_to_raise + # Used to test that read and question methods are not generated for these attributes def ruby_type read_attribute :ruby_type @@ -120,6 +122,9 @@ class Client < Company query_attribute :rating end + def overwrite_to_raise + end + class << self private diff --git a/activerecord/test/models/reply.rb b/activerecord/test/models/reply.rb index f5906dedd1..ba5a1d1d01 100644 --- a/activerecord/test/models/reply.rb +++ b/activerecord/test/models/reply.rb @@ -8,13 +8,13 @@ class Reply < Topic has_many :replies, :class_name => "SillyReply", :dependent => :destroy, :foreign_key => "parent_id" validate :errors_on_empty_content - validate_on_create :title_is_wrong_create + validate :title_is_wrong_create, :on => :create attr_accessible :title, :author_name, :author_email_address, :written_on, :content, :last_read, :parent_title validate :check_empty_title - validate_on_create :check_content_mismatch - validate_on_update :check_wrong_update + validate :check_content_mismatch, :on => :create + validate :check_wrong_update, :on => :update def check_empty_title errors[:title] << "Empty" unless attribute_present?("title") @@ -47,4 +47,4 @@ module Web class Reply < Web::Topic belongs_to :topic, :foreign_key => "parent_id", :counter_cache => true, :class_name => 'Web::Topic' end -end
\ No newline at end of file +end diff --git a/activerecord/test/models/topic.rb b/activerecord/test/models/topic.rb index 9594dc300a..c16a6f2be9 100644 --- a/activerecord/test/models/topic.rb +++ b/activerecord/test/models/topic.rb @@ -77,4 +77,4 @@ module Web class Topic < ActiveRecord::Base has_many :replies, :dependent => :destroy, :foreign_key => "parent_id", :class_name => 'Web::Reply' end -end
\ No newline at end of file +end |