paperclip 2.2.9.2 → 2.3.0

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.

@@ -44,7 +44,7 @@ end
44
44
  # documentation for Paperclip::ClassMethods for more useful information.
45
45
  module Paperclip
46
46
 
47
- VERSION = "2.2.9.2"
47
+ VERSION = "2.3.0"
48
48
 
49
49
  class << self
50
50
  # Provides configurability to Paperclip. There are a number of options available, such as:
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Paperclip
2
3
  # The Attachment class manages the files for a given attachment. It saves
3
4
  # when the model saves, deletes when the model is destroyed, and processes
@@ -76,7 +77,7 @@ module Paperclip
76
77
  return nil if uploaded_file.nil?
77
78
 
78
79
  @queued_for_write[:original] = uploaded_file.to_tempfile
79
- instance_write(:file_name, uploaded_file.original_filename.strip.gsub(/[^\w\d\.\-]+/, '_'))
80
+ instance_write(:file_name, uploaded_file.original_filename.strip.gsub(/[^A-Za-z\d\.\-_]+/, '_'))
80
81
  instance_write(:content_type, uploaded_file.content_type.to_s.strip)
81
82
  instance_write(:file_size, uploaded_file.size.to_i)
82
83
  instance_write(:updated_at, Time.now)
@@ -30,7 +30,7 @@ module Paperclip
30
30
  protected
31
31
 
32
32
  def responds?
33
- methods = @subject.instance_methods
33
+ methods = @subject.instance_methods.map(&:to_s)
34
34
  methods.include?("#{@attachment_name}") &&
35
35
  methods.include?("#{@attachment_name}=") &&
36
36
  methods.include?("#{@attachment_name}?")
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'test/helper'
2
3
 
3
4
  class Dummy
@@ -486,12 +487,10 @@ class AttachmentTest < Test::Unit::TestCase
486
487
  rebuild_model
487
488
  @instance = Dummy.new
488
489
  @attachment = Paperclip::Attachment.new(:avatar, @instance)
489
- @file = File.new(File.join(File.dirname(__FILE__),
490
- "fixtures",
491
- "5k.png"), 'rb')
490
+ @file = File.new(File.join(File.dirname(__FILE__), "fixtures", "5k.png"), 'rb')
492
491
  end
493
492
 
494
- teardown do
493
+ teardown do
495
494
  @file.close
496
495
  Paperclip::Attachment.default_options.merge!(@old_defaults)
497
496
  end
@@ -508,13 +507,13 @@ class AttachmentTest < Test::Unit::TestCase
508
507
  assert_equal "/avatars/original/missing.png", @attachment.url
509
508
  assert_equal "/avatars/blah/missing.png", @attachment.url(:blah)
510
509
  end
511
-
510
+
512
511
  should "return nil as path when no file assigned" do
513
512
  assert @attachment.to_file.nil?
514
513
  assert_equal nil, @attachment.path
515
514
  assert_equal nil, @attachment.path(:blah)
516
515
  end
517
-
516
+
518
517
  context "with a file assigned in the database" do
519
518
  setup do
520
519
  @attachment.stubs(:instance_read).with(:file_name).returns("5k.png")
@@ -533,7 +532,7 @@ class AttachmentTest < Test::Unit::TestCase
533
532
  should "make sure the updated_at mtime is in the url if it is defined" do
534
533
  assert_match %r{#{Time.now.to_i}$}, @attachment.url(:blah)
535
534
  end
536
-
535
+
537
536
  should "make sure the updated_at mtime is NOT in the url if false is passed to the url method" do
538
537
  assert_no_match %r{#{Time.now.to_i}$}, @attachment.url(:blah, false)
539
538
  end
@@ -549,12 +548,12 @@ class AttachmentTest < Test::Unit::TestCase
549
548
  end
550
549
 
551
550
  should "return the proper path when filename has a single .'s" do
552
- assert_equal "./test/../tmp/avatars/dummies/original/#{@instance.id}/5k.png", @attachment.path
551
+ assert_equal File.expand_path("./test/../tmp/avatars/dummies/original/#{@instance.id}/5k.png"), File.expand_path(@attachment.path)
553
552
  end
554
553
 
555
554
  should "return the proper path when filename has multiple .'s" do
556
- @attachment.stubs(:instance_read).with(:file_name).returns("5k.old.png")
557
- assert_equal "./test/../tmp/avatars/dummies/original/#{@instance.id}/5k.old.png", @attachment.path
555
+ @attachment.stubs(:instance_read).with(:file_name).returns("5k.old.png")
556
+ assert_equal File.expand_path("./test/../tmp/avatars/dummies/original/#{@instance.id}/5k.old.png"), File.expand_path(@attachment.path)
558
557
  end
559
558
 
560
559
  context "when expecting three styles" do
@@ -77,7 +77,7 @@ class GeometryTest < Test::Unit::TestCase
77
77
  should "make sure the modifier gets passed during transformation_to" do
78
78
  assert @src = Paperclip::Geometry.parse("123x456")
79
79
  assert @dst = Paperclip::Geometry.parse("123x456>")
80
- assert_equal "123x456>", @src.transformation_to(@dst).to_s
80
+ assert_equal ["123x456>", nil], @src.transformation_to(@dst)
81
81
  end
82
82
 
83
83
  should "generate correct ImageMagick formatting string for W-formatted string" do
@@ -1,6 +1,5 @@
1
1
  require 'rubygems'
2
2
  require 'test/unit'
3
- gem 'thoughtbot-shoulda', ">= 2.9.0"
4
3
  require 'shoulda'
5
4
  require 'mocha'
6
5
  require 'tempfile'
@@ -40,7 +39,7 @@ def reset_class class_name
40
39
  end
41
40
 
42
41
  def reset_table table_name, &block
43
- block ||= lambda{ true }
42
+ block ||= lambda { |table| true }
44
43
  ActiveRecord::Base.connection.create_table :dummies, {:force => true}, &block
45
44
  end
46
45
 
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.9.2
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Yurek