aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller
diff options
context:
space:
mode:
authorTobias Lütke <tobias.luetke@gmail.com>2005-10-16 02:20:53 +0000
committerTobias Lütke <tobias.luetke@gmail.com>2005-10-16 02:20:53 +0000
commit0279949b055330209eb272ed642e1fe59536087d (patch)
tree0424c4875415012fd96af6ea13d0773977841465 /actionpack/test/controller
parent5e5c332c3ea906750c339c4776a60ec5aa18b0af (diff)
downloadrails-0279949b055330209eb272ed642e1fe59536087d.tar.gz
rails-0279949b055330209eb272ed642e1fe59536087d.tar.bz2
rails-0279949b055330209eb272ed642e1fe59536087d.zip
added assert_valid to AP
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2635 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r--actionpack/test/controller/action_pack_assertions_test.rb52
-rw-r--r--actionpack/test/controller/active_record_assertions_test.rb3
2 files changed, 52 insertions, 3 deletions
diff --git a/actionpack/test/controller/action_pack_assertions_test.rb b/actionpack/test/controller/action_pack_assertions_test.rb
index 917ae330b6..6d5ade98bf 100644
--- a/actionpack/test/controller/action_pack_assertions_test.rb
+++ b/actionpack/test/controller/action_pack_assertions_test.rb
@@ -77,6 +77,41 @@ class ActionPackAssertionsController < ActionController::Base
def raise_on_post
raise "post" if @request.post?
render_text "request method: #{@request.env['REQUEST_METHOD']}"
+ end
+
+ def get_valid_record
+ @record = Class.new do
+ def valid?
+ true
+ end
+
+ def errors
+ Class.new do
+ def full_messages; '...stuff...'; end
+ end.new
+ end
+
+ end.new
+
+ render :nothing => true
+ end
+
+
+ def get_invalid_record
+ @record = Class.new do
+
+ def valid?
+ false
+ end
+
+ def errors
+ Class.new do
+ def full_messages; '...stuff...'; end
+ end.new
+ end
+ end.new
+
+ render :nothing => true
end
# 911
@@ -420,6 +455,21 @@ class ActionPackAssertionsControllerTest < Test::Unit::TestCase
get :redirect_to_fellow_controller
assert_redirected_to :controller => 'admin/user'
+ end
+
+ def test_assert_valid
+ get :get_valid_record
+ assert_valid assigns('record')
+ end
+
+ def test_assert_valid_failing
+ get :get_invalid_record
+
+ begin
+ assert_valid assigns('record')
+ assert false
+ rescue Test::Unit::AssertionFailedError => e
+ end
end
end
@@ -437,4 +487,4 @@ class ActionPackHeaderTest < Test::Unit::TestCase
process :hello_xml_world
assert_equal('application/pdf', @controller.headers['Content-Type'])
end
-end
+end \ No newline at end of file
diff --git a/actionpack/test/controller/active_record_assertions_test.rb b/actionpack/test/controller/active_record_assertions_test.rb
index d4cbda80e9..a60df5a668 100644
--- a/actionpack/test/controller/active_record_assertions_test.rb
+++ b/actionpack/test/controller/active_record_assertions_test.rb
@@ -75,8 +75,7 @@ class ActiveRecordAssertionsController < ActionController::Base
# the safety dance......
def rescue_action(e) raise; end
end
-
-
+
class ActiveRecordAssertionsControllerTest < Test::Unit::TestCase
def setup
@request = ActionController::TestRequest.new