Changeset 2635
- Timestamp:
- 10/16/05 02:20:53 (3 years ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_controller/assertions.rb (modified) (1 diff)
- trunk/actionpack/test/controller/action_pack_assertions_test.rb (modified) (2 diffs)
- trunk/actionpack/test/controller/active_record_assertions_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r2630 r2635 1 1 *SVN* 2 3 * Added assert_vaild. Reports the proper AR error messages as fail message when the passed record is invalid [Tobias Luetke] 2 4 3 5 * Add temporary support for passing locals to render using string keys [Nicholas Seckar] trunk/actionpack/lib/action_controller/assertions.rb
r2611 r2635 284 284 end 285 285 end 286 287 # ensures that the passed record is valid by active record standards. returns the error messages if not 288 def assert_valid(record) 289 clean_backtrace do 290 assert record.valid?, record.errors.full_messages 291 end 292 end 286 293 287 294 def clean_backtrace(&block) trunk/actionpack/test/controller/action_pack_assertions_test.rb
r1971 r2635 78 78 raise "post" if @request.post? 79 79 render_text "request method: #{@request.env['REQUEST_METHOD']}" 80 end 81 82 def get_valid_record 83 @record = Class.new do 84 def valid? 85 true 86 end 87 88 def errors 89 Class.new do 90 def full_messages; '...stuff...'; end 91 end.new 92 end 93 94 end.new 95 96 render :nothing => true 97 end 98 99 100 def get_invalid_record 101 @record = Class.new do 102 103 def valid? 104 false 105 end 106 107 def errors 108 Class.new do 109 def full_messages; '...stuff...'; end 110 end.new 111 end 112 end.new 113 114 render :nothing => true 80 115 end 81 116 … … 421 456 get :redirect_to_fellow_controller 422 457 assert_redirected_to :controller => 'admin/user' 458 end 459 460 def test_assert_valid 461 get :get_valid_record 462 assert_valid assigns('record') 463 end 464 465 def test_assert_valid_failing 466 get :get_invalid_record 467 468 begin 469 assert_valid assigns('record') 470 assert false 471 rescue Test::Unit::AssertionFailedError => e 472 end 423 473 end 424 474 end trunk/actionpack/test/controller/active_record_assertions_test.rb
r1915 r2635 76 76 def rescue_action(e) raise; end 77 77 end 78 79 78 80 79 class ActiveRecordAssertionsControllerTest < Test::Unit::TestCase 81 80 def setup