Patch ActiveRecord::Errors#full_messages so that it contains custom values error messages.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2518 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2009-02-22 14:46:32 +00:00
parent 67fd5f3dc9
commit a64b8695c8
2 changed files with 43 additions and 0 deletions
+13
View File
@@ -63,6 +63,19 @@ class IssueTest < Test::Unit::TestCase
assert_equal 'PostgreSQL', issue.custom_value_for(field).value
end
def test_errors_full_messages_should_include_custom_fields_errors
field = IssueCustomField.find_by_name('Database')
issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :subject => 'test_create', :description => 'IssueTest#test_create_with_required_custom_field')
assert issue.available_custom_fields.include?(field)
# Invalid value
issue.custom_field_values = { field.id => 'SQLServer' }
assert !issue.valid?
assert_equal 1, issue.errors.full_messages.size
assert_equal "Database #{I18n.translate('activerecord.errors.messages.inclusion')}", issue.errors.full_messages.first
end
def test_update_issue_with_required_custom_field
field = IssueCustomField.find_by_name('Database')
field.update_attribute(:is_required, true)