paperclip 4.1.0 → 4.1.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of paperclip might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d56fec1091044497580e29573ce29fcf2f67ecc9
4
- data.tar.gz: d54575168a2aa162c760bae6a3a0a8246db6566b
3
+ metadata.gz: b280fe3ddac312ba397836a6dbb268f3119b741a
4
+ data.tar.gz: 9034cfd55c882ef8c2b50ac8e98ccbcd212c746a
5
5
  SHA512:
6
- metadata.gz: debcaa74f90f8d01bab69a66b721e3b15bc1532584afb3be685259c4a7b565041362fe30df0fda7d747974c3e4195af3cf372bcbf7253e2f729c2cff8934eaf7
7
- data.tar.gz: a80c28c4168be7c12d20b11f2de4b077756f4b4bf46bbd005d53e142aa0e61f769a16f8872847853500b43256b6444071c824dde06d475f2823c17f1402c2536
6
+ metadata.gz: 4def9d053ea08b067da60d48e548bdaeaedd2e8c1e82d3b8228857d253313ea105484d9c894edab7803d4a08569b7fc44d69a05fd221c3e8b234004075ec46be
7
+ data.tar.gz: d7694572fa8b724c945496299fc916c2e410acf617de7272e7c03218da1140eb8cfc67736a2c02c16afde04b957ad1626ef815a14b2a7c59591c3de5a67ededa
@@ -17,8 +17,10 @@ gemfile:
17
17
  - gemfiles/3.1.gemfile
18
18
  - gemfiles/3.2.gemfile
19
19
  - gemfiles/4.0.gemfile
20
+ - gemfiles/4.1.gemfile
20
21
 
21
22
  matrix:
23
+ fast_finish: true
22
24
  allow_failures:
23
25
  - rvm: jruby-19mode
24
26
  - rvm: rbx-19mode
@@ -26,3 +28,5 @@ matrix:
26
28
  exclude:
27
29
  - rvm: 1.9.2
28
30
  gemfile: gemfiles/4.0.gemfile
31
+ - rvm: 1.9.2
32
+ gemfile: gemfiles/4.1.gemfile
data/Appraisals CHANGED
@@ -17,3 +17,8 @@ appraise "4.0" do
17
17
  gem "rails", "~> 4.0.0"
18
18
  gem "paperclip", :path => "../"
19
19
  end
20
+
21
+ appraise "4.1" do
22
+ gem "rails", "~> 4.1.0.beta"
23
+ gem "paperclip", :path => "../"
24
+ end
data/Gemfile CHANGED
@@ -7,3 +7,10 @@ gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
7
7
 
8
8
  gem 'pry', :platform => :ruby
9
9
  gem 'pry-byebug', :platform => :ruby
10
+
11
+ # Hinting at development dependencies
12
+ # Prevents bundler from taking a long-time to resolve
13
+ group :development, :test do
14
+ gem 'mime-types', '~> 1.16'
15
+ gem 'builder', '~> 3.1.4'
16
+ end
data/NEWS CHANGED
@@ -1,3 +1,14 @@
1
+ New in 4.1.1:
2
+
3
+ * Improvement: Add defauly translations for spoof validation
4
+ * Bug Fix: Don't check for spoofs if the file hasn't changed
5
+ * Bug Fix: Callback chain terminator is different in Rails 4.1, remove warnings
6
+ * Improvement: Fixed various Ruby warnings
7
+ * Bug Fix: Give bundler a hint, so it doesn't run forever on a fresh bundle
8
+ * Improvement: Documentation fixes
9
+ * Improvement: Allow travis-ci to finish-fast
10
+
11
+
1
12
  New in 4.1.0:
2
13
 
3
14
  * Improvement: Add :content_type_mappings to correct for missing spoof types
data/README.md CHANGED
@@ -64,7 +64,7 @@ Paperclip is distributed as a gem, which is how it should be used in your app.
64
64
  Include the gem in your Gemfile:
65
65
 
66
66
  ```ruby
67
- gem "paperclip", "~> 3.0"
67
+ gem "paperclip", "~> 4.1"
68
68
  ```
69
69
 
70
70
  If you're still using Rails 2.3.x, you should do this instead:
@@ -527,7 +527,7 @@ _NOTE: Because processors operate by turning the original attachment into the
527
527
  styles, no processors will be run if there are no styles defined._
528
528
 
529
529
  If you're interested in caching your thumbnail's width, height and size in the
530
- database, take a look at the [paperclip-meta](https://github.com/y8/paperclip-meta) gem.
530
+ database, take a look at the [paperclip-meta](https://github.com/teeparham/paperclip-meta) gem.
531
531
 
532
532
  Also, if you're interested in generating the thumbnail on-the-fly, you might want
533
533
  to look into the [attachment_on_the_fly](https://github.com/drpentode/Attachment-on-the-Fly) gem.
@@ -0,0 +1,11 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "jruby-openssl", :platform=>:jruby
6
+ gem "activerecord-jdbcsqlite3-adapter", :platform=>:jruby
7
+ gem "sqlite3", :platform=>:ruby
8
+ gem "rails", "~> 4.1.0.beta"
9
+ gem "paperclip", :path=>"../"
10
+
11
+ gemspec :path=>"../"
@@ -7,7 +7,7 @@ module Paperclip
7
7
 
8
8
  module Defining
9
9
  def define_paperclip_callbacks(*callbacks)
10
- define_callbacks(*[callbacks, {:terminator => "result == false"}].flatten)
10
+ define_callbacks(*[callbacks, {:terminator => callback_terminator}].flatten)
11
11
  callbacks.each do |callback|
12
12
  eval <<-end_callbacks
13
13
  def before_#{callback}(*args, &blk)
@@ -19,6 +19,16 @@ module Paperclip
19
19
  end_callbacks
20
20
  end
21
21
  end
22
+
23
+ private
24
+
25
+ def callback_terminator
26
+ if ::ActiveSupport::VERSION::STRING >= '4.1'
27
+ lambda { |target, result| result == false }
28
+ else
29
+ 'result == false'
30
+ end
31
+ end
22
32
  end
23
33
 
24
34
  module Running
@@ -79,7 +79,8 @@ module Paperclip
79
79
  end
80
80
 
81
81
  def add_required_validations
82
- @klass.validates_media_type_spoof_detection @name
82
+ name = @name
83
+ @klass.validates_media_type_spoof_detection name, :if => ->{ send(name).dirty? }
83
84
  end
84
85
 
85
86
  def add_active_record_callbacks
@@ -2,6 +2,7 @@ en:
2
2
  errors:
3
3
  messages:
4
4
  in_between: "must be in between %{min} and %{max}"
5
+ spoofed_media_type: "has an extension that does not match its contents"
5
6
 
6
7
  number:
7
8
  human:
@@ -1,3 +1,3 @@
1
1
  module Paperclip
2
- VERSION = "4.1.0" unless defined? Paperclip::VERSION
2
+ VERSION = "4.1.1" unless defined? Paperclip::VERSION
3
3
  end
@@ -6,7 +6,42 @@ class MediaTypeSpoofDetectionValidatorTest < Test::Unit::TestCase
6
6
  @dummy = Dummy.new
7
7
  end
8
8
 
9
+ def build_validator(options = {})
10
+ @validator = Paperclip::Validators::MediaTypeSpoofDetectionValidator.new(options.merge(
11
+ :attributes => :avatar
12
+ ))
13
+ end
14
+
9
15
  should "be on the attachment without being explicitly added" do
10
16
  assert Dummy.validators_on(:avatar).any?{ |validator| validator.kind == :media_type_spoof_detection }
11
17
  end
18
+
19
+ should "return default error message for spoofed media type" do
20
+ build_validator
21
+ file = File.new(fixture_file("5k.png"), "rb")
22
+ @dummy.avatar.assign(file)
23
+
24
+ detector = mock("detector", :spoofed? => true)
25
+ Paperclip::MediaTypeSpoofDetector.stubs(:using).returns(detector)
26
+ @validator.validate(@dummy)
27
+
28
+ assert_equal "has an extension that does not match its contents", @dummy.errors[:avatar].first
29
+ end
30
+
31
+ should "run when attachment is dirty" do
32
+ build_validator
33
+ file = File.new(fixture_file("5k.png"), "rb")
34
+ @dummy.avatar.assign(file)
35
+ Paperclip::MediaTypeSpoofDetector.stubs(:using).returns(stub(:spoofed? => false))
36
+
37
+ @dummy.valid?
38
+
39
+ assert_received(Paperclip::MediaTypeSpoofDetector, :using){|e| e.once }
40
+ end
41
+
42
+ should "not run when attachment is not dirty" do
43
+ Paperclip::MediaTypeSpoofDetector.stubs(:using).never
44
+ @dummy.valid?
45
+ assert_received(Paperclip::MediaTypeSpoofDetector, :using){|e| e.never }
46
+ end
12
47
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperclip
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0
4
+ version: 4.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Yurek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-07 00:00:00.000000000 Z
11
+ date: 2014-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -358,6 +358,7 @@ files:
358
358
  - gemfiles/3.1.gemfile
359
359
  - gemfiles/3.2.gemfile
360
360
  - gemfiles/4.0.gemfile
361
+ - gemfiles/4.1.gemfile
361
362
  - lib/generators/paperclip/USAGE
362
363
  - lib/generators/paperclip/paperclip_generator.rb
363
364
  - lib/generators/paperclip/templates/paperclip_migration.rb.erb