Commit d3a74275 by Prem Sichanugrist

Fix some errors on shoulda's matchers

parent da5d716b
......@@ -39,14 +39,14 @@ module Paperclip
def error_when_not_valid?
@subject.send(@attachment_name).assign(nil)
@subject.valid?
not @subject.errors[:"#{@attachment_name}_file_name"].blank?
@subject.errors[:"#{@attachment_name}"].present?
end
def no_error_when_valid?
@file = StringIO.new(".")
@subject.send(@attachment_name).assign(@file)
@subject.valid?
@subject.errors[:"#{@attachment_name}_file_name"].blank?
@subject.errors[:"#{@attachment_name}"].blank?
end
end
end
......
......@@ -18,7 +18,6 @@ module Paperclip
class ValidateAttachmentSizeMatcher
def initialize attachment_name
@attachment_name = attachment_name
@low, @high = 0, (1.0/0)
end
def less_than size
......@@ -76,21 +75,19 @@ module Paperclip
end
def lower_than_low?
not passes_validation_with_size(@low - 1)
@low.nil? || !passes_validation_with_size(@low - 1)
end
def higher_than_low?
passes_validation_with_size(@low + 1)
@low.nil? || passes_validation_with_size(@low + 1)
end
def lower_than_high?
return true if @high == (1.0/0)
passes_validation_with_size(@high - 1)
@high.nil? || @high == Float::INFINITY || passes_validation_with_size(@high - 1)
end
def higher_than_high?
return true if @high == (1.0/0)
not passes_validation_with_size(@high + 1)
@high.nil? || @high == Float::INFINITY || !passes_validation_with_size(@high + 1)
end
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment