Skip to content
This repository has been archived by the owner on Dec 29, 2021. It is now read-only.

Commit

Permalink
All tests passing on Windows (if you have 'file.exe' installed).
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Yurek committed Aug 10, 2010
1 parent 00c0daf commit 32b9a28
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions lib/paperclip/thumbnail.rb
Expand Up @@ -71,8 +71,8 @@ def make
def transformation_command
scale, crop = @current_geometry.transformation_to(@target_geometry, crop?)
trans = []
trans << "-resize" << "'#{scale}'" unless scale.nil? || scale.empty?
trans << "-crop" << "'#{crop}'" << "+repage" if crop
trans << "-resize" << %["#{scale}"] unless scale.nil? || scale.empty?
trans << "-crop" << %["#{crop}"] << "+repage" if crop
trans
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/paperclip/upfile.rb
Expand Up @@ -17,7 +17,7 @@ def content_type
when "csv", "xml", "css" then "text/#{type}"
else
# On BSDs, `file` doesn't give a result code of 1 if the file doesn't exist.
content_type = (Paperclip.run("file", "--mime-type :file", :file => self.path).split(':').last.strip rescue "application/x-#{type}")
content_type = (Paperclip.run("file", "-b --mime-type :file", :file => self.path).split(':').last.strip rescue "application/x-#{type}")
content_type = "application/x-#{type}" if content_type.match(/\(.*?\)/)
content_type
end
Expand Down
8 changes: 4 additions & 4 deletions test/paperclip_test.rb
Expand Up @@ -11,19 +11,19 @@ class PaperclipTest < Test::Unit::TestCase
should "execute the right command with :image_magick_path" do
Paperclip.options[:image_magick_path] = "/usr/bin"
Paperclip.expects(:log).with(includes('[DEPRECATION]'))
Paperclip.expects(:log).with("/usr/bin/convert 'one.jpg' 'two.jpg'")
Paperclip::CommandLine.expects(:"`").with("/usr/bin/convert 'one.jpg' 'two.jpg'")
Paperclip.expects(:log).with(regexp_matches(%r{/usr/bin/convert ['"]one.jpg['"] ['"]two.jpg['"]}))
Paperclip::CommandLine.expects(:"`").with(regexp_matches(%r{/usr/bin/convert ['"]one.jpg['"] ['"]two.jpg['"]}))
Paperclip.run("convert", ":one :two", :one => "one.jpg", :two => "two.jpg")
end

should "execute the right command with :command_path" do
Paperclip.options[:command_path] = "/usr/bin"
Paperclip::CommandLine.expects(:"`").with("/usr/bin/convert 'one.jpg' 'two.jpg'")
Paperclip::CommandLine.expects(:"`").with(regexp_matches(%r{/usr/bin/convert ['"]one.jpg['"] ['"]two.jpg['"]}))
Paperclip.run("convert", ":one :two", :one => "one.jpg", :two => "two.jpg")
end

should "execute the right command with no path" do
Paperclip::CommandLine.expects(:"`").with("convert 'one.jpg' 'two.jpg'")
Paperclip::CommandLine.expects(:"`").with(regexp_matches(%r{convert ['"]one.jpg['"] ['"]two.jpg['"]}))
Paperclip.run("convert", ":one :two", :one => "one.jpg", :two => "two.jpg")
end

Expand Down
6 changes: 3 additions & 3 deletions test/thumbnail_test.rb
Expand Up @@ -92,7 +92,7 @@ class ThumbnailTest < Test::Unit::TestCase

should "send the right command to convert when sent #make" do
Paperclip::CommandLine.expects(:"`").with do |arg|
arg.match %r{convert '#{File.expand_path(@thumb.file.path)}\[0\]' -resize 'x50' -crop '100x50\+114\+0' \+repage '.*?'}
arg.match %r{convert ["']#{File.expand_path(@thumb.file.path)}\[0\]["'] -resize ["']x50["'] -crop ["']100x50\+114\+0["'] \+repage ["'].*?["']}
end
@thumb.make
end
Expand All @@ -116,7 +116,7 @@ class ThumbnailTest < Test::Unit::TestCase

should "send the right command to convert when sent #make" do
Paperclip::CommandLine.expects(:"`").with do |arg|
arg.match %r{convert -strip '#{File.expand_path(@thumb.file.path)}\[0\]' -resize 'x50' -crop '100x50\+114\+0' \+repage '.*?'}
arg.match %r{convert -strip ["']#{File.expand_path(@thumb.file.path)}\[0\]["'] -resize ["']x50["'] -crop ["']100x50\+114\+0["'] \+repage ["'].*?["']}
end
@thumb.make
end
Expand Down Expand Up @@ -154,7 +154,7 @@ class ThumbnailTest < Test::Unit::TestCase

should "send the right command to convert when sent #make" do
Paperclip::CommandLine.expects(:"`").with do |arg|
arg.match %r{convert '#{File.expand_path(@thumb.file.path)}\[0\]' -resize 'x50' -crop '100x50\+114\+0' \+repage -strip -depth 8 '.*?'}
arg.match %r{convert ["']#{File.expand_path(@thumb.file.path)}\[0\]["'] -resize ["']x50["'] -crop ["']100x50\+114\+0["'] \+repage -strip -depth 8 ["'].*?["']}
end
@thumb.make
end
Expand Down

0 comments on commit 32b9a28

Please sign in to comment.