Fix warnings seen in delayed_paperclip tests

This commit is contained in:
Vasily Fedoseyev
2022-04-18 20:08:20 +03:00
parent 3a704cc055
commit b98762edca
5 changed files with 17 additions and 13 deletions

View File

@@ -219,6 +219,7 @@ module Paperclip
# Returns true if there are changes that need to be saved.
def dirty?
return false unless defined?(@dirty)
@dirty || false
end
@@ -338,9 +339,11 @@ module Paperclip
# for more details.
def instance_read(attr)
getter = :"#{name}_#{attr}"
if instance_variable_defined?("@_#{getter}")
cached = self.instance_variable_get("@_#{getter}")
return cached if cached
end
responds = instance.respond_to?(getter)
cached = self.instance_variable_get("@_#{getter}")
return cached if cached
instance.send(getter) if responds || attr.to_s == "file_name"
end
@@ -363,13 +366,14 @@ module Paperclip
end
def validate #:nodoc:
return if @validated
self.class.validations.each do |validation|
name, options = validation
error = send(:"validate_#{name}", options) if allow_validation?(options)
errors[name] = error if error
@validated ||= begin
self.class.validations.each do |validation|
name, options = validation
error = send(:"validate_#{name}", options) if allow_validation?(options)
errors[name] = error if error
end
true
end
@validated = true
end
def allow_validation? options #:nodoc:

View File

@@ -45,7 +45,7 @@ module Paperclip
end
def define_paperclip_callbacks(*callbacks)
define_callbacks *callbacks.flatten, CALLBACK_OPTIONS
define_callbacks(*callbacks.flatten, CALLBACK_OPTIONS)
callbacks.map(&:to_sym).each do |callback|
define_singleton_method "before_#{callback}" do |*args, &blk|
set_callback(callback, :before, *args, &blk)

View File

@@ -27,7 +27,7 @@ module Paperclip
file = file.path if file.respond_to? "path"
geometry = begin
Paperclip.run("identify", %Q[-format "%wx%h,%[exif:orientation]" "#{file}"[0]])
rescue PaperclipCommandLineError => e
rescue PaperclipCommandLineError
""
end
parse(geometry) ||

View File

@@ -58,7 +58,7 @@ module Paperclip
end_command
begin
success = Paperclip.run("convert", command.gsub(/\s+/, " "))
_success = Paperclip.run("convert", command.gsub(/\s+/, " "))
rescue PaperclipCommandLineError
raise PaperclipError, "There was an error processing the thumbnail for #{@basename}" if @whiny
end
@@ -90,7 +90,7 @@ module Paperclip
raise PaperclipError, "There was an error processing the thumbnail for #{@basename}" if @whiny
end
magick, type = result.split("\n")
magick, _type = result.split("\n")
if magick == 'PNG'
'-define png:big-depth=16 -define png:color-type=6'
else

View File

@@ -47,7 +47,7 @@ end
if defined? StringIO
class StringIO
attr_accessor :original_filename, :content_type
attr_writer :original_filename, :content_type
def original_filename
@original_filename ||= "stringio.txt"