Commit b3f26a69 by Jon Yurek

Merge branch 'master' of git@github.com:thoughtbot/paperclip

parents ac86bb9d e430afe4
......@@ -44,7 +44,7 @@ end
# documentation for Paperclip::ClassMethods for more useful information.
module Paperclip
VERSION = "2.2.9.2"
VERSION = "2.3.0"
class << self
# Provides configurability to Paperclip. There are a number of options available, such as:
......
# encoding: utf-8
module Paperclip
# The Attachment class manages the files for a given attachment. It saves
# when the model saves, deletes when the model is destroyed, and processes
......@@ -76,7 +77,7 @@ module Paperclip
return nil if uploaded_file.nil?
@queued_for_write[:original] = uploaded_file.to_tempfile
instance_write(:file_name, uploaded_file.original_filename.strip.gsub(/[^\w\d\.\-]+/, '_'))
instance_write(:file_name, uploaded_file.original_filename.strip.gsub(/[^A-Za-z\d\.\-_]+/, '_'))
instance_write(:content_type, uploaded_file.content_type.to_s.strip)
instance_write(:file_size, uploaded_file.size.to_i)
instance_write(:updated_at, Time.now)
......
......@@ -30,7 +30,7 @@ module Paperclip
protected
def responds?
methods = @subject.instance_methods
methods = @subject.instance_methods.map(&:to_s)
methods.include?("#{@attachment_name}") &&
methods.include?("#{@attachment_name}=") &&
methods.include?("#{@attachment_name}?")
......
......@@ -2,7 +2,7 @@
Gem::Specification.new do |s|
s.name = %q{paperclip}
s.version = "2.2.9.2"
s.version = "2.3.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Jon Yurek"]
......
# encoding: utf-8
require 'test/helper'
class Dummy
......@@ -498,12 +499,10 @@ class AttachmentTest < Test::Unit::TestCase
rebuild_model
@instance = Dummy.new
@attachment = Paperclip::Attachment.new(:avatar, @instance)
@file = File.new(File.join(File.dirname(__FILE__),
"fixtures",
"5k.png"), 'rb')
@file = File.new(File.join(File.dirname(__FILE__), "fixtures", "5k.png"), 'rb')
end
teardown do
teardown do
@file.close
Paperclip::Attachment.default_options.merge!(@old_defaults)
end
......@@ -520,13 +519,13 @@ class AttachmentTest < Test::Unit::TestCase
assert_equal "/avatars/original/missing.png", @attachment.url
assert_equal "/avatars/blah/missing.png", @attachment.url(:blah)
end
should "return nil as path when no file assigned" do
assert @attachment.to_file.nil?
assert_equal nil, @attachment.path
assert_equal nil, @attachment.path(:blah)
end
context "with a file assigned in the database" do
setup do
@attachment.stubs(:instance_read).with(:file_name).returns("5k.png")
......@@ -545,7 +544,7 @@ class AttachmentTest < Test::Unit::TestCase
should "make sure the updated_at mtime is in the url if it is defined" do
assert_match %r{#{Time.now.to_i}$}, @attachment.url(:blah)
end
should "make sure the updated_at mtime is NOT in the url if false is passed to the url method" do
assert_no_match %r{#{Time.now.to_i}$}, @attachment.url(:blah, false)
end
......@@ -561,12 +560,12 @@ class AttachmentTest < Test::Unit::TestCase
end
should "return the proper path when filename has a single .'s" do
assert_equal "./test/../tmp/avatars/dummies/original/#{@instance.id}/5k.png", @attachment.path
assert_equal File.expand_path("./test/../tmp/avatars/dummies/original/#{@instance.id}/5k.png"), File.expand_path(@attachment.path)
end
should "return the proper path when filename has multiple .'s" do
@attachment.stubs(:instance_read).with(:file_name).returns("5k.old.png")
assert_equal "./test/../tmp/avatars/dummies/original/#{@instance.id}/5k.old.png", @attachment.path
@attachment.stubs(:instance_read).with(:file_name).returns("5k.old.png")
assert_equal File.expand_path("./test/../tmp/avatars/dummies/original/#{@instance.id}/5k.old.png"), File.expand_path(@attachment.path)
end
context "when expecting three styles" do
......
......@@ -77,7 +77,7 @@ class GeometryTest < Test::Unit::TestCase
should "make sure the modifier gets passed during transformation_to" do
assert @src = Paperclip::Geometry.parse("123x456")
assert @dst = Paperclip::Geometry.parse("123x456>")
assert_equal "123x456>", @src.transformation_to(@dst).to_s
assert_equal ["123x456>", nil], @src.transformation_to(@dst)
end
should "generate correct ImageMagick formatting string for W-formatted string" do
......
require 'rubygems'
require 'test/unit'
gem 'thoughtbot-shoulda', ">= 2.9.0"
require 'shoulda'
require 'mocha'
require 'tempfile'
......@@ -40,7 +39,7 @@ def reset_class class_name
end
def reset_table table_name, &block
block ||= lambda{ true }
block ||= lambda { |table| true }
ActiveRecord::Base.connection.create_table :dummies, {:force => true}, &block
end
......
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