#1517 Uploading with an empty attachment field
This commit is contained in:
parent
f8ebe13249
commit
79bc188c75
@ -20,6 +20,8 @@
|
||||
|
||||
# Upload helper
|
||||
module DmsfUploadHelper
|
||||
include Redmine::I18n
|
||||
|
||||
def self.commit_files_internal(committed_files, project, folder, controller = nil, container = nil, new_object: false)
|
||||
failed_uploads = []
|
||||
files = []
|
||||
|
||||
@ -446,7 +446,11 @@ class DmsfFileRevision < ApplicationRecord
|
||||
value = value.except('blank')
|
||||
_, v = value.first
|
||||
# We need a symbols here
|
||||
result[key] = v&.symbolize_keys
|
||||
result[key] = if v.key?('file') && v['file'].blank?
|
||||
nil
|
||||
else
|
||||
v&.symbolize_keys
|
||||
end
|
||||
else
|
||||
result[key] = value
|
||||
end
|
||||
|
||||
@ -150,7 +150,7 @@ class DmsfFileRevisionTest < RedmineDmsf::Test::UnitTest
|
||||
|
||||
def test_workflow_tooltip
|
||||
@revision2.set_workflow @wf1.id, 'start'
|
||||
assert_equal 'John Smith', @revision2.workflow_tooltip
|
||||
assert_equal @jsmith.name, @revision2.workflow_tooltip
|
||||
end
|
||||
|
||||
def test_version
|
||||
@ -302,4 +302,19 @@ class DmsfFileRevisionTest < RedmineDmsf::Test::UnitTest
|
||||
assert h.is_a?(Hash)
|
||||
assert_equal 'atoken', h['90'][:token]
|
||||
end
|
||||
|
||||
def test_params_to_hash_empty_attachment
|
||||
parameters = ActionController::Parameters.new({
|
||||
'78': 'A',
|
||||
'90': {
|
||||
'blank': '',
|
||||
'1': {
|
||||
'file': ''
|
||||
}
|
||||
}
|
||||
})
|
||||
h = DmsfFileRevision.params_to_hash(parameters)
|
||||
assert h.is_a?(Hash)
|
||||
assert_nil h['90']
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user