test/helper.rb in paperclip-2.2.8 vs test/helper.rb in paperclip-2.2.9.1

- old
+ new

@@ -15,20 +15,19 @@ puts "ruby-debug not loaded" end ROOT = File.join(File.dirname(__FILE__), '..') RAILS_ROOT = ROOT +RAILS_ENV = "test" $LOAD_PATH << File.join(ROOT, 'lib') $LOAD_PATH << File.join(ROOT, 'lib', 'paperclip') require File.join(ROOT, 'lib', 'paperclip.rb') require 'shoulda_macros/paperclip' -ENV['RAILS_ENV'] ||= 'test' - FIXTURES_DIR = File.join(File.dirname(__FILE__), "fixtures") config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml')) ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log") ActiveRecord::Base.establish_connection(config['test']) @@ -69,14 +68,33 @@ has_attached_file :avatar, options end end def temporary_rails_env(new_env) - old_env = defined?(RAILS_ENV) ? RAILS_ENV : nil + old_env = Object.const_defined?("RAILS_ENV") ? RAILS_ENV : nil silence_warnings do Object.const_set("RAILS_ENV", new_env) end yield silence_warnings do Object.const_set("RAILS_ENV", old_env) end +end + +class FakeModel + attr_accessor :avatar_file_name, + :avatar_file_size, + :avatar_last_updated, + :avatar_content_type, + :id + + def errors + @errors ||= [] + end + + def run_callbacks name, *args + end +end + +def attachment options + Paperclip::Attachment.new(:avatar, FakeModel.new, options) end