Commit 2db36782 by S. Humza Shah Committed by Tute Costa

replaced 3 if-not-blank checks with if-present checks (#2230)

* replaced if-not-blank with if-present

an instance of code was testing presence via `!a.blank?`. this is now
replaced with a more readable version: `a.present?`

* replaced 2 if-not-blank checks with if-present checks

* temporarily restrict travis

* reverted travis changes

* readded whitespace
parent 6819fac5
...@@ -349,7 +349,7 @@ module Paperclip ...@@ -349,7 +349,7 @@ module Paperclip
# Returns true if a file has been assigned. # Returns true if a file has been assigned.
def file? def file?
!original_filename.blank? original_filename.present?
end end
alias :present? :file? alias :present? :file?
......
...@@ -18,7 +18,7 @@ module Paperclip ...@@ -18,7 +18,7 @@ module Paperclip
raise "Class #{klass.name} has no attachments specified" raise "Class #{klass.name} has no attachments specified"
end end
if !name.blank? && attachment_names.map(&:to_s).include?(name.to_s) if name.present? && attachment_names.map(&:to_s).include?(name.to_s)
[ name ] [ name ]
else else
attachment_names attachment_names
......
...@@ -1121,7 +1121,7 @@ describe Paperclip::Attachment do ...@@ -1121,7 +1121,7 @@ describe Paperclip::Attachment do
context "with a file assigned but not saved yet" do context "with a file assigned but not saved yet" do
it "clears out any attached files" do it "clears out any attached files" do
@attachment.assign(@file) @attachment.assign(@file)
assert !@attachment.queued_for_write.blank? assert @attachment.queued_for_write.present?
@attachment.clear @attachment.clear
assert @attachment.queued_for_write.blank? assert @attachment.queued_for_write.blank?
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