Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Rearranged stuff and added a gem build/deploy process. Official relea…

…se of 2.1.0.
  • Loading branch information...
commit c6ccb54d61f487567b73a56a4ef16fc7f3716e97 1 parent c44048d
@jyurek jyurek authored
View
1  .gitignore
@@ -1,2 +1,3 @@
*.swp
tmp
+s3.yml
View
17 Rakefile
@@ -3,6 +3,9 @@ require 'rake/testtask'
require 'rake/rdoctask'
require 'rake/gempackagetask'
+$LOAD_PATH << File.join(File.dirname(__FILE__), 'lib')
+require 'paperclip'
+
desc 'Default: run unit tests.'
task :default => [:clean, :test]
@@ -44,7 +47,7 @@ end
spec = Gem::Specification.new do |s|
s.name = "paperclip"
- s.version = "2.1.0"
+ s.version = Paperclip::VERSION
s.author = "Jon Yurek"
s.email = "jyurek@thoughtbot.com"
s.homepage = "http://www.thoughtbot.com/"
@@ -67,3 +70,15 @@ end
Rake::GemPackageTask.new(spec) do |pkg|
pkg.need_tar = true
end
+
+desc "Release new version"
+task :release => [:test, :sync_docs, :gem] do
+ require 'rubygems'
+ require 'rubyforge'
+ r = RubyForge.new
+ r.login
+ r.add_release spec.rubyforge_project,
+ spec.name,
+ spec.version,
+ File.join("pkg", "#{spec.name}-#{spec.version}.gem")
+end
View
2  init.rb
@@ -1,3 +1 @@
require File.join(File.dirname(__FILE__), "lib", "paperclip")
-ActiveRecord::Base.extend( Paperclip::ClassMethods )
-File.send :include, Paperclip::Upfile
View
9 lib/paperclip.rb
@@ -35,6 +35,9 @@
# The base module that gets included in ActiveRecord::Base.
module Paperclip
+
+ VERSION = "2.1.0"
+
class << self
# Provides configurability to Paperclip. There are a number of options available, such as:
# * whiny_thumbnails: Will raise an error if Paperclip cannot process thumbnails of
@@ -198,3 +201,9 @@ def destroy_attached_files
end
end
+
+# Set it all up.
+if Object.const_defined?("ActiveRecord")
+ ActiveRecord::Base.send(:include, Paperclip)
+ File.send(:include, Paperclip::Upfile)
+end
View
18 test/test_attachment.rb
@@ -81,6 +81,7 @@ class AttachmentTest < Test::Unit::TestCase
Paperclip::Attachment.default_options.merge!({
:path => ":rails_root/tmp/:attachment/:class/:style/:id/:basename.:extension"
})
+ FileUtils.rm_rf("tmp")
@instance = stub
@instance.stubs(:id).returns(41)
@instance.stubs(:class).returns(Dummy)
@@ -172,6 +173,23 @@ class AttachmentTest < Test::Unit::TestCase
should "still have its #file attribute not be nil" do
assert ! @attachment.file.nil?
end
+
+ context "and deleted" do
+ setup do
+ @existing_names = @attachment.styles.keys.collect do |style|
+ @attachment.path(style)
+ end
+ @instance.expects(:[]=).with(:test_file_name, nil)
+ @instance.expects(:[]=).with(:test_content_type, nil)
+ @instance.expects(:[]=).with(:test_file_size, nil)
+ @attachment.assign nil
+ @attachment.save
+ end
+
+ should "delete the files" do
+ @existing_names.each{|f| assert ! File.exists?(f) }
+ end
+ end
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.