paperclip 2.2.5 → 2.2.6

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.

@@ -43,7 +43,7 @@ end
43
43
  # documentation for Paperclip::ClassMethods for more useful information.
44
44
  module Paperclip
45
45
 
46
- VERSION = "2.2.5"
46
+ VERSION = "2.2.6"
47
47
 
48
48
  class << self
49
49
  # Provides configurability to Paperclip. There are a number of options available, such as:
@@ -191,31 +191,24 @@ module Paperclip
191
191
  # necessary.
192
192
  def self.interpolations
193
193
  @interpolations ||= {
194
- :rails_root => lambda{|attachment,style| RAILS_ROOT },
195
- :rails_env => lambda{|attachment,style| RAILS_ENV },
196
- :class => lambda do |attachment,style|
197
- attachment.instance.class.name.underscore.pluralize
198
- end,
199
- :basename => lambda do |attachment,style|
200
- attachment.original_filename.gsub(/#{File.extname(attachment.original_filename)}$/, "")
201
- end,
202
- :extension => lambda do |attachment,style|
203
- ((style = attachment.styles[style]) && style[:format]) ||
204
- File.extname(attachment.original_filename).gsub(/^\.+/, "")
205
- end,
206
- :id => lambda{|attachment,style| attachment.instance.id },
207
- :id_partition => lambda do |attachment, style|
208
- ("%09d" % attachment.instance.id).scan(/\d{3}/).join("/")
209
- end,
210
- :attachment => lambda{|attachment,style| attachment.name.to_s.downcase.pluralize },
211
- :style => lambda{|attachment,style| style || attachment.default_style },
212
- :relative_root => lambda do |attachment,style|
213
- if ActionController::AbstractRequest.respond_to?(:relative_url_root)
214
- ActionController::AbstractRequest.relative_url_root
215
- elsif ActionController::Base.respond_to?(:relative_url_root)
216
- ActionController::Base.relative_url_root
217
- end
218
- end
194
+ :rails_root => lambda{|attachment,style| RAILS_ROOT },
195
+ :rails_env => lambda{|attachment,style| RAILS_ENV },
196
+ :class => lambda do |attachment,style|
197
+ attachment.instance.class.name.underscore.pluralize
198
+ end,
199
+ :basename => lambda do |attachment,style|
200
+ attachment.original_filename.gsub(/#{File.extname(attachment.original_filename)}$/, "")
201
+ end,
202
+ :extension => lambda do |attachment,style|
203
+ ((style = attachment.styles[style]) && style[:format]) ||
204
+ File.extname(attachment.original_filename).gsub(/^\.+/, "")
205
+ end,
206
+ :id => lambda{|attachment,style| attachment.instance.id },
207
+ :id_partition => lambda do |attachment, style|
208
+ ("%09d" % attachment.instance.id).scan(/\d{3}/).join("/")
209
+ end,
210
+ :attachment => lambda{|attachment,style| attachment.name.to_s.downcase.pluralize },
211
+ :style => lambda{|attachment,style| style || attachment.default_style },
219
212
  }
220
213
  end
221
214
 
@@ -206,11 +206,11 @@ module Paperclip
206
206
 
207
207
  def find_credentials creds
208
208
  case creds
209
- when File:
209
+ when File
210
210
  YAML.load_file(creds.path)
211
- when String:
211
+ when String
212
212
  YAML.load_file(creds)
213
- when Hash:
213
+ when Hash
214
214
  creds
215
215
  else
216
216
  raise ArgumentError, "Credentials are not a path, file, or hash."
@@ -9,6 +9,7 @@ module Paperclip
9
9
  # you're testing (that is, UserTest is the test for the User model), and
10
10
  # will load that class for testing purposes.
11
11
  module Shoulda
12
+ include Matchers
12
13
  # This will test whether you have defined your attachment correctly by
13
14
  # checking for all the required fields exist after the definition of the
14
15
  # attachment.
@@ -64,5 +65,4 @@ end
64
65
 
65
66
  class Test::Unit::TestCase #:nodoc:
66
67
  extend Paperclip::Shoulda
67
- include Paperclip::Shoulda::Matchers
68
68
  end
@@ -106,36 +106,6 @@ class AttachmentTest < Test::Unit::TestCase
106
106
  end
107
107
  end
108
108
 
109
- context "An attachment with a :relative_root interpolation" do
110
- setup do
111
- rebuild_model :url => ":relative_root/:id.png"
112
- @dummy = Dummy.new
113
- @dummy.stubs(:id).returns(1024)
114
- @dummy.avatar = StringIO.new(".")
115
-
116
- ActionController::Base.stubs(:respond_to?).with(:relative_url_root).returns(false)
117
- ActionController::Base.stubs(:relative_url_root).returns("/base")
118
- ActionController::AbstractRequest.stubs(:respond_to?).with(:relative_url_root).returns(false)
119
- ActionController::AbstractRequest.stubs(:relative_url_root).returns("/request")
120
- end
121
-
122
- should "return the proper path when the path is nil" do
123
- assert_equal "/1024.png", @dummy.avatar.url(:original, false)
124
- end
125
-
126
- should "return the proper path when using Rails < 2.1" do
127
- ActionController::AbstractRequest.expects(:respond_to?).with(:relative_url_root).returns(true)
128
- ActionController::AbstractRequest.expects(:relative_url_root).returns("/request")
129
- assert_equal "/request/1024.png", @dummy.avatar.url(:original, false)
130
- end
131
-
132
- should "return the proper path when using Rails >= 2.1" do
133
- ActionController::Base.expects(:respond_to?).with(:relative_url_root).returns(true)
134
- ActionController::Base.expects(:relative_url_root).returns("/base")
135
- assert_equal "/base/1024.png", @dummy.avatar.url(:original, false)
136
- end
137
- end
138
-
139
109
  context "An attachment with :convert_options" do
140
110
  setup do
141
111
  rebuild_model :styles => {
@@ -9,7 +9,6 @@ gem 'sqlite3-ruby'
9
9
 
10
10
  require 'active_record'
11
11
  require 'active_support'
12
- require 'action_controller'
13
12
  begin
14
13
  require 'ruby-debug'
15
14
  rescue LoadError
@@ -5,7 +5,7 @@ class HaveAttachedFileMatcherTest < Test::Unit::TestCase
5
5
  setup do
6
6
  @dummy_class = reset_class "Dummy"
7
7
  reset_table "dummies"
8
- @matcher = have_attached_file(:avatar)
8
+ @matcher = self.class.have_attached_file(:avatar)
9
9
  end
10
10
 
11
11
  should "reject a class with no attachment" do
@@ -8,7 +8,7 @@ class ValidateAttachmentContentTypeMatcherTest < Test::Unit::TestCase
8
8
  end
9
9
  @dummy_class = reset_class "Dummy"
10
10
  @dummy_class.has_attached_file :avatar
11
- @matcher = validate_attachment_content_type(:avatar).
11
+ @matcher = self.class.validate_attachment_content_type(:avatar).
12
12
  allowing(%w(image/png image/jpeg)).
13
13
  rejecting(%w(audio/mp3 application/octet-stream))
14
14
  end
@@ -6,7 +6,7 @@ class ValidateAttachmentPresenceMatcherTest < Test::Unit::TestCase
6
6
  reset_table("dummies"){|d| d.string :avatar_file_name }
7
7
  @dummy_class = reset_class "Dummy"
8
8
  @dummy_class.has_attached_file :avatar
9
- @matcher = validate_attachment_presence(:avatar)
9
+ @matcher = self.class.validate_attachment_presence(:avatar)
10
10
  end
11
11
 
12
12
  should "reject a class with no validation" do
@@ -11,7 +11,7 @@ class ValidateAttachmentSizeMatcherTest < Test::Unit::TestCase
11
11
  end
12
12
 
13
13
  context "of limited size" do
14
- setup{ @matcher = validate_attachment_size(:avatar).in(256..1024) }
14
+ setup{ @matcher = self.class.validate_attachment_size(:avatar).in(256..1024) }
15
15
 
16
16
  should "reject a class with no validation" do
17
17
  assert_rejects @matcher, @dummy_class
@@ -34,7 +34,7 @@ class ValidateAttachmentSizeMatcherTest < Test::Unit::TestCase
34
34
  end
35
35
 
36
36
  context "validates_attachment_size with infinite range" do
37
- setup{ @matcher = validate_attachment_size(:avatar) }
37
+ setup{ @matcher = self.class.validate_attachment_size(:avatar) }
38
38
 
39
39
  should "accept a class with an upper limit" do
40
40
  @dummy_class.validates_attachment_size :avatar, :less_than => 1
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperclip
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.5
4
+ version: 2.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Yurek
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-11 00:00:00 -05:00
12
+ date: 2009-02-17 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -24,7 +24,7 @@ dependencies:
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: thoughtbot-shoulda
27
- type: :runtime
27
+ type: :development
28
28
  version_requirement:
29
29
  version_requirements: !ruby/object:Gem::Requirement
30
30
  requirements:
@@ -34,7 +34,7 @@ dependencies:
34
34
  version:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: mocha
37
- type: :runtime
37
+ type: :development
38
38
  version_requirement:
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements: