Stronger direct upload model specs
This commit is contained in:
@@ -29,9 +29,6 @@ class Image < ActiveRecord::Base
|
||||
|
||||
validate :validate_image_dimensions, if: -> { attachment.present? && attachment.dirty? }
|
||||
|
||||
after_create :redimension_using_origin_styles
|
||||
after_save :remove_cached_image, if: -> { valid? && persisted? && cached_attachment.present? }
|
||||
|
||||
def set_cached_attachment_from_attachment(prefix)
|
||||
self.cached_attachment = if Paperclip::Attachment.default_options[:storage] == :filesystem
|
||||
attachment.path
|
||||
@@ -60,13 +57,8 @@ class Image < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
def redimension_using_origin_styles
|
||||
attachment.reprocess!
|
||||
end
|
||||
|
||||
def imageable_class
|
||||
imageable_type.constantize if imageable_type.present?
|
||||
end
|
||||
@@ -102,10 +94,6 @@ class Image < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def remove_cached_image
|
||||
File.delete(cached_attachment) if File.exists?(cached_attachment)
|
||||
end
|
||||
|
||||
def attachment_of_valid_content_type?
|
||||
attachment.present? && imageable_accepted_content_types.include?(attachment_content_type)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user