]> projects.mako.cc - selectricity/blobdiff - vendor/plugins/attachment_fu/test/test_helper.rb
Added some minor TODO's for increased user funcitonality. Change email, beautify...
[selectricity] / vendor / plugins / attachment_fu / test / test_helper.rb
index 66a0b72dcb51a717e46ab98bd88c6558cae5d697..5fe613188198182f1d74bf17ae99137927986717 100644 (file)
@@ -1,10 +1,10 @@
 $:.unshift(File.dirname(__FILE__) + '/../lib')
 
 ENV['RAILS_ENV'] = 'test'
+ENV['RAILS_ROOT'] ||= File.dirname(__FILE__) + '/../../../..'
 
 require 'test/unit'
-require File.expand_path(File.join(File.dirname(__FILE__), '../../../../config/environment.rb'))
-require 'breakpoint'
+require File.expand_path(File.join(ENV['RAILS_ROOT'], 'config/environment.rb'))
 require 'active_record/fixtures'
 require 'action_controller/test_process'
 
@@ -87,6 +87,14 @@ class Test::Unit::TestCase #:nodoc:
       end
     end
 
+    def upload_merb_file(options = {})
+      use_temp_file options[:filename] do |file|
+        att = attachment_model.create :uploaded_data => {"size" => file.size, "content_type" => options[:content_type] || 'image/png', "filename" => file, 'tempfile' => fixture_file_upload(file, options[:content_type] || 'image/png')}
+        att.reload unless att.new_record?
+        return att
+      end
+    end
+    
     def use_temp_file(fixture_filename)
       temp_path = File.join('/tmp', File.basename(fixture_filename))
       FileUtils.mkdir_p File.join(fixture_path, 'tmp')

Benjamin Mako Hill || Want to submit a patch?