From 465e0c0c2635588927ca707e6220cd7f232b3f17 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 7 Dec 2004 12:18:33 +0000 Subject: [PATCH] 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 --- actionpack/CHANGELOG | 2 ++ .../assertions/active_record_assertions.rb | 4 ++-- .../test/controller/active_record_assertions_test.rb | 11 ++++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 9343c00c12e..1453bd97043 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *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 all the HTTP methods as alternatives to the generic "process" for functional testing #276 [Tobias Luetke]. Examples: diff --git a/actionpack/lib/action_controller/assertions/active_record_assertions.rb b/actionpack/lib/action_controller/assertions/active_record_assertions.rb index 9167eae53e9..cdc9b6951dd 100644 --- a/actionpack/lib/action_controller/assertions/active_record_assertions.rb +++ b/actionpack/lib/action_controller/assertions/active_record_assertions.rb @@ -22,7 +22,7 @@ module Test #:nodoc: # 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) record = find_record_in_template(key) - record.validate + record.send(:validate) cols = glue_columns(columns) cols.delete_if { |col| !record.errors.invalid?(col) } @@ -33,7 +33,7 @@ module Test #:nodoc: # 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) record = find_record_in_template(key) - record.validate + record.send(:validate) cols = glue_columns(columns) cols.delete_if { |col| record.errors.invalid?(col) } diff --git a/actionpack/test/controller/active_record_assertions_test.rb b/actionpack/test/controller/active_record_assertions_test.rb index 53106aaee7a..2a005b8586c 100644 --- a/actionpack/test/controller/active_record_assertions_test.rb +++ b/actionpack/test/controller/active_record_assertions_test.rb @@ -21,11 +21,12 @@ require 'fixtures/company' # add some validation rules to trip up the assertions class Company - def validate - errors.add_on_empty('name') - errors.add('rating', 'rating should not be 2') if rating == 2 - errors.add_to_base('oh oh') if rating == 3 - end + protected + def validate + errors.add_on_empty('name') + errors.add('rating', 'rating should not be 2') if rating == 2 + errors.add_to_base('oh oh') if rating == 3 + end end # -----------------------------------------------------------------------------