Changeset 1201
- Timestamp:
- 07/12/08 16:29:28 (5 months ago)
- Files:
-
- trunk/app/models/image.rb (modified) (1 diff)
- trunk/vendor/plugins/acts_as_attachment/README (deleted)
- trunk/vendor/plugins/acts_as_attachment/generators/attachment_model/USAGE (deleted)
- trunk/vendor/plugins/acts_as_attachment/generators/attachment_model/attachment_model_generator.rb (deleted)
- trunk/vendor/plugins/acts_as_attachment/generators/attachment_model/templates/fixtures.yml (deleted)
- trunk/vendor/plugins/acts_as_attachment/generators/attachment_model/templates/migration.rb (deleted)
- trunk/vendor/plugins/acts_as_attachment/generators/attachment_model/templates/model.rb (deleted)
- trunk/vendor/plugins/acts_as_attachment/generators/attachment_model/templates/unit_test.rb (deleted)
- trunk/vendor/plugins/acts_as_attachment/init.rb (deleted)
- trunk/vendor/plugins/acts_as_attachment/install.rb (deleted)
- trunk/vendor/plugins/acts_as_attachment/lib/db_file.rb (deleted)
- trunk/vendor/plugins/acts_as_attachment/lib/technoweenie/acts_as_attachment.rb (deleted)
- trunk/vendor/plugins/acts_as_attachment/lib/technoweenie/acts_as_attachment/class_methods.rb (deleted)
- trunk/vendor/plugins/acts_as_attachment/lib/technoweenie/acts_as_attachment/db_file_methods.rb (deleted)
- trunk/vendor/plugins/acts_as_attachment/lib/technoweenie/acts_as_attachment/file_system_methods.rb (deleted)
- trunk/vendor/plugins/acts_as_attachment/lib/technoweenie/acts_as_attachment/instance_methods.rb (deleted)
- trunk/vendor/plugins/acts_as_attachment/meta.yml (deleted)
- trunk/vendor/plugins/acts_as_attachment/test/content_type_test.rb (deleted)
- trunk/vendor/plugins/acts_as_attachment/test/fixtures/attachment.rb (deleted)
- trunk/vendor/plugins/acts_as_attachment/test/fixtures/base_attachment_tests.rb (deleted)
- trunk/vendor/plugins/acts_as_attachment/test/image_attachment_test.rb (deleted)
- trunk/vendor/plugins/acts_as_attachment/test/schema.rb (deleted)
- trunk/vendor/plugins/acts_as_attachment/test/validation_test.rb (deleted)
- trunk/vendor/plugins/attachment_fu (added)
- trunk/vendor/plugins/attachment_fu/CHANGELOG (added)
- trunk/vendor/plugins/attachment_fu/README (added)
- trunk/vendor/plugins/attachment_fu/Rakefile (moved) (moved from trunk/vendor/plugins/acts_as_attachment/Rakefile) (2 diffs)
- trunk/vendor/plugins/attachment_fu/amazon_s3.yml.tpl (added)
- trunk/vendor/plugins/attachment_fu/init.rb (added)
- trunk/vendor/plugins/attachment_fu/install.rb (added)
- trunk/vendor/plugins/attachment_fu/lib (added)
- trunk/vendor/plugins/attachment_fu/lib/geometry.rb (added)
- trunk/vendor/plugins/attachment_fu/lib/technoweenie (added)
- trunk/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu (added)
- trunk/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb (added)
- trunk/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends (added)
- trunk/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/db_file_backend.rb (added)
- trunk/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/file_system_backend.rb (added)
- trunk/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/s3_backend.rb (added)
- trunk/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors (added)
- trunk/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/core_image_processor.rb (added)
- trunk/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/gd2_processor.rb (added)
- trunk/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/image_science_processor.rb (added)
- trunk/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/mini_magick_processor.rb (added)
- trunk/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/rmagick_processor.rb (added)
- trunk/vendor/plugins/attachment_fu/test (added)
- trunk/vendor/plugins/attachment_fu/test/backends (added)
- trunk/vendor/plugins/attachment_fu/test/backends/db_file_test.rb (added)
- trunk/vendor/plugins/attachment_fu/test/backends/file_system_test.rb (moved) (moved from trunk/vendor/plugins/acts_as_attachment/test/file_attachment_test.rb) (2 diffs)
- trunk/vendor/plugins/attachment_fu/test/backends/remote (added)
- trunk/vendor/plugins/attachment_fu/test/backends/remote/s3_test.rb (added)
- trunk/vendor/plugins/attachment_fu/test/base_attachment_tests.rb (added)
- trunk/vendor/plugins/attachment_fu/test/basic_test.rb (added)
- trunk/vendor/plugins/attachment_fu/test/database.yml (moved) (moved from trunk/vendor/plugins/acts_as_attachment/test/database.yml) (2 diffs)
- trunk/vendor/plugins/attachment_fu/test/extra_attachment_test.rb (moved) (moved from trunk/vendor/plugins/acts_as_attachment/test/attachment_test.rb) (3 diffs)
- trunk/vendor/plugins/attachment_fu/test/fixtures (added)
- trunk/vendor/plugins/attachment_fu/test/fixtures/attachment.rb (added)
- trunk/vendor/plugins/attachment_fu/test/fixtures/files (added)
- trunk/vendor/plugins/attachment_fu/test/fixtures/files/fake (added)
- trunk/vendor/plugins/attachment_fu/test/fixtures/files/fake/rails.png (moved) (moved from trunk/vendor/plugins/acts_as_attachment/test/fixtures/files/fake/rails.png)
- trunk/vendor/plugins/attachment_fu/test/fixtures/files/foo.txt (moved) (moved from trunk/vendor/plugins/acts_as_attachment/test/fixtures/files/foo.txt)
- trunk/vendor/plugins/attachment_fu/test/fixtures/files/rails.png (moved) (moved from trunk/vendor/plugins/acts_as_attachment/test/fixtures/files/rails.png)
- trunk/vendor/plugins/attachment_fu/test/geometry_test.rb (added)
- trunk/vendor/plugins/attachment_fu/test/processors (added)
- trunk/vendor/plugins/attachment_fu/test/processors/core_image_test.rb (added)
- trunk/vendor/plugins/attachment_fu/test/processors/gd2_test.rb (added)
- trunk/vendor/plugins/attachment_fu/test/processors/image_science_test.rb (added)
- trunk/vendor/plugins/attachment_fu/test/processors/mini_magick_test.rb (added)
- trunk/vendor/plugins/attachment_fu/test/processors/rmagick_test.rb (added)
- trunk/vendor/plugins/attachment_fu/test/schema.rb (added)
- trunk/vendor/plugins/attachment_fu/test/test_helper.rb (moved) (moved from trunk/vendor/plugins/acts_as_attachment/test/abstract_unit.rb) (5 diffs)
- trunk/vendor/plugins/attachment_fu/test/validation_test.rb (added)
- trunk/vendor/plugins/attachment_fu/vendor (added)
- trunk/vendor/plugins/attachment_fu/vendor/red_artisan (added)
- trunk/vendor/plugins/attachment_fu/vendor/red_artisan/core_image (added)
- trunk/vendor/plugins/attachment_fu/vendor/red_artisan/core_image/filters (added)
- trunk/vendor/plugins/attachment_fu/vendor/red_artisan/core_image/filters/color.rb (added)
- trunk/vendor/plugins/attachment_fu/vendor/red_artisan/core_image/filters/effects.rb (added)
- trunk/vendor/plugins/attachment_fu/vendor/red_artisan/core_image/filters/perspective.rb (added)
- trunk/vendor/plugins/attachment_fu/vendor/red_artisan/core_image/filters/quality.rb (added)
- trunk/vendor/plugins/attachment_fu/vendor/red_artisan/core_image/filters/scale.rb (added)
- trunk/vendor/plugins/attachment_fu/vendor/red_artisan/core_image/filters/watermark.rb (added)
- trunk/vendor/plugins/attachment_fu/vendor/red_artisan/core_image/processor.rb (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/app/models/image.rb
r1193 r1201 1 1 class Image < ActiveRecord::Base 2 2 belongs_to :show 3 acts_as_attachment :storage => :file_system, :max_size => 300.kilobytes, :content_type => :image, :thumbnails => { :normal => '200>', :thumb => '75' }3 has_attachment :storage => :file_system, :max_size => 300.kilobytes, :content_type => :image, :thumbnails => { :normal => '200>', :thumb => '75' } 4 4 validates_as_attachment 5 5 end trunk/vendor/plugins/attachment_fu/Rakefile
r1193 r1201 6 6 task :default => :test 7 7 8 desc 'Test the a cts_as_attachmentplugin.'8 desc 'Test the attachment_fu plugin.' 9 9 Rake::TestTask.new(:test) do |t| 10 10 t.libs << 'lib' … … 13 13 end 14 14 15 desc 'Generate documentation for the a cts_as_attachmentplugin.'15 desc 'Generate documentation for the attachment_fu plugin.' 16 16 Rake::RDocTask.new(:rdoc) do |rdoc| 17 17 rdoc.rdoc_dir = 'rdoc' trunk/vendor/plugins/attachment_fu/test/backends/file_system_test.rb
r1193 r1201 1 class FileAttachmentTest < Test::Unit::TestCase 1 require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper')) 2 3 class FileSystemTest < Test::Unit::TestCase 2 4 include BaseAttachmentTests 3 5 attachment_model FileAttachment … … 49 51 old_filename = attachment.full_filename 50 52 assert_not_created do 51 attachment.filename = 'rails2.png' 52 attachment.attachment_data = IO.read(File.join(File.dirname(__FILE__), 'fixtures/files/rails.png')) 53 attachment.save 54 assert File.exists?(attachment.full_filename), "#{attachment.full_filename} does not exist" 55 assert !File.exists?(old_filename), "#{old_filename} still exists" 53 use_temp_file 'files/rails.png' do |file| 54 attachment.filename = 'rails2.png' 55 attachment.temp_path = File.join(fixture_path, file) 56 attachment.save! 57 assert File.exists?(attachment.full_filename), "#{attachment.full_filename} does not exist" 58 assert !File.exists?(old_filename), "#{old_filename} still exists" 59 end 56 60 end 57 61 end trunk/vendor/plugins/attachment_fu/test/database.yml
r1193 r1201 1 1 sqlite: 2 2 :adapter: sqlite 3 :dbfile: a cts_as_attachment_plugin.sqlite.db3 :dbfile: attachment_fu_plugin.sqlite.db 4 4 sqlite3: 5 5 :adapter: sqlite3 6 :dbfile: a cts_as_attachment_plugin.sqlite3.db6 :dbfile: attachment_fu_plugin.sqlite3.db 7 7 postgresql: 8 8 :adapter: postgresql 9 9 :username: postgres 10 10 :password: postgres 11 :database: a cts_as_attachment_plugin_test11 :database: attachment_fu_plugin_test 12 12 :min_messages: ERROR 13 13 mysql: … … 16 16 :username: rails 17 17 :password: 18 :database: a cts_as_attachment_plugin_test18 :database: attachment_fu_plugin_test trunk/vendor/plugins/attachment_fu/test/extra_attachment_test.rb
r1193 r1201 1 require File.join(File.dirname(__FILE__), 'abstract_unit') 2 3 class DbAttachmentTest < Test::Unit::TestCase 4 include BaseAttachmentTests 5 attachment_model Attachment 6 7 def test_should_call_after_attachment_saved(klass = Attachment) 8 attachment_model Attachment 9 attachment_model.saves = 0 10 assert_created do 11 upload_file :filename => '/files/rails.png' 12 end 13 assert_equal 1, attachment_model.saves 14 end 15 16 test_against_subclass :test_should_call_after_attachment_saved, Attachment 17 end 1 require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper')) 18 2 19 3 class OrphanAttachmentTest < Test::Unit::TestCase … … 55 39 attachment = upload_file :filename => '/files/rails.png' 56 40 57 assert_raise Technoweenie::A ctsAsAttachment::ThumbnailError do58 attachment.create_or_update_thumbnail( 'thumb', 50, 50)41 assert_raise Technoweenie::AttachmentFu::ThumbnailError do 42 attachment.create_or_update_thumbnail(attachment.create_temp_file, 'thumb', 50, 50) 59 43 end 60 44 end … … 63 47 attachment = upload_file :filename => '/files/rails.png' 64 48 65 assert_raise Technoweenie::A ctsAsAttachment::ThumbnailError do66 attachment.create_or_update_thumbnail( 'thumb', 'x50')49 assert_raise Technoweenie::AttachmentFu::ThumbnailError do 50 attachment.create_or_update_thumbnail(attachment.create_temp_file, 'thumb', 'x50') 67 51 end 68 52 end trunk/vendor/plugins/attachment_fu/test/test_helper.rb
r1193 r1201 1 1 $:.unshift(File.dirname(__FILE__) + '/../lib') 2 2 3 ENV['RAILS_ENV'] = 'test' 4 ENV['RAILS_ROOT'] ||= File.dirname(__FILE__) + '/../../../..' 5 3 6 require 'test/unit' 4 require File.expand_path(File.join(File.dirname(__FILE__), '../../../../config/environment.rb')) 5 require 'breakpoint' 7 require File.expand_path(File.join(ENV['RAILS_ROOT'], 'config/environment.rb')) 6 8 require 'active_record/fixtures' 7 9 require 'action_controller/test_process' … … 9 11 config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml')) 10 12 ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log") 11 ActiveRecord::Base.establish_connection(config[ENV['DB'] || 'sqlite']) 13 14 db_adapter = ENV['DB'] 15 16 # no db passed, try one of these fine config-free DBs before bombing. 17 db_adapter ||= 18 begin 19 require 'rubygems' 20 require 'sqlite' 21 'sqlite' 22 rescue MissingSourceFile 23 begin 24 require 'sqlite3' 25 'sqlite3' 26 rescue MissingSourceFile 27 end 28 end 29 30 if db_adapter.nil? 31 raise "No DB Adapter selected. Pass the DB= option to pick one, or install Sqlite or Sqlite3." 32 end 33 34 ActiveRecord::Base.establish_connection(config[db_adapter]) 12 35 13 36 load(File.dirname(__FILE__) + "/schema.rb") 14 37 15 Test::Unit::TestCase.fixture_path = File.dirname(__FILE__) + "/fixtures /"38 Test::Unit::TestCase.fixture_path = File.dirname(__FILE__) + "/fixtures" 16 39 $LOAD_PATH.unshift(Test::Unit::TestCase.fixture_path) 17 40 … … 27 50 28 51 def setup 52 Attachment.saves = 0 53 DbFile.transaction { [Attachment, FileAttachment, OrphanAttachment, MinimalAttachment, DbFile].each { |klass| klass.delete_all } } 54 attachment_model self.class.attachment_model 55 end 56 57 def teardown 29 58 FileUtils.rm_rf File.join(File.dirname(__FILE__), 'files') 30 attachment_model self.class.attachment_model31 59 end 32 60 … … 53 81 protected 54 82 def upload_file(options = {}) 55 att = attachment_model.create :uploaded_data => fixture_file_upload(options[:filename], options[:content_type] || 'image/png') 56 att.reload unless att.new_record? 57 att 83 use_temp_file options[:filename] do |file| 84 att = attachment_model.create :uploaded_data => fixture_file_upload(file, options[:content_type] || 'image/png') 85 att.reload unless att.new_record? 86 return att 87 end 58 88 end 59 89 90 def use_temp_file(fixture_filename) 91 temp_path = File.join('/tmp', File.basename(fixture_filename)) 92 FileUtils.mkdir_p File.join(fixture_path, 'tmp') 93 FileUtils.cp File.join(fixture_path, fixture_filename), File.join(fixture_path, temp_path) 94 yield temp_path 95 ensure 96 FileUtils.rm_rf File.join(fixture_path, 'tmp') 97 end 98 60 99 def assert_created(num = 1) 61 100 assert_difference attachment_model.base_class, :count, num do … … 101 140 102 141 require File.join(File.dirname(__FILE__), 'fixtures/attachment') 103 require File.join(File.dirname(__FILE__), ' fixtures/base_attachment_tests')142 require File.join(File.dirname(__FILE__), 'base_attachment_tests')
