fixes image specs

This commit is contained in:
rgarcia
2017-10-06 14:01:03 +02:00
parent b4d494ce24
commit 9a31c97a20
2 changed files with 8 additions and 2 deletions

View File

@@ -19,7 +19,9 @@ class DirectUpload
if @resource_type.present? && @resource_relation.present? && (@attachment.present? || @cached_attachment.present?)
@resource = @resource_type.constantize.find_or_initialize_by(id: @resource_id)
if @resource.respond_to?(:images) && !@attachment.content_type.match(/pdf/)
#Refactor
if @resource.respond_to?(:images) &&
(@attachment.present? && !@attachment.content_type.match(/pdf/)) || @cached_attachment.present?
@relation = @resource.images.send("build", relation_attributtes)
elsif @resource.class.reflections[@resource_relation].macro == :has_one
@relation = @resource.send("build_#{resource_relation}", relation_attributtes)