Commit 2e540f89 by Jon Yurek

Fixes failing tests

parent 67580ee3
...@@ -2,7 +2,7 @@ source "https://rubygems.org" ...@@ -2,7 +2,7 @@ source "https://rubygems.org"
gemspec gemspec
gem 'sqlite3', '1.3.8', :platforms => :ruby gem 'sqlite3', '~> 1.3.8', :platforms => :ruby
gem 'jruby-openssl', :platforms => :jruby gem 'jruby-openssl', :platforms => :jruby
gem 'activerecord-jdbcsqlite3-adapter', :platforms => :jruby gem 'activerecord-jdbcsqlite3-adapter', :platforms => :jruby
......
...@@ -3,32 +3,32 @@ require 'spec_helper' ...@@ -3,32 +3,32 @@ require 'spec_helper'
describe Paperclip::MediaTypeSpoofDetector do describe Paperclip::MediaTypeSpoofDetector do
it 'rejects a file that is named .html and identifies as PNG' do it 'rejects a file that is named .html and identifies as PNG' do
file = File.open(fixture_file("5k.png")) file = File.open(fixture_file("5k.png"))
assert Paperclip::MediaTypeSpoofDetector.using(file, "5k.html").spoofed? assert Paperclip::MediaTypeSpoofDetector.using(file, "5k.html", "image/png").spoofed?
end end
it 'does not reject a file that is named .jpg and identifies as PNG' do it 'does not reject a file that is named .jpg and identifies as PNG' do
file = File.open(fixture_file("5k.png")) file = File.open(fixture_file("5k.png"))
assert ! Paperclip::MediaTypeSpoofDetector.using(file, "5k.jpg").spoofed? assert ! Paperclip::MediaTypeSpoofDetector.using(file, "5k.jpg", "image/png").spoofed?
end end
it 'does not reject a file that is named .html and identifies as HTML' do it 'does not reject a file that is named .html and identifies as HTML' do
file = File.open(fixture_file("empty.html")) file = File.open(fixture_file("empty.html"))
assert ! Paperclip::MediaTypeSpoofDetector.using(file, "empty.html").spoofed? assert ! Paperclip::MediaTypeSpoofDetector.using(file, "empty.html", "text/html").spoofed?
end end
it 'does not reject a file that does not have a name' do it 'does not reject a file that does not have a name' do
file = File.open(fixture_file("empty.html")) file = File.open(fixture_file("empty.html"))
assert ! Paperclip::MediaTypeSpoofDetector.using(file, "").spoofed? assert ! Paperclip::MediaTypeSpoofDetector.using(file, "", "").spoofed?
end end
it 'does not reject a file that does have an extension' do it 'does not reject a file that does have an extension' do
file = File.open(fixture_file("empty.html")) file = File.open(fixture_file("empty.html"))
assert ! Paperclip::MediaTypeSpoofDetector.using(file, "data").spoofed? assert ! Paperclip::MediaTypeSpoofDetector.using(file, "data", "").spoofed?
end end
it 'does not reject when the supplied file is an IOAdapter' do it 'does not reject when the supplied file is an IOAdapter' do
adapter = Paperclip.io_adapters.for(File.new(fixture_file("5k.png"))) adapter = Paperclip.io_adapters.for(File.new(fixture_file("5k.png")))
assert ! Paperclip::MediaTypeSpoofDetector.using(adapter, adapter.original_filename).spoofed? assert ! Paperclip::MediaTypeSpoofDetector.using(adapter, adapter.original_filename, adapter.content_type).spoofed?
end end
it 'does not reject when the extension => content_type is in :content_type_mappings' do it 'does not reject when the extension => content_type is in :content_type_mappings' do
...@@ -38,7 +38,7 @@ describe Paperclip::MediaTypeSpoofDetector do ...@@ -38,7 +38,7 @@ describe Paperclip::MediaTypeSpoofDetector do
file.puts "Certificate!" file.puts "Certificate!"
file.close file.close
adapter = Paperclip.io_adapters.for(File.new(file.path)); adapter = Paperclip.io_adapters.for(File.new(file.path));
assert ! Paperclip::MediaTypeSpoofDetector.using(adapter, adapter.original_filename).spoofed? assert ! Paperclip::MediaTypeSpoofDetector.using(adapter, adapter.original_filename, adapter.content_type).spoofed?
ensure ensure
Paperclip.options[:content_type_mappings] = {} Paperclip.options[:content_type_mappings] = {}
end end
...@@ -49,7 +49,7 @@ describe Paperclip::MediaTypeSpoofDetector do ...@@ -49,7 +49,7 @@ describe Paperclip::MediaTypeSpoofDetector do
assert Paperclip::MediaTypeSpoofDetector.using(file, "empty.html", "image/jpg").spoofed? assert Paperclip::MediaTypeSpoofDetector.using(file, "empty.html", "image/jpg").spoofed?
end end
it "does not reject is content_type is empty but otherwise checks out" do it "does not reject if content_type is empty but otherwise checks out" do
file = File.open(fixture_file("empty.html")) file = File.open(fixture_file("empty.html"))
assert ! Paperclip::MediaTypeSpoofDetector.using(file, "empty.html", "").spoofed? assert ! Paperclip::MediaTypeSpoofDetector.using(file, "empty.html", "").spoofed?
end end
......
...@@ -20,7 +20,7 @@ describe Paperclip do ...@@ -20,7 +20,7 @@ describe Paperclip do
it "saves Cocaine::CommandLine.path that set before" do it "saves Cocaine::CommandLine.path that set before" do
Cocaine::CommandLine.path = "/opt/my_app/bin" Cocaine::CommandLine.path = "/opt/my_app/bin"
Paperclip.run("convert", "stuff") Paperclip.run("convert", "stuff")
assert_equal [Cocaine::CommandLine.path].flatten.include?("/opt/my_app/bin"), true expect(Cocaine::CommandLine.path).to match("/opt/my_app/bin")
end end
it "does not duplicate Cocaine::CommandLine.path on multiple runs" do it "does not duplicate Cocaine::CommandLine.path on multiple runs" do
......
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