Commit 488ffd25 by Jon Yurek

Removed support for Rails 2.0.*, ensured support for 2.1.2

parent d8f45ee0
......@@ -312,7 +312,12 @@ module Paperclip
types = [options.delete(:content_type)].flatten
validates_each(:"#{name}_content_type", options) do |record, attr, value|
unless types.any?{|t| t === value }
record.errors.add(:"#{name}_content_type", :inclusion, :default => options[:message], :value => value)
if record.errors.method(:add).arity == -2
message = options[:message] || "is not one of #{types.join(", ")}"
record.errors.add(:"#{name}_content_type", message)
else
record.errors.add(:"#{name}_content_type", :inclusion, :default => options[:message], :value => value)
end
end
end
end
......
module Paperclip
# This module is intended as a compatability shim for the differences in
# callbacks between Rails 2.0 and Rails 2.1.
module CallbackCompatability
module Rails20
def self.included(base)
base.extend(Defining)
base.send(:include, Running)
puts "Including Rails 2.0 Compatability"
end
module Defining
def define_paperclip_callbacks(*args)
end
end
module Running
def run_paperclip_callbacks(callback, opts = nil, &blk)
end
end
end
module Rails21
def self.included(base)
base.extend(Defining)
......
......@@ -104,8 +104,10 @@ module Paperclip
end
end
class ActionController::Integration::Session #:nodoc:
include Paperclip::Shoulda
if defined?(ActionController::Integration::Session)
class ActionController::Integration::Session #:nodoc:
include Paperclip::Shoulda
end
end
class Factory
......
......@@ -399,17 +399,12 @@ class AttachmentTest < Test::Unit::TestCase
end
should "cancel the processing if a before_post_process returns false" do
begin
$DEBUG = true
@dummy.expects(:do_before_avatar).never
@dummy.expects(:do_after_avatar).never
@dummy.expects(:do_before_all).with().returns(false)
@dummy.expects(:do_after_all)
Paperclip::Thumbnail.expects(:make).never
@dummy.avatar = @file
ensure
$DEBUG = false
end
end
should "cancel the processing if a before_avatar_post_process returns false" do
......
require 'rubygems'
require 'test/unit'
require 'shoulda'
require 'tempfile'
require 'test/unit'
require 'bundler'
gem 'jferris-mocha'
require 'shoulda'
require 'mocha'
gem 'sqlite3-ruby'
case ENV['RAILS_VERSION']
when '2.1' then
puts "Using Rails 2.1.2"
gem 'activerecord', '2.1.2'
gem 'activesupport', '2.1.2'
gem 'actionpack', '2.1.2'
require 'activerecord'
require 'activesupport'
require 'actionpack'
when '3.0' then
puts "Using Rails 3.0.0.beta3"
gem 'activerecord', '3.0.0.beta3'
gem 'activesupport', '3.0.0.beta3'
gem 'actionpack', '3.0.0.beta3'
require 'active_record'
require 'active_support'
require 'action_pack'
else
puts "Using Rails 2.3.5"
gem 'activerecord', '2.3.5'
gem 'activesupport', '2.3.5'
gem 'actionpack', '2.3.5'
require 'active_record'
require 'active_support'
require 'action_pack'
end
require 'activerecord'
require 'activesupport'
require 'actionpack'
begin
require 'ruby-debug'
rescue LoadError
puts "ruby-debug not loaded"
rescue LoadError => e
puts "debugger disabled"
end
ROOT = File.join(File.dirname(__FILE__), '..')
......
......@@ -41,34 +41,24 @@ class PaperclipTest < Test::Unit::TestCase
end
context "Calling Paperclip.run and logging" do
setup do
should "log the command when :log_command is true" do
Paperclip.options[:image_magick_path] = nil
Paperclip.options[:command_path] = nil
Paperclip.stubs(:bit_bucket).returns("/dev/null")
Paperclip.stubs(:log)
Paperclip.stubs(:"`").with("this is the command 2>/dev/null")
end
should "log the command when :log_command is true" do
Paperclip.expects(:log).with("this is the command 2>/dev/null")
Paperclip.expects(:"`").with("this is the command 2>/dev/null")
Paperclip.options[:log_command] = true
Paperclip.run("this","is the command")
assert_received(Paperclip, :log) do |p|
p.with("this is the command 2>/dev/null")
end
assert_received(Paperclip, :`) do |p|
p.with("this is the command 2>/dev/null")
end
end
should "not log the command when :log_command is false" do
Paperclip.options[:image_magick_path] = nil
Paperclip.options[:command_path] = nil
Paperclip.stubs(:bit_bucket).returns("/dev/null")
Paperclip.expects(:log).with("this is the command 2>/dev/null").never
Paperclip.expects(:"`").with("this is the command 2>/dev/null")
Paperclip.options[:log_command] = false
Paperclip.run("this","is the command")
assert_received(Paperclip, :log) do |p|
p.with("this is the command 2>/dev/null").never
end
assert_received(Paperclip, :`) do |p|
p.with("this is the command 2>/dev/null")
end
end
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