2009-04-30 16:55:53 +00:00
|
|
|
module ActionDispatch
|
2006-09-03 20:18:06 +00:00
|
|
|
module Assertions
|
|
|
|
module ModelAssertions
|
2008-05-25 11:29:00 +00:00
|
|
|
# Ensures that the passed record is valid by Active Record standards and
|
|
|
|
# returns any error messages if it is not.
|
2007-12-05 14:40:42 +00:00
|
|
|
#
|
|
|
|
# ==== Examples
|
|
|
|
#
|
|
|
|
# # assert that a newly created record is valid
|
|
|
|
# model = Model.new
|
|
|
|
# assert_valid(model)
|
|
|
|
#
|
2006-09-03 20:18:06 +00:00
|
|
|
def assert_valid(record)
|
2008-11-25 18:32:14 +00:00
|
|
|
::ActiveSupport::Deprecation.warn("assert_valid is deprecated. Use assert record.valid? instead", caller)
|
2009-04-30 16:40:29 +00:00
|
|
|
assert record.valid?, record.errors.full_messages.join("\n")
|
2006-09-03 20:18:06 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2007-12-05 14:40:42 +00:00
|
|
|
end
|