aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/assertions/assert_valid.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_controller/assertions/assert_valid.rb')
-rw-r--r--actionpack/lib/action_controller/assertions/assert_valid.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/assertions/assert_valid.rb b/actionpack/lib/action_controller/assertions/assert_valid.rb
new file mode 100644
index 0000000000..b807a8902f
--- /dev/null
+++ b/actionpack/lib/action_controller/assertions/assert_valid.rb
@@ -0,0 +1,15 @@
+require 'test/unit'
+require 'test/unit/assertions'
+
+module ActionController
+ module Assertions
+ module ModelAssertions
+ # ensures that the passed record is valid by active record standards. returns the error messages if not
+ def assert_valid(record)
+ clean_backtrace do
+ assert record.valid?, record.errors.full_messages.join("\n")
+ end
+ end
+ end
+ end
+end \ No newline at end of file