aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/models/reply.rb
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2009-06-02 12:36:36 -0300
committerEmilio Tagua <miloops@gmail.com>2009-06-02 12:36:36 -0300
commitfd3c55f09fdfb45c33a5383af2c0b9ddf8f63e90 (patch)
tree89f6b8eeae81ba9e9f3c43667b234b64a776e649 /activemodel/test/models/reply.rb
parent5255a81b808c2c947d58df979e6436b1fe1d8157 (diff)
parent196f780e30fcece25e4d09c12f9b9f7374ebed29 (diff)
downloadrails-fd3c55f09fdfb45c33a5383af2c0b9ddf8f63e90.tar.gz
rails-fd3c55f09fdfb45c33a5383af2c0b9ddf8f63e90.tar.bz2
rails-fd3c55f09fdfb45c33a5383af2c0b9ddf8f63e90.zip
Merge commit 'rails/master'
Conflicts: activerecord/lib/active_record.rb
Diffstat (limited to 'activemodel/test/models/reply.rb')
-rw-r--r--activemodel/test/models/reply.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/activemodel/test/models/reply.rb b/activemodel/test/models/reply.rb
new file mode 100644
index 0000000000..acfd801674
--- /dev/null
+++ b/activemodel/test/models/reply.rb
@@ -0,0 +1,34 @@
+require 'models/topic'
+
+class Reply < Topic
+ validate :errors_on_empty_content
+ validate_on_create :title_is_wrong_create
+
+ validate :check_empty_title
+ validate_on_create :check_content_mismatch
+ validate_on_update :check_wrong_update
+
+ attr_accessible :title, :author_name, :author_email_address, :written_on, :content, :last_read
+
+ def check_empty_title
+ errors[:title] << "Empty" unless attribute_present?("title")
+ end
+
+ def errors_on_empty_content
+ errors[:content] << "Empty" unless attribute_present?("content")
+ end
+
+ def check_content_mismatch
+ if attribute_present?("title") && attribute_present?("content") && content == "Mismatch"
+ errors[:title] << "is Content Mismatch"
+ end
+ end
+
+ def title_is_wrong_create
+ errors[:title] << "is Wrong Create" if attribute_present?("title") && title == "Wrong Create"
+ end
+
+ def check_wrong_update
+ errors[:title] << "is Wrong Update" if attribute_present?("title") && title == "Wrong Update"
+ end
+end