]> source.dussan.org Git - redmine.git/commitdiff
No validation errors when entering an invalid "Estimate hours" value (#27881).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 7 Jan 2018 21:41:15 +0000 (21:41 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 7 Jan 2018 21:41:15 +0000 (21:41 +0000)
Patch by Go MAEDA.

git-svn-id: http://svn.redmine.org/redmine/trunk@17144 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/issue.rb
test/unit/issue_test.rb

index 5798fef9fbd9e12c03916ceb1d072a6b54e54d61..ae7267deb2b3022a114a2e44930fa0b068b033fb 100644 (file)
@@ -440,7 +440,7 @@ class Issue < ActiveRecord::Base
   end
 
   def estimated_hours=(h)
-    write_attribute :estimated_hours, (h.is_a?(String) ? h.to_hours : h)
+    write_attribute :estimated_hours, (h.is_a?(String) ? (h.to_hours || h) : h)
   end
 
   safe_attributes 'project_id',
index 861e3f6680ee3bd6187eb66e83a2f153ba5de28a..cd17612d0391a93e23d818f78c2a238939600f1f 100644 (file)
@@ -128,7 +128,7 @@ class IssueTest < ActiveSupport::TestCase
 
   def test_estimated_hours_should_be_validated
     set_language_if_valid 'en'
-    ['-2'].each do |invalid|
+    ['-2', '123abc'].each do |invalid|
       issue = Issue.new(:estimated_hours => invalid)
       assert !issue.valid?
       assert_include 'Estimated time is invalid', issue.errors.full_messages