Add asset validation on wopi creation

Missing file
This commit is contained in:
Jure Grabnar 2019-03-21 10:00:54 +01:00
parent d9a9045658
commit bc9eff2ef5

View file

@ -47,6 +47,8 @@ class Asset < ApplicationRecord
# This could cause some problems if you create empty asset and want to # This could cause some problems if you create empty asset and want to
# assign it to result # assign it to result
validate :step_or_result_or_repository_asset_value validate :step_or_result_or_repository_asset_value
validate :name_should_not_be_empty_without_extension,
on: :wopi_file_creation
belongs_to :created_by, belongs_to :created_by,
foreign_key: 'created_by_id', foreign_key: 'created_by_id',
@ -517,6 +519,15 @@ class Asset < ApplicationRecord
end end
end end
def name_should_not_be_empty_without_extension
unless file.original_filename[0..-6].present?
errors.add(
:file,
I18n.t('general.text.not_blank')
)
end
end
def cache def cache
fetched_file = file.fetch fetched_file = file.fetch
file_content = fetched_file.read file_content = fetched_file.read