paperclip 2.7.2 → 2.7.4

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.

@@ -13,6 +13,7 @@ Feature: Rails integration
13
13
  """
14
14
  has_attached_file :attachment
15
15
  """
16
+ And I add attr_accessible to a Rails 3.2 application
16
17
  And I start the rails application
17
18
  When I go to the new user page
18
19
  And I fill in "Name" with "something"
@@ -30,6 +31,7 @@ Feature: Rails integration
30
31
  :path => "/:attachment/:id/:style/:filename",
31
32
  :s3_credentials => Rails.root.join("config/s3.yml")
32
33
  """
34
+ And I add attr_accessible to a Rails 3.2 application
33
35
  And I write to "config/s3.yml" with:
34
36
  """
35
37
  bucket: paperclip
@@ -6,6 +6,7 @@ Feature: Rake tasks
6
6
  And I run a paperclip generator to add a paperclip "attachment" to the "User" model
7
7
  And I run a migration
8
8
  And I add the paperclip rake task to a Rails 2.3 application
9
+ And I add attr_accessible to a Rails 3.2 application
9
10
  And I add this snippet to the User model:
10
11
  """
11
12
  has_attached_file :attachment, :path => ":rails_root/public/system/:attachment/:style/:filename"
@@ -17,6 +18,7 @@ Feature: Rake tasks
17
18
  has_attached_file :attachment, :path => ":rails_root/public/system/:attachment/:style/:filename",
18
19
  :styles => { :medium => "200x200#" }
19
20
  """
21
+ And I add attr_accessible to a Rails 3.2 application
20
22
  And I upload the fixture "5k.png"
21
23
  Then the attachment "medium/5k.png" should have a dimension of 200x200
22
24
  When I modify my attachment definition to:
@@ -24,6 +26,7 @@ Feature: Rake tasks
24
26
  has_attached_file :attachment, :path => ":rails_root/public/system/:attachment/:style/:filename",
25
27
  :styles => { :medium => "100x100#" }
26
28
  """
29
+ And I add attr_accessible to a Rails 3.2 application
27
30
  When I successfully run `bundle exec rake paperclip:refresh:thumbnails CLASS=User --trace`
28
31
  Then the attachment "original/5k.png" should exist
29
32
  And the attachment "medium/5k.png" should have a dimension of 100x100
@@ -44,6 +47,7 @@ Feature: Rake tasks
44
47
  has_attached_file :attachment, :path => ":rails_root/public/system/:attachment/:style/:filename",
45
48
  :styles => { :medium => "200x200#" }
46
49
  """
50
+ And I add attr_accessible to a Rails 3.2 application
47
51
  When I successfully run `bundle exec rake paperclip:refresh:missing_styles --trace`
48
52
  Then the attachment file "original/5k.png" should exist
49
53
  And the attachment file "medium/5k.png" should exist
@@ -58,6 +62,7 @@ Feature: Rake tasks
58
62
  has_attached_file :attachment, :path => ":rails_root/public/system/:attachment/:style/:filename"
59
63
  validates_attachment_size :attachment, :less_than => 10.kilobytes
60
64
  """
65
+ And I add attr_accessible to a Rails 3.2 application
61
66
  And I successfully run `bundle exec rake paperclip:clean CLASS=User --trace`
62
67
  Then the attachment file "original/5k.png" should exist
63
68
  But the attachment file "original/12k.png" should not exist
@@ -71,11 +71,7 @@ Given /^I update my user view to include the attachment$/ do
71
71
  end
72
72
 
73
73
  Given /^I add this snippet to the User model:$/ do |snippet|
74
- file_name = "app/models/user.rb"
75
- in_current_dir do
76
- content = File.read(file_name)
77
- File.open(file_name, 'w') { |f| f << content.sub(/end\Z/, "#{snippet}\nend") }
78
- end
74
+ insert_snippet_into_file("app/models/user.rb", snippet)
79
75
  end
80
76
 
81
77
  Given /^I start the rails application$/ do
@@ -113,6 +109,12 @@ Given /^I update my application to use Bundler$/ do
113
109
  end
114
110
  end
115
111
 
112
+ Given /^I add attr_accessible to a Rails 3.2 application$/ do
113
+ if framework_version?("3.2")
114
+ insert_snippet_into_file("app/models/user.rb", "attr_accessible :attachment\n")
115
+ end
116
+ end
117
+
116
118
  Given /^I add the paperclip rake task to a Rails 2.3 application$/ do
117
119
  if framework_version?("2.3")
118
120
  require 'fileutils'
@@ -157,6 +159,14 @@ When /^I comment out the gem "([^"]*)" from the Gemfile$/ do |gemname|
157
159
  end
158
160
 
159
161
  module FileHelpers
162
+ def insert_snippet_into_file(file_name, snippet)
163
+ in_current_dir do
164
+ content = File.read(file_name)
165
+ File.open(file_name, 'w') { |f| f << content.sub(/end\Z/, "#{snippet}\nend") }
166
+ content = File.read(file_name)
167
+ end
168
+ end
169
+
160
170
  def append_to(path, contents)
161
171
  in_current_dir do
162
172
  File.open(path, "a") do |file|
@@ -14,6 +14,7 @@ module Paperclip
14
14
  :convert_options => {},
15
15
  :default_style => :original,
16
16
  :default_url => "/:attachment/:style/missing.png",
17
+ :escape_url => true,
17
18
  :restricted_characters => /[&$+,\/:;=?@<>\[\]\{\}\|\\\^~%# ]/,
18
19
  :hash_data => ":class/:attachment/:id/:style/:updated_at",
19
20
  :hash_digest => "SHA1",
@@ -62,6 +63,7 @@ module Paperclip
62
63
  # +preserve_files+ - whether to keep files on the filesystem when deleting to clearing the attachment. Defaults to false
63
64
  # +interpolator+ - the object used to interpolate filenames and URLs. Defaults to Paperclip::Interpolations
64
65
  # +url_generator+ - the object used to generate URLs, using the interpolator. Defaults to Paperclip::UrlGenerator
66
+ # +escape_url+ - Perform URI escaping to URLs. Defaults to true
65
67
  def initialize(name, instance, options = {})
66
68
  @name = name
67
69
  @instance = instance
@@ -149,7 +151,7 @@ module Paperclip
149
151
  # +#new(Paperclip::Attachment, options_hash)+
150
152
  # +#for(style_name, options_hash)+
151
153
  def url(style_name = default_style, options = {})
152
- default_options = {:timestamp => @options[:use_timestamp], :escape => true}
154
+ default_options = {:timestamp => @options[:use_timestamp], :escape => @options[:escape_url]}
153
155
 
154
156
  if options == true || options == false # Backwards compatibility.
155
157
  @url_generator.for(style_name, default_options.merge(:timestamp => options))
@@ -1,3 +1,3 @@
1
1
  module Paperclip
2
- VERSION = "2.7.2" unless defined? Paperclip::VERSION
2
+ VERSION = "2.7.4" unless defined? Paperclip::VERSION
3
3
  end
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
22
22
 
23
23
  s.add_dependency('activerecord', '>= 2.3.0')
24
24
  s.add_dependency('activesupport', '>= 2.3.2')
25
- s.add_dependency('cocaine', '>= 0.0.2')
25
+ s.add_dependency('cocaine', '~> 0.3.0')
26
26
  s.add_dependency('mime-types')
27
27
 
28
28
  s.add_development_dependency('shoulda')
@@ -95,6 +95,28 @@ class AttachmentTest < Test::Unit::TestCase
95
95
  assert mock_url_generator_builder.has_generated_url_with_options?(:escape => true, :timestamp => true)
96
96
  end
97
97
 
98
+ should "pass the option :escape => true if :escape_url is true and :escape is not passed" do
99
+ mock_url_generator_builder = MockUrlGeneratorBuilder.new
100
+ attachment = Paperclip::Attachment.new(:name,
101
+ :instance,
102
+ :url_generator => mock_url_generator_builder,
103
+ :escape_url => true)
104
+
105
+ attachment.url(:style_name)
106
+ assert mock_url_generator_builder.has_generated_url_with_options?(:escape => true)
107
+ end
108
+
109
+ should "pass the option :escape => false if :escape_url is false and :escape is not passed" do
110
+ mock_url_generator_builder = MockUrlGeneratorBuilder.new
111
+ attachment = Paperclip::Attachment.new(:name,
112
+ :instance,
113
+ :url_generator => mock_url_generator_builder,
114
+ :escape_url => false)
115
+
116
+ attachment.url(:style_name)
117
+ assert mock_url_generator_builder.has_generated_url_with_options?(:escape => false)
118
+ end
119
+
98
120
  should "return the path based on the url by default" do
99
121
  @attachment = attachment :url => "/:class/:id/:basename"
100
122
  @model = @attachment.instance
@@ -76,6 +76,8 @@ class ThumbnailTest < Test::Unit::TestCase
76
76
  should "let us know when a command isn't found versus a processing error" do
77
77
  old_path = ENV['PATH']
78
78
  begin
79
+ Cocaine::CommandLine.path = ''
80
+ Paperclip.options[:command_path] = ''
79
81
  ENV['PATH'] = ''
80
82
  assert_raises(Paperclip::CommandNotFoundError) do
81
83
  @thumb.make
@@ -202,6 +204,8 @@ class ThumbnailTest < Test::Unit::TestCase
202
204
  should "let us know when a command isn't found versus a processing error" do
203
205
  old_path = ENV['PATH']
204
206
  begin
207
+ Cocaine::CommandLine.path = ''
208
+ Paperclip.options[:command_path] = ''
205
209
  ENV['PATH'] = ''
206
210
  assert_raises(Paperclip::CommandNotFoundError) do
207
211
  @thumb.make
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.7.2
4
+ version: 2.7.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-19 00:00:00.000000000 Z
12
+ date: 2012-11-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -48,17 +48,17 @@ dependencies:
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  none: false
50
50
  requirements:
51
- - - ! '>='
51
+ - - ~>
52
52
  - !ruby/object:Gem::Version
53
- version: 0.0.2
53
+ version: 0.3.0
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  none: false
58
58
  requirements:
59
- - - ! '>='
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: 0.0.2
61
+ version: 0.3.0
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: mime-types
64
64
  requirement: !ruby/object:Gem::Requirement