Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix some errors on shoulda's matchers

  • Loading branch information...
commit d3a742755e3b0ffefcd73abe68fb193fd7cdd143 1 parent da5d716
@sikachu sikachu authored
View
4 lib/paperclip/matchers/validate_attachment_presence_matcher.rb
@@ -39,14 +39,14 @@ def description
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
View
11 lib/paperclip/matchers/validate_attachment_size_matcher.rb
@@ -18,7 +18,6 @@ def validate_attachment_size name
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 @@ def passes_validation_with_size(new_size)
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
Please sign in to comment.
Something went wrong with that request. Please try again.