Added the possibility of having validate be protected for assert_(in)valid_column #263 [Tobias Luetke]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@67 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
David Heinemeier Hansson 2004-12-07 12:18:33 +00:00
parent 1e4a936bd0
commit 465e0c0c26
3 changed files with 10 additions and 7 deletions

@ -1,5 +1,7 @@
*SVN* *SVN*
* Added the possibility of having validate be protected for assert_(in)valid_column #263 [Tobias Luetke]
* Added that ActiveRecordHelper#form now calls url_for on the :action option. * Added that ActiveRecordHelper#form now calls url_for on the :action option.
* Added all the HTTP methods as alternatives to the generic "process" for functional testing #276 [Tobias Luetke]. Examples: * Added all the HTTP methods as alternatives to the generic "process" for functional testing #276 [Tobias Luetke]. Examples:

@ -22,7 +22,7 @@ def assert_invalid_record(key = nil, message = nil)
# Assert the template object with the given name is an Active Record descendant and the specified column(s) are valid. # Assert the template object with the given name is an Active Record descendant and the specified column(s) are valid.
def assert_valid_column_on_record(key = nil, columns = "", message = nil) def assert_valid_column_on_record(key = nil, columns = "", message = nil)
record = find_record_in_template(key) record = find_record_in_template(key)
record.validate record.send(:validate)
cols = glue_columns(columns) cols = glue_columns(columns)
cols.delete_if { |col| !record.errors.invalid?(col) } cols.delete_if { |col| !record.errors.invalid?(col) }
@ -33,7 +33,7 @@ def assert_valid_column_on_record(key = nil, columns = "", message = nil)
# Assert the template object with the given name is an Active Record descendant and the specified column(s) are invalid. # Assert the template object with the given name is an Active Record descendant and the specified column(s) are invalid.
def assert_invalid_column_on_record(key = nil, columns = "", message = nil) def assert_invalid_column_on_record(key = nil, columns = "", message = nil)
record = find_record_in_template(key) record = find_record_in_template(key)
record.validate record.send(:validate)
cols = glue_columns(columns) cols = glue_columns(columns)
cols.delete_if { |col| record.errors.invalid?(col) } cols.delete_if { |col| record.errors.invalid?(col) }

@ -21,6 +21,7 @@
# add some validation rules to trip up the assertions # add some validation rules to trip up the assertions
class Company class Company
protected
def validate def validate
errors.add_on_empty('name') errors.add_on_empty('name')
errors.add('rating', 'rating should not be 2') if rating == 2 errors.add('rating', 'rating should not be 2') if rating == 2