From e0a7e0fec760ba12c8067a37e10c96f1f05876e2 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Wed, 24 Jun 2026 04:13:16 +0200 Subject: Stage 1 complete: Rails 2.3.5 to Rails 3.2.22.5 upgrade - Converted plugins to gems (Gemfile) - Updated config structure (application.rb, boot.rb, environment.rb) - Converted routes to Rails 3 DSL - Converted named_scope to scope throughout models - Converted find(:all, :conditions) to where() chains - Fixed has_many :order to use ordering scope - Updated session store and secret token configuration - Fixed exception_notification middleware configuration - Patched Ruby 2.4 / Rails 3.2 incompatibilities: - Integer/Float duration arithmetic (ActiveSupport) - Arel visit_Integer for PostgreSQL adapter - create_database String/Integer coercion - ActionController consider_all_requests_local - Migrated taggings schema for acts-as-taggable-on - Replaced dynamic_form gem with custom form_error_messages helper - Fixed Rails 3 block helper syntax (form_for, form_tag, fields_for) - Fixed admin layout yield - Updated test suite for Rails 3 APIs --- vendor/plugins/paperclip/test/.gitignore | 1 - vendor/plugins/paperclip/test/attachment_test.rb | 742 --------------------- vendor/plugins/paperclip/test/fixtures/12k.png | Bin 12093 -> 0 bytes vendor/plugins/paperclip/test/fixtures/50x50.png | Bin 1615 -> 0 bytes vendor/plugins/paperclip/test/fixtures/5k.png | Bin 4456 -> 0 bytes vendor/plugins/paperclip/test/fixtures/bad.png | 1 - vendor/plugins/paperclip/test/fixtures/text.txt | 0 vendor/plugins/paperclip/test/fixtures/twopage.pdf | Bin 8775 -> 0 bytes vendor/plugins/paperclip/test/geometry_test.rb | 168 ----- vendor/plugins/paperclip/test/helper.rb | 82 --- vendor/plugins/paperclip/test/integration_test.rb | 481 ------------- vendor/plugins/paperclip/test/iostream_test.rb | 71 -- .../matchers/have_attached_file_matcher_test.rb | 21 - ...alidate_attachment_content_type_matcher_test.rb | 30 - .../validate_attachment_presence_matcher_test.rb | 21 - .../validate_attachment_size_matcher_test.rb | 50 -- vendor/plugins/paperclip/test/paperclip_test.rb | 233 ------- vendor/plugins/paperclip/test/processor_test.rb | 10 - vendor/plugins/paperclip/test/storage_test.rb | 277 -------- vendor/plugins/paperclip/test/thumbnail_test.rb | 177 ----- 20 files changed, 2365 deletions(-) delete mode 100644 vendor/plugins/paperclip/test/.gitignore delete mode 100644 vendor/plugins/paperclip/test/attachment_test.rb delete mode 100644 vendor/plugins/paperclip/test/fixtures/12k.png delete mode 100644 vendor/plugins/paperclip/test/fixtures/50x50.png delete mode 100644 vendor/plugins/paperclip/test/fixtures/5k.png delete mode 100644 vendor/plugins/paperclip/test/fixtures/bad.png delete mode 100644 vendor/plugins/paperclip/test/fixtures/text.txt delete mode 100644 vendor/plugins/paperclip/test/fixtures/twopage.pdf delete mode 100644 vendor/plugins/paperclip/test/geometry_test.rb delete mode 100644 vendor/plugins/paperclip/test/helper.rb delete mode 100644 vendor/plugins/paperclip/test/integration_test.rb delete mode 100644 vendor/plugins/paperclip/test/iostream_test.rb delete mode 100644 vendor/plugins/paperclip/test/matchers/have_attached_file_matcher_test.rb delete mode 100644 vendor/plugins/paperclip/test/matchers/validate_attachment_content_type_matcher_test.rb delete mode 100644 vendor/plugins/paperclip/test/matchers/validate_attachment_presence_matcher_test.rb delete mode 100644 vendor/plugins/paperclip/test/matchers/validate_attachment_size_matcher_test.rb delete mode 100644 vendor/plugins/paperclip/test/paperclip_test.rb delete mode 100644 vendor/plugins/paperclip/test/processor_test.rb delete mode 100644 vendor/plugins/paperclip/test/storage_test.rb delete mode 100644 vendor/plugins/paperclip/test/thumbnail_test.rb (limited to 'vendor/plugins/paperclip/test') diff --git a/vendor/plugins/paperclip/test/.gitignore b/vendor/plugins/paperclip/test/.gitignore deleted file mode 100644 index b14c5486..00000000 --- a/vendor/plugins/paperclip/test/.gitignore +++ /dev/null @@ -1 +0,0 @@ -debug.log diff --git a/vendor/plugins/paperclip/test/attachment_test.rb b/vendor/plugins/paperclip/test/attachment_test.rb deleted file mode 100644 index 61ab2a22..00000000 --- a/vendor/plugins/paperclip/test/attachment_test.rb +++ /dev/null @@ -1,742 +0,0 @@ -require 'test/helper' - -class Dummy - # This is a dummy class -end - -class AttachmentTest < Test::Unit::TestCase - context "Attachment default_options" do - setup do - rebuild_model - @old_default_options = Paperclip::Attachment.default_options.dup - @new_default_options = @old_default_options.merge({ - :path => "argle/bargle", - :url => "fooferon", - :default_url => "not here.png" - }) - end - - teardown do - Paperclip::Attachment.default_options.merge! @old_default_options - end - - should "be overrideable" do - Paperclip::Attachment.default_options.merge!(@new_default_options) - @new_default_options.keys.each do |key| - assert_equal @new_default_options[key], - Paperclip::Attachment.default_options[key] - end - end - - context "without an Attachment" do - setup do - @dummy = Dummy.new - end - - should "return false when asked exists?" do - assert !@dummy.avatar.exists? - end - end - - context "on an Attachment" do - setup do - @dummy = Dummy.new - @attachment = @dummy.avatar - end - - Paperclip::Attachment.default_options.keys.each do |key| - should "be the default_options for #{key}" do - assert_equal @old_default_options[key], - @attachment.instance_variable_get("@#{key}"), - key - end - end - - context "when redefined" do - setup do - Paperclip::Attachment.default_options.merge!(@new_default_options) - @dummy = Dummy.new - @attachment = @dummy.avatar - end - - Paperclip::Attachment.default_options.keys.each do |key| - should "be the new default_options for #{key}" do - assert_equal @new_default_options[key], - @attachment.instance_variable_get("@#{key}"), - key - end - end - end - end - end - - context "An attachment with similarly named interpolations" do - setup do - rebuild_model :path => ":id.omg/:id-bbq/:idwhat/:id_partition.wtf" - @dummy = Dummy.new - @dummy.stubs(:id).returns(1024) - @file = File.new(File.join(File.dirname(__FILE__), - "fixtures", - "5k.png"), 'rb') - @dummy.avatar = @file - end - - teardown { @file.close } - - should "make sure that they are interpolated correctly" do - assert_equal "1024.omg/1024-bbq/1024what/000/001/024.wtf", @dummy.avatar.path - end - end - - context "An attachment with a :rails_env interpolation" do - setup do - @rails_env = "blah" - @id = 1024 - rebuild_model :path => ":rails_env/:id.png" - @dummy = Dummy.new - @dummy.stubs(:id).returns(@id) - @file = StringIO.new(".") - @dummy.avatar = @file - end - - should "return the proper path" do - temporary_rails_env(@rails_env) { - assert_equal "#{@rails_env}/#{@id}.png", @dummy.avatar.path - } - end - end - - context "An attachment with :convert_options" do - setup do - rebuild_model :styles => { - :thumb => "100x100", - :large => "400x400" - }, - :convert_options => { - :all => "-do_stuff", - :thumb => "-thumbnailize" - } - @dummy = Dummy.new - @dummy.avatar - end - - should "report the correct options when sent #extra_options_for(:thumb)" do - assert_equal "-thumbnailize -do_stuff", @dummy.avatar.send(:extra_options_for, :thumb), @dummy.avatar.convert_options.inspect - end - - should "report the correct options when sent #extra_options_for(:large)" do - assert_equal "-do_stuff", @dummy.avatar.send(:extra_options_for, :large) - end - - before_should "call extra_options_for(:thumb/:large)" do - Paperclip::Attachment.any_instance.expects(:extra_options_for).with(:thumb) - Paperclip::Attachment.any_instance.expects(:extra_options_for).with(:large) - end - end - - context "An attachment with :convert_options that is a proc" do - setup do - rebuild_model :styles => { - :thumb => "100x100", - :large => "400x400" - }, - :convert_options => { - :all => lambda{|i| i.all }, - :thumb => lambda{|i| i.thumb } - } - Dummy.class_eval do - def all; "-all"; end - def thumb; "-thumb"; end - end - @dummy = Dummy.new - @dummy.avatar - end - - should "report the correct options when sent #extra_options_for(:thumb)" do - assert_equal "-thumb -all", @dummy.avatar.send(:extra_options_for, :thumb), @dummy.avatar.convert_options.inspect - end - - should "report the correct options when sent #extra_options_for(:large)" do - assert_equal "-all", @dummy.avatar.send(:extra_options_for, :large) - end - - before_should "call extra_options_for(:thumb/:large)" do - Paperclip::Attachment.any_instance.expects(:extra_options_for).with(:thumb) - Paperclip::Attachment.any_instance.expects(:extra_options_for).with(:large) - end - end - - context "An attachment with :path that is a proc" do - setup do - rebuild_model :path => lambda{ |attachment| "path/#{attachment.instance.other}.:extension" } - - @file = File.new(File.join(File.dirname(__FILE__), - "fixtures", - "5k.png"), 'rb') - @dummyA = Dummy.new(:other => 'a') - @dummyA.avatar = @file - @dummyB = Dummy.new(:other => 'b') - @dummyB.avatar = @file - end - - teardown { @file.close } - - should "return correct path" do - assert_equal "path/a.png", @dummyA.avatar.path - assert_equal "path/b.png", @dummyB.avatar.path - end - end - - context "An attachment with :styles that is a proc" do - setup do - rebuild_model :styles => lambda{ |attachment| {:thumb => "50x50#", :large => "400x400"} } - - @attachment = Dummy.new.avatar - end - - should "have the correct geometry" do - assert_equal "50x50#", @attachment.styles[:thumb][:geometry] - end - end - - context "An attachment with :url that is a proc" do - setup do - rebuild_model :url => lambda{ |attachment| "path/#{attachment.instance.other}.:extension" } - - @file = File.new(File.join(File.dirname(__FILE__), - "fixtures", - "5k.png"), 'rb') - @dummyA = Dummy.new(:other => 'a') - @dummyA.avatar = @file - @dummyB = Dummy.new(:other => 'b') - @dummyB.avatar = @file - end - - teardown { @file.close } - - should "return correct url" do - assert_equal "path/a.png", @dummyA.avatar.url(:original, false) - assert_equal "path/b.png", @dummyB.avatar.url(:original, false) - end - end - - geometry_specs = [ - [ lambda{|z| "50x50#" }, :png ], - lambda{|z| "50x50#" }, - { :geometry => lambda{|z| "50x50#" } } - ] - geometry_specs.each do |geometry_spec| - context "An attachment geometry like #{geometry_spec}" do - setup do - rebuild_model :styles => { :normal => geometry_spec } - @attachment = Dummy.new.avatar - end - - should "not run the procs immediately" do - assert_kind_of Proc, @attachment.styles[:normal][:geometry] - end - - context "when assigned" do - setup do - @file = StringIO.new(".") - @attachment.assign(@file) - end - - should "have the correct geometry" do - assert_equal "50x50#", @attachment.styles[:normal][:geometry] - end - end - end - end - - context "An attachment with both 'normal' and hash-style styles" do - setup do - rebuild_model :styles => { - :normal => ["50x50#", :png], - :hash => { :geometry => "50x50#", :format => :png } - } - @dummy = Dummy.new - @attachment = @dummy.avatar - end - - [:processors, :whiny, :convert_options, :geometry, :format].each do |field| - should "have the same #{field} field" do - assert_equal @attachment.styles[:normal][field], @attachment.styles[:hash][field] - end - end - end - - context "An attachment with :processors that is a proc" do - setup do - rebuild_model :styles => { :normal => '' }, :processors => lambda { |a| [ :test ] } - @attachment = Dummy.new.avatar - end - - should "not run the proc immediately" do - assert_kind_of Proc, @attachment.styles[:normal][:processors] - end - - context "when assigned" do - setup do - @attachment.assign(StringIO.new(".")) - end - - should "have the correct processors" do - assert_equal [ :test ], @attachment.styles[:normal][:processors] - end - end - end - - context "An attachment with erroring processor" do - setup do - rebuild_model :processor => [:thumbnail], :styles => { :small => '' }, :whiny_thumbnails => true - @dummy = Dummy.new - Paperclip::Thumbnail.expects(:make).raises(Paperclip::PaperclipError, "cannot be processed.") - @file = StringIO.new("...") - @file.stubs(:to_tempfile).returns(@file) - @dummy.avatar = @file - end - - should "correctly forward processing error message to the instance" do - @dummy.valid? - assert_contains @dummy.errors.full_messages, "Avatar cannot be processed." - end - end - - context "An attachment with multiple processors" do - setup do - class Paperclip::Test < Paperclip::Processor; end - @style_params = { :once => {:one => 1, :two => 2} } - rebuild_model :processors => [:thumbnail, :test], :styles => @style_params - @dummy = Dummy.new - @file = StringIO.new("...") - @file.stubs(:to_tempfile).returns(@file) - Paperclip::Test.stubs(:make).returns(@file) - Paperclip::Thumbnail.stubs(:make).returns(@file) - end - - context "when assigned" do - setup { @dummy.avatar = @file } - - before_should "call #make on all specified processors" do - expected_params = @style_params[:once].merge({:processors => [:thumbnail, :test], :whiny => nil, :convert_options => ""}) - Paperclip::Thumbnail.expects(:make).with(@file, expected_params, @dummy.avatar).returns(@file) - Paperclip::Test.expects(:make).with(@file, expected_params, @dummy.avatar).returns(@file) - end - - before_should "call #make with attachment passed as third argument" do - expected_params = @style_params[:once].merge({:processors => [:thumbnail, :test], :whiny => nil, :convert_options => ""}) - Paperclip::Test.expects(:make).with(@file, expected_params, @dummy.avatar).returns(@file) - end - end - end - - context "An attachment with no processors defined" do - setup do - rebuild_model :processors => [], :styles => {:something => 1} - @dummy = Dummy.new - @file = StringIO.new("...") - end - should "raise when assigned to" do - assert_raises(RuntimeError){ @dummy.avatar = @file } - end - end - - context "Assigning an attachment with post_process hooks" do - setup do - rebuild_model :styles => { :something => "100x100#" } - Dummy.class_eval do - before_avatar_post_process :do_before_avatar - after_avatar_post_process :do_after_avatar - before_post_process :do_before_all - after_post_process :do_after_all - def do_before_avatar; end - def do_after_avatar; end - def do_before_all; end - def do_after_all; end - end - @file = StringIO.new(".") - @file.stubs(:to_tempfile).returns(@file) - @dummy = Dummy.new - Paperclip::Thumbnail.stubs(:make).returns(@file) - @attachment = @dummy.avatar - end - - should "call the defined callbacks when assigned" do - @dummy.expects(:do_before_avatar).with() - @dummy.expects(:do_after_avatar).with() - @dummy.expects(:do_before_all).with() - @dummy.expects(:do_after_all).with() - Paperclip::Thumbnail.expects(:make).returns(@file) - @dummy.avatar = @file - end - - should "not cancel the processing if a before_post_process returns nil" do - @dummy.expects(:do_before_avatar).with().returns(nil) - @dummy.expects(:do_after_avatar).with() - @dummy.expects(:do_before_all).with().returns(nil) - @dummy.expects(:do_after_all).with() - Paperclip::Thumbnail.expects(:make).returns(@file) - @dummy.avatar = @file - end - - should "cancel the processing if a before_post_process returns false" do - @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).never - Paperclip::Thumbnail.expects(:make).never - @dummy.avatar = @file - end - - should "cancel the processing if a before_avatar_post_process returns false" do - @dummy.expects(:do_before_avatar).with().returns(false) - @dummy.expects(:do_after_avatar).never - @dummy.expects(:do_before_all).with().returns(true) - @dummy.expects(:do_after_all).never - Paperclip::Thumbnail.expects(:make).never - @dummy.avatar = @file - end - end - - context "Assigning an attachment" do - setup do - rebuild_model :styles => { :something => "100x100#" } - @file = StringIO.new(".") - @file.expects(:original_filename).returns("5k.png\n\n") - @file.expects(:content_type).returns("image/png\n\n") - @file.stubs(:to_tempfile).returns(@file) - @dummy = Dummy.new - Paperclip::Thumbnail.expects(:make).returns(@file) - @dummy.expects(:run_callbacks).with(:before_avatar_post_process, {:original => @file}) - @dummy.expects(:run_callbacks).with(:before_post_process, {:original => @file}) - @dummy.expects(:run_callbacks).with(:after_avatar_post_process, {:original => @file, :something => @file}) - @dummy.expects(:run_callbacks).with(:after_post_process, {:original => @file, :something => @file}) - @attachment = @dummy.avatar - @dummy.avatar = @file - end - - should "strip whitespace from original_filename field" do - assert_equal "5k.png", @dummy.avatar.original_filename - end - - should "strip whitespace from content_type field" do - assert_equal "image/png", @dummy.avatar.instance.avatar_content_type - end - end - - context "Attachment with strange letters" do - setup do - rebuild_model - - @not_file = mock - @tempfile = mock - @not_file.stubs(:nil?).returns(false) - @not_file.expects(:size).returns(10) - @tempfile.expects(:size).returns(10) - @not_file.expects(:to_tempfile).returns(@tempfile) - @not_file.expects(:original_filename).returns("sheep_say_bæ.png\r\n") - @not_file.expects(:content_type).returns("image/png\r\n") - - @dummy = Dummy.new - @attachment = @dummy.avatar - @attachment.expects(:valid_assignment?).with(@not_file).returns(true) - @attachment.expects(:queue_existing_for_delete) - @attachment.expects(:post_process) - @attachment.expects(:valid?).returns(true) - @attachment.expects(:validate) - @dummy.avatar = @not_file - end - - should "remove strange letters and replace with underscore (_)" do - assert_equal "sheep_say_b_.png", @dummy.avatar.original_filename - end - - end - - context "An attachment" do - setup do - Paperclip::Attachment.default_options.merge!({ - :path => ":rails_root/tmp/:attachment/:class/:style/:id/:basename.:extension" - }) - FileUtils.rm_rf("tmp") - rebuild_model - @instance = Dummy.new - @attachment = Paperclip::Attachment.new(:avatar, @instance) - @file = File.new(File.join(File.dirname(__FILE__), - "fixtures", - "5k.png"), 'rb') - end - - teardown { @file.close } - - should "raise if there are not the correct columns when you try to assign" do - @other_attachment = Paperclip::Attachment.new(:not_here, @instance) - assert_raises(Paperclip::PaperclipError) do - @other_attachment.assign(@file) - end - end - - should "return its default_url when no file assigned" do - assert @attachment.to_file.nil? - assert_equal "/avatars/original/missing.png", @attachment.url - assert_equal "/avatars/blah/missing.png", @attachment.url(:blah) - end - - should "return nil as path when no file assigned" do - assert @attachment.to_file.nil? - assert_equal nil, @attachment.path - assert_equal nil, @attachment.path(:blah) - end - - context "with a file assigned in the database" do - setup do - @attachment.stubs(:instance_read).with(:file_name).returns("5k.png") - @attachment.stubs(:instance_read).with(:content_type).returns("image/png") - @attachment.stubs(:instance_read).with(:file_size).returns(12345) - now = Time.now - Time.stubs(:now).returns(now) - @attachment.stubs(:instance_read).with(:updated_at).returns(Time.now) - end - - should "return a correct url even if the file does not exist" do - assert_nil @attachment.to_file - assert_match %r{^/system/avatars/#{@instance.id}/blah/5k\.png}, @attachment.url(:blah) - end - - should "make sure the updated_at mtime is in the url if it is defined" do - assert_match %r{#{Time.now.to_i}$}, @attachment.url(:blah) - end - - should "make sure the updated_at mtime is NOT in the url if false is passed to the url method" do - assert_no_match %r{#{Time.now.to_i}$}, @attachment.url(:blah, false) - end - - context "with the updated_at field removed" do - setup do - @attachment.stubs(:instance_read).with(:updated_at).returns(nil) - end - - should "only return the url without the updated_at when sent #url" do - assert_match "/avatars/#{@instance.id}/blah/5k.png", @attachment.url(:blah) - end - end - - should "return the proper path when filename has a single .'s" do - assert_equal "./test/../tmp/avatars/dummies/original/#{@instance.id}/5k.png", @attachment.path - end - - should "return the proper path when filename has multiple .'s" do - @attachment.stubs(:instance_read).with(:file_name).returns("5k.old.png") - assert_equal "./test/../tmp/avatars/dummies/original/#{@instance.id}/5k.old.png", @attachment.path - end - - context "when expecting three styles" do - setup do - styles = {:styles => { :large => ["400x400", :png], - :medium => ["100x100", :gif], - :small => ["32x32#", :jpg]}} - @attachment = Paperclip::Attachment.new(:avatar, - @instance, - styles) - end - - context "and assigned a file" do - setup do - now = Time.now - Time.stubs(:now).returns(now) - @attachment.assign(@file) - end - - should "be dirty" do - assert @attachment.dirty? - end - - context "and saved" do - setup do - @attachment.save - end - - should "return the real url" do - file = @attachment.to_file - assert file - assert_match %r{^/system/avatars/#{@instance.id}/original/5k\.png}, @attachment.url - assert_match %r{^/system/avatars/#{@instance.id}/small/5k\.jpg}, @attachment.url(:small) - file.close - end - - should "commit the files to disk" do - [:large, :medium, :small].each do |style| - io = @attachment.to_io(style) - assert File.exists?(io) - assert ! io.is_a?(::Tempfile) - io.close - end - end - - should "save the files as the right formats and sizes" do - [[:large, 400, 61, "PNG"], - [:medium, 100, 15, "GIF"], - [:small, 32, 32, "JPEG"]].each do |style| - cmd = %Q[identify -format "%w %h %b %m" "#{@attachment.path(style.first)}"] - out = `#{cmd}` - width, height, size, format = out.split(" ") - assert_equal style[1].to_s, width.to_s - assert_equal style[2].to_s, height.to_s - assert_equal style[3].to_s, format.to_s - end - end - - should "still have its #file attribute not be nil" do - assert ! (file = @attachment.to_file).nil? - file.close - end - - context "and trying to delete" do - setup do - @existing_names = @attachment.styles.keys.collect do |style| - @attachment.path(style) - end - end - - should "delete the files after assigning nil" do - @attachment.expects(:instance_write).with(:file_name, nil) - @attachment.expects(:instance_write).with(:content_type, nil) - @attachment.expects(:instance_write).with(:file_size, nil) - @attachment.expects(:instance_write).with(:updated_at, nil) - @attachment.assign nil - @attachment.save - @existing_names.each{|f| assert ! File.exists?(f) } - end - - should "delete the files when you call #clear and #save" do - @attachment.expects(:instance_write).with(:file_name, nil) - @attachment.expects(:instance_write).with(:content_type, nil) - @attachment.expects(:instance_write).with(:file_size, nil) - @attachment.expects(:instance_write).with(:updated_at, nil) - @attachment.clear - @attachment.save - @existing_names.each{|f| assert ! File.exists?(f) } - end - - should "delete the files when you call #delete" do - @attachment.expects(:instance_write).with(:file_name, nil) - @attachment.expects(:instance_write).with(:content_type, nil) - @attachment.expects(:instance_write).with(:file_size, nil) - @attachment.expects(:instance_write).with(:updated_at, nil) - @attachment.destroy - @existing_names.each{|f| assert ! File.exists?(f) } - end - end - end - end - end - - end - - context "when trying a nonexistant storage type" do - setup do - rebuild_model :storage => :not_here - end - - should "not be able to find the module" do - assert_raise(NameError){ Dummy.new.avatar } - end - end - end - - context "An attachment with only a avatar_file_name column" do - setup do - ActiveRecord::Base.connection.create_table :dummies, :force => true do |table| - table.column :avatar_file_name, :string - end - rebuild_class - @dummy = Dummy.new - @file = File.new(File.join(File.dirname(__FILE__), "fixtures", "5k.png"), 'rb') - end - - teardown { @file.close } - - should "not error when assigned an attachment" do - assert_nothing_raised { @dummy.avatar = @file } - end - - should "return the time when sent #avatar_updated_at" do - now = Time.now - Time.stubs(:now).returns(now) - @dummy.avatar = @file - assert now, @dummy.avatar.updated_at - end - - should "return nil when reloaded and sent #avatar_updated_at" do - @dummy.save - @dummy.reload - assert_nil @dummy.avatar.updated_at - end - - should "return the right value when sent #avatar_file_size" do - @dummy.avatar = @file - assert_equal @file.size, @dummy.avatar.size - end - - context "and avatar_updated_at column" do - setup do - ActiveRecord::Base.connection.add_column :dummies, :avatar_updated_at, :timestamp - rebuild_class - @dummy = Dummy.new - end - - should "not error when assigned an attachment" do - assert_nothing_raised { @dummy.avatar = @file } - end - - should "return the right value when sent #avatar_updated_at" do - now = Time.now - Time.stubs(:now).returns(now) - @dummy.avatar = @file - assert_equal now.to_i, @dummy.avatar.updated_at - end - end - - context "and avatar_content_type column" do - setup do - ActiveRecord::Base.connection.add_column :dummies, :avatar_content_type, :string - rebuild_class - @dummy = Dummy.new - end - - should "not error when assigned an attachment" do - assert_nothing_raised { @dummy.avatar = @file } - end - - should "return the right value when sent #avatar_content_type" do - @dummy.avatar = @file - assert_equal "image/png", @dummy.avatar.content_type - end - end - - context "and avatar_file_size column" do - setup do - ActiveRecord::Base.connection.add_column :dummies, :avatar_file_size, :integer - rebuild_class - @dummy = Dummy.new - end - - should "not error when assigned an attachment" do - assert_nothing_raised { @dummy.avatar = @file } - end - - should "return the right value when sent #avatar_file_size" do - @dummy.avatar = @file - assert_equal @file.size, @dummy.avatar.size - end - - should "return the right value when saved, reloaded, and sent #avatar_file_size" do - @dummy.avatar = @file - @dummy.save - @dummy = Dummy.find(@dummy.id) - assert_equal @file.size, @dummy.avatar.size - end - end - end -end diff --git a/vendor/plugins/paperclip/test/fixtures/12k.png b/vendor/plugins/paperclip/test/fixtures/12k.png deleted file mode 100644 index f819d451..00000000 Binary files a/vendor/plugins/paperclip/test/fixtures/12k.png and /dev/null differ diff --git a/vendor/plugins/paperclip/test/fixtures/50x50.png b/vendor/plugins/paperclip/test/fixtures/50x50.png deleted file mode 100644 index 63f56465..00000000 Binary files a/vendor/plugins/paperclip/test/fixtures/50x50.png and /dev/null differ diff --git a/vendor/plugins/paperclip/test/fixtures/5k.png b/vendor/plugins/paperclip/test/fixtures/5k.png deleted file mode 100644 index 75d9f045..00000000 Binary files a/vendor/plugins/paperclip/test/fixtures/5k.png and /dev/null differ diff --git a/vendor/plugins/paperclip/test/fixtures/bad.png b/vendor/plugins/paperclip/test/fixtures/bad.png deleted file mode 100644 index 7ba4f07a..00000000 --- a/vendor/plugins/paperclip/test/fixtures/bad.png +++ /dev/null @@ -1 +0,0 @@ -This is not an image. diff --git a/vendor/plugins/paperclip/test/fixtures/text.txt b/vendor/plugins/paperclip/test/fixtures/text.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/vendor/plugins/paperclip/test/fixtures/twopage.pdf b/vendor/plugins/paperclip/test/fixtures/twopage.pdf deleted file mode 100644 index 0c34a519..00000000 Binary files a/vendor/plugins/paperclip/test/fixtures/twopage.pdf and /dev/null differ diff --git a/vendor/plugins/paperclip/test/geometry_test.rb b/vendor/plugins/paperclip/test/geometry_test.rb deleted file mode 100644 index 134372d6..00000000 --- a/vendor/plugins/paperclip/test/geometry_test.rb +++ /dev/null @@ -1,168 +0,0 @@ -require 'test/helper' - -class GeometryTest < Test::Unit::TestCase - context "Paperclip::Geometry" do - should "correctly report its given dimensions" do - assert @geo = Paperclip::Geometry.new(1024, 768) - assert_equal 1024, @geo.width - assert_equal 768, @geo.height - end - - should "set height to 0 if height dimension is missing" do - assert @geo = Paperclip::Geometry.new(1024) - assert_equal 1024, @geo.width - assert_equal 0, @geo.height - end - - should "set width to 0 if width dimension is missing" do - assert @geo = Paperclip::Geometry.new(nil, 768) - assert_equal 0, @geo.width - assert_equal 768, @geo.height - end - - should "be generated from a WxH-formatted string" do - assert @geo = Paperclip::Geometry.parse("800x600") - assert_equal 800, @geo.width - assert_equal 600, @geo.height - end - - should "be generated from a xH-formatted string" do - assert @geo = Paperclip::Geometry.parse("x600") - assert_equal 0, @geo.width - assert_equal 600, @geo.height - end - - should "be generated from a Wx-formatted string" do - assert @geo = Paperclip::Geometry.parse("800x") - assert_equal 800, @geo.width - assert_equal 0, @geo.height - end - - should "be generated from a W-formatted string" do - assert @geo = Paperclip::Geometry.parse("800") - assert_equal 800, @geo.width - assert_equal 0, @geo.height - end - - should "ensure the modifier is nil if not present" do - assert @geo = Paperclip::Geometry.parse("123x456") - assert_nil @geo.modifier - end - - ['>', '<', '#', '@', '%', '^', '!', nil].each do |mod| - should "ensure the modifier #{mod.inspect} is preserved" do - assert @geo = Paperclip::Geometry.parse("123x456#{mod}") - assert_equal mod, @geo.modifier - assert_equal "123x456#{mod}", @geo.to_s - end - end - - ['>', '<', '#', '@', '%', '^', '!', nil].each do |mod| - should "ensure the modifier #{mod.inspect} is preserved with no height" do - assert @geo = Paperclip::Geometry.parse("123x#{mod}") - assert_equal mod, @geo.modifier - assert_equal "123#{mod}", @geo.to_s - end - end - - should "make sure the modifier gets passed during transformation_to" do - assert @src = Paperclip::Geometry.parse("123x456") - assert @dst = Paperclip::Geometry.parse("123x456>") - assert_equal "123x456>", @src.transformation_to(@dst).to_s - end - - should "generate correct ImageMagick formatting string for W-formatted string" do - assert @geo = Paperclip::Geometry.parse("800") - assert_equal "800", @geo.to_s - end - - should "generate correct ImageMagick formatting string for Wx-formatted string" do - assert @geo = Paperclip::Geometry.parse("800x") - assert_equal "800", @geo.to_s - end - - should "generate correct ImageMagick formatting string for xH-formatted string" do - assert @geo = Paperclip::Geometry.parse("x600") - assert_equal "x600", @geo.to_s - end - - should "generate correct ImageMagick formatting string for WxH-formatted string" do - assert @geo = Paperclip::Geometry.parse("800x600") - assert_equal "800x600", @geo.to_s - end - - should "be generated from a file" do - file = File.join(File.dirname(__FILE__), "fixtures", "5k.png") - file = File.new(file, 'rb') - assert_nothing_raised{ @geo = Paperclip::Geometry.from_file(file) } - assert @geo.height > 0 - assert @geo.width > 0 - end - - should "be generated from a file path" do - file = File.join(File.dirname(__FILE__), "fixtures", "5k.png") - assert_nothing_raised{ @geo = Paperclip::Geometry.from_file(file) } - assert @geo.height > 0 - assert @geo.width > 0 - end - - should "not generate from a bad file" do - file = "/home/This File Does Not Exist.omg" - assert_raise(Paperclip::NotIdentifiedByImageMagickError){ @geo = Paperclip::Geometry.from_file(file) } - end - - [['vertical', 900, 1440, true, false, false, 1440, 900, 0.625], - ['horizontal', 1024, 768, false, true, false, 1024, 768, 1.3333], - ['square', 100, 100, false, false, true, 100, 100, 1]].each do |args| - context "performing calculations on a #{args[0]} viewport" do - setup do - @geo = Paperclip::Geometry.new(args[1], args[2]) - end - - should "#{args[3] ? "" : "not"} be vertical" do - assert_equal args[3], @geo.vertical? - end - - should "#{args[4] ? "" : "not"} be horizontal" do - assert_equal args[4], @geo.horizontal? - end - - should "#{args[5] ? "" : "not"} be square" do - assert_equal args[5], @geo.square? - end - - should "report that #{args[6]} is the larger dimension" do - assert_equal args[6], @geo.larger - end - - should "report that #{args[7]} is the smaller dimension" do - assert_equal args[7], @geo.smaller - end - - should "have an aspect ratio of #{args[8]}" do - assert_in_delta args[8], @geo.aspect, 0.0001 - end - end - end - - [[ [1000, 100], [64, 64], "x64", "64x64+288+0" ], - [ [100, 1000], [50, 950], "x950", "50x950+22+0" ], - [ [100, 1000], [50, 25], "50x", "50x25+0+237" ]]. each do |args| - context "of #{args[0].inspect} and given a Geometry #{args[1].inspect} and sent transform_to" do - setup do - @geo = Paperclip::Geometry.new(*args[0]) - @dst = Paperclip::Geometry.new(*args[1]) - @scale, @crop = @geo.transformation_to @dst, true - end - - should "be able to return the correct scaling transformation geometry #{args[2]}" do - assert_equal args[2], @scale - end - - should "be able to return the correct crop transformation geometry #{args[3]}" do - assert_equal args[3], @crop - end - end - end - end -end diff --git a/vendor/plugins/paperclip/test/helper.rb b/vendor/plugins/paperclip/test/helper.rb deleted file mode 100644 index 3e7e6a1c..00000000 --- a/vendor/plugins/paperclip/test/helper.rb +++ /dev/null @@ -1,82 +0,0 @@ -require 'rubygems' -require 'test/unit' -gem 'thoughtbot-shoulda', ">= 2.9.0" -require 'shoulda' -require 'mocha' -require 'tempfile' - -gem 'sqlite3-ruby' - -require 'active_record' -require 'active_support' -begin - require 'ruby-debug' -rescue LoadError - puts "ruby-debug not loaded" -end - -ROOT = File.join(File.dirname(__FILE__), '..') -RAILS_ROOT = ROOT - -$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']) - -def reset_class class_name - ActiveRecord::Base.send(:include, Paperclip) - Object.send(:remove_const, class_name) rescue nil - klass = Object.const_set(class_name, Class.new(ActiveRecord::Base)) - klass.class_eval{ include Paperclip } - klass -end - -def reset_table table_name, &block - block ||= lambda{ true } - ActiveRecord::Base.connection.create_table :dummies, {:force => true}, &block -end - -def modify_table table_name, &block - ActiveRecord::Base.connection.change_table :dummies, &block -end - -def rebuild_model options = {} - ActiveRecord::Base.connection.create_table :dummies, :force => true do |table| - table.column :other, :string - table.column :avatar_file_name, :string - table.column :avatar_content_type, :string - table.column :avatar_file_size, :integer - table.column :avatar_updated_at, :datetime - end - rebuild_class options -end - -def rebuild_class options = {} - ActiveRecord::Base.send(:include, Paperclip) - Object.send(:remove_const, "Dummy") rescue nil - Object.const_set("Dummy", Class.new(ActiveRecord::Base)) - Dummy.class_eval do - include Paperclip - has_attached_file :avatar, options - end -end - -def temporary_rails_env(new_env) - old_env = 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 diff --git a/vendor/plugins/paperclip/test/integration_test.rb b/vendor/plugins/paperclip/test/integration_test.rb deleted file mode 100644 index f7014acd..00000000 --- a/vendor/plugins/paperclip/test/integration_test.rb +++ /dev/null @@ -1,481 +0,0 @@ -require 'test/helper' - -class IntegrationTest < Test::Unit::TestCase - context "Many models at once" do - setup do - rebuild_model - @file = File.new(File.join(FIXTURES_DIR, "5k.png"), 'rb') - 300.times do |i| - Dummy.create! :avatar => @file - end - end - - should "not exceed the open file limit" do - assert_nothing_raised do - dummies = Dummy.find(:all) - dummies.each { |dummy| dummy.avatar } - end - end - end - - context "An attachment" do - setup do - rebuild_model :styles => { :thumb => "50x50#" } - @dummy = Dummy.new - @file = File.new(File.join(File.dirname(__FILE__), - "fixtures", - "5k.png"), 'rb') - @dummy.avatar = @file - assert @dummy.save - end - - teardown { @file.close } - - should "create its thumbnails properly" do - assert_match /\b50x50\b/, `identify "#{@dummy.avatar.path(:thumb)}"` - end - - context "redefining its attachment styles" do - setup do - Dummy.class_eval do - has_attached_file :avatar, :styles => { :thumb => "150x25#" } - has_attached_file :avatar, :styles => { :thumb => "150x25#", :dynamic => lambda { |a| '50x50#' } } - end - @d2 = Dummy.find(@dummy.id) - @d2.avatar.reprocess! - @d2.save - end - - should "create its thumbnails properly" do - assert_match /\b150x25\b/, `identify "#{@dummy.avatar.path(:thumb)}"` - assert_match /\b50x50\b/, `identify "#{@dummy.avatar.path(:dynamic)}"` - end - end - end - - context "A model that modifies its original" do - setup do - rebuild_model :styles => { :original => "2x2#" } - @dummy = Dummy.new - @file = File.new(File.join(File.dirname(__FILE__), - "fixtures", - "5k.png"), 'rb') - @dummy.avatar = @file - end - - should "report the file size of the processed file and not the original" do - assert_not_equal @file.size, @dummy.avatar.size - end - - teardown { @file.close } - end - - context "A model with attachments scoped under an id" do - setup do - rebuild_model :styles => { :large => "100x100", - :medium => "50x50" }, - :path => ":rails_root/tmp/:id/:attachments/:style.:extension" - @dummy = Dummy.new - @file = File.new(File.join(File.dirname(__FILE__), - "fixtures", - "5k.png"), 'rb') - @dummy.avatar = @file - end - - teardown { @file.close } - - context "when saved" do - setup do - @dummy.save - @saved_path = @dummy.avatar.path(:large) - end - - should "have a large file in the right place" do - assert File.exists?(@dummy.avatar.path(:large)) - end - - context "and deleted" do - setup do - @dummy.avatar.clear - @dummy.save - end - - should "not have a large file in the right place anymore" do - assert ! File.exists?(@saved_path) - end - - should "not have its next two parent directories" do - assert ! File.exists?(File.dirname(@saved_path)) - assert ! File.exists?(File.dirname(File.dirname(@saved_path))) - end - - before_should "not die if an unexpected SystemCallError happens" do - FileUtils.stubs(:rmdir).raises(Errno::EPIPE) - end - end - end - end - - context "A model with no attachment validation" do - setup do - rebuild_model :styles => { :large => "300x300>", - :medium => "100x100", - :thumb => ["32x32#", :gif] }, - :default_style => :medium, - :url => "/:attachment/:class/:style/:id/:basename.:extension", - :path => ":rails_root/tmp/:attachment/:class/:style/:id/:basename.:extension" - @dummy = Dummy.new - end - - should "have its definition return false when asked about whiny_thumbnails" do - assert ! Dummy.attachment_definitions[:avatar][:whiny_thumbnails] - end - - context "when validates_attachment_thumbnails is called" do - setup do - Dummy.validates_attachment_thumbnails :avatar - end - - should "have its definition return true when asked about whiny_thumbnails" do - assert_equal true, Dummy.attachment_definitions[:avatar][:whiny_thumbnails] - end - end - - context "redefined to have attachment validations" do - setup do - rebuild_model :styles => { :large => "300x300>", - :medium => "100x100", - :thumb => ["32x32#", :gif] }, - :whiny_thumbnails => true, - :default_style => :medium, - :url => "/:attachment/:class/:style/:id/:basename.:extension", - :path => ":rails_root/tmp/:attachment/:class/:style/:id/:basename.:extension" - end - - should "have its definition return true when asked about whiny_thumbnails" do - assert_equal true, Dummy.attachment_definitions[:avatar][:whiny_thumbnails] - end - end - end - - context "A model with no convert_options setting" do - setup do - rebuild_model :styles => { :large => "300x300>", - :medium => "100x100", - :thumb => ["32x32#", :gif] }, - :default_style => :medium, - :url => "/:attachment/:class/:style/:id/:basename.:extension", - :path => ":rails_root/tmp/:attachment/:class/:style/:id/:basename.:extension" - @dummy = Dummy.new - end - - should "have its definition return nil when asked about convert_options" do - assert ! Dummy.attachment_definitions[:avatar][:convert_options] - end - - context "redefined to have convert_options setting" do - setup do - rebuild_model :styles => { :large => "300x300>", - :medium => "100x100", - :thumb => ["32x32#", :gif] }, - :convert_options => "-strip -depth 8", - :default_style => :medium, - :url => "/:attachment/:class/:style/:id/:basename.:extension", - :path => ":rails_root/tmp/:attachment/:class/:style/:id/:basename.:extension" - end - - should "have its definition return convert_options value when asked about convert_options" do - assert_equal "-strip -depth 8", Dummy.attachment_definitions[:avatar][:convert_options] - end - end - end - - context "A model with a filesystem attachment" do - setup do - rebuild_model :styles => { :large => "300x300>", - :medium => "100x100", - :thumb => ["32x32#", :gif] }, - :whiny_thumbnails => true, - :default_style => :medium, - :url => "/:attachment/:class/:style/:id/:basename.:extension", - :path => ":rails_root/tmp/:attachment/:class/:style/:id/:basename.:extension" - @dummy = Dummy.new - @file = File.new(File.join(FIXTURES_DIR, "5k.png"), 'rb') - @bad_file = File.new(File.join(FIXTURES_DIR, "bad.png"), 'rb') - - assert @dummy.avatar = @file - assert @dummy.valid? - assert @dummy.save - end - - should "write and delete its files" do - [["434x66", :original], - ["300x46", :large], - ["100x15", :medium], - ["32x32", :thumb]].each do |geo, style| - cmd = %Q[identify -format "%wx%h" "#{@dummy.avatar.path(style)}"] - assert_equal geo, `#{cmd}`.chomp, cmd - end - - saved_paths = [:thumb, :medium, :large, :original].collect{|s| @dummy.avatar.path(s) } - - @d2 = Dummy.find(@dummy.id) - assert_equal "100x15", `identify -format "%wx%h" "#{@d2.avatar.path}"`.chomp - assert_equal "434x66", `identify -format "%wx%h" "#{@d2.avatar.path(:original)}"`.chomp - assert_equal "300x46", `identify -format "%wx%h" "#{@d2.avatar.path(:large)}"`.chomp - assert_equal "100x15", `identify -format "%wx%h" "#{@d2.avatar.path(:medium)}"`.chomp - assert_equal "32x32", `identify -format "%wx%h" "#{@d2.avatar.path(:thumb)}"`.chomp - - @dummy.avatar = "not a valid file but not nil" - assert_equal File.basename(@file.path), @dummy.avatar_file_name - assert @dummy.valid? - assert @dummy.save - - saved_paths.each do |p| - assert File.exists?(p) - end - - @dummy.avatar.clear - assert_nil @dummy.avatar_file_name - assert @dummy.valid? - assert @dummy.save - - saved_paths.each do |p| - assert ! File.exists?(p) - end - - @d2 = Dummy.find(@dummy.id) - assert_nil @d2.avatar_file_name - end - - should "work exactly the same when new as when reloaded" do - @d2 = Dummy.find(@dummy.id) - - assert_equal @dummy.avatar_file_name, @d2.avatar_file_name - [:thumb, :medium, :large, :original].each do |style| - assert_equal @dummy.avatar.path(style), @d2.avatar.path(style) - end - - saved_paths = [:thumb, :medium, :large, :original].collect{|s| @dummy.avatar.path(s) } - - @d2.avatar.clear - assert @d2.save - - saved_paths.each do |p| - assert ! File.exists?(p) - end - end - - should "know the difference between good files, bad files, and not files" do - expected = @dummy.avatar.to_file - @dummy.avatar = "not a file" - assert @dummy.valid? - assert_equal expected.path, @dummy.avatar.path - expected.close - - @dummy.avatar = @bad_file - assert ! @dummy.valid? - end - - should "know the difference between good files, bad files, and not files when validating" do - Dummy.validates_attachment_presence :avatar - @d2 = Dummy.find(@dummy.id) - @d2.avatar = @file - assert @d2.valid?, @d2.errors.full_messages.inspect - @d2.avatar = @bad_file - assert ! @d2.valid? - end - - should "be able to reload without saving and not have the file disappear" do - @dummy.avatar = @file - assert @dummy.save - @dummy.avatar.clear - assert_nil @dummy.avatar_file_name - @dummy.reload - assert_equal "5k.png", @dummy.avatar_file_name - end - - context "that is assigned its file from another Paperclip attachment" do - setup do - @dummy2 = Dummy.new - @file2 = File.new(File.join(FIXTURES_DIR, "12k.png"), 'rb') - assert @dummy2.avatar = @file2 - @dummy2.save - end - - should "work when assigned a file" do - assert_not_equal `identify -format "%wx%h" "#{@dummy.avatar.path(:original)}"`, - `identify -format "%wx%h" "#{@dummy2.avatar.path(:original)}"` - - assert @dummy.avatar = @dummy2.avatar - @dummy.save - assert_equal `identify -format "%wx%h" "#{@dummy.avatar.path(:original)}"`, - `identify -format "%wx%h" "#{@dummy2.avatar.path(:original)}"` - end - end - - end - - context "A model with an attachments association and a Paperclip attachment" do - setup do - Dummy.class_eval do - has_many :attachments, :class_name => 'Dummy' - end - - @dummy = Dummy.new - @dummy.avatar = File.new(File.join(File.dirname(__FILE__), - "fixtures", - "5k.png"), 'rb') - end - - should "should not error when saving" do - assert_nothing_raised do - @dummy.save! - end - end - end - - if ENV['S3_TEST_BUCKET'] - def s3_files_for attachment - [:thumb, :medium, :large, :original].inject({}) do |files, style| - data = `curl "#{attachment.url(style)}" 2>/dev/null`.chomp - t = Tempfile.new("paperclip-test") - t.binmode - t.write(data) - t.rewind - files[style] = t - files - end - end - - def s3_headers_for attachment, style - `curl --head "#{attachment.url(style)}" 2>/dev/null`.split("\n").inject({}) do |h,head| - split_head = head.chomp.split(/\s*:\s*/, 2) - h[split_head.first.downcase] = split_head.last unless split_head.empty? - h - end - end - - context "A model with an S3 attachment" do - setup do - rebuild_model :styles => { :large => "300x300>", - :medium => "100x100", - :thumb => ["32x32#", :gif] }, - :storage => :s3, - :whiny_thumbnails => true, - # :s3_options => {:logger => Logger.new(StringIO.new)}, - :s3_credentials => File.new(File.join(File.dirname(__FILE__), "s3.yml")), - :default_style => :medium, - :bucket => ENV['S3_TEST_BUCKET'], - :path => ":class/:attachment/:id/:style/:basename.:extension" - @dummy = Dummy.new - @file = File.new(File.join(FIXTURES_DIR, "5k.png"), 'rb') - @bad_file = File.new(File.join(FIXTURES_DIR, "bad.png"), 'rb') - - assert @dummy.avatar = @file - assert @dummy.valid? - assert @dummy.save - - @files_on_s3 = s3_files_for @dummy.avatar - end - - should "write and delete its files" do - [["434x66", :original], - ["300x46", :large], - ["100x15", :medium], - ["32x32", :thumb]].each do |geo, style| - cmd = %Q[identify -format "%wx%h" "#{@files_on_s3[style].path}"] - assert_equal geo, `#{cmd}`.chomp, cmd - end - - @d2 = Dummy.find(@dummy.id) - @d2_files = s3_files_for @d2.avatar - [["434x66", :original], - ["300x46", :large], - ["100x15", :medium], - ["32x32", :thumb]].each do |geo, style| - cmd = %Q[identify -format "%wx%h" "#{@d2_files[style].path}"] - assert_equal geo, `#{cmd}`.chomp, cmd - end - - @dummy.avatar = "not a valid file but not nil" - assert_equal File.basename(@file.path), @dummy.avatar_file_name - assert @dummy.valid? - assert @dummy.save - - saved_keys = [:thumb, :medium, :large, :original].collect{|s| @dummy.avatar.to_file(s) } - - saved_keys.each do |key| - assert key.exists? - end - - @dummy.avatar.clear - assert_nil @dummy.avatar_file_name - assert @dummy.valid? - assert @dummy.save - - saved_keys.each do |key| - assert ! key.exists? - end - - @d2 = Dummy.find(@dummy.id) - assert_nil @d2.avatar_file_name - end - - should "work exactly the same when new as when reloaded" do - @d2 = Dummy.find(@dummy.id) - - assert_equal @dummy.avatar_file_name, @d2.avatar_file_name - [:thumb, :medium, :large, :original].each do |style| - assert_equal @dummy.avatar.to_file(style).to_s, @d2.avatar.to_file(style).to_s - end - - saved_keys = [:thumb, :medium, :large, :original].collect{|s| @dummy.avatar.to_file(s) } - - @d2.avatar.clear - assert @d2.save - - saved_keys.each do |key| - assert ! key.exists? - end - end - - should "know the difference between good files, bad files, not files, and nil" do - expected = @dummy.avatar.to_file - @dummy.avatar = "not a file" - assert @dummy.valid? - assert_equal expected.full_name, @dummy.avatar.to_file.full_name - - @dummy.avatar = @bad_file - assert ! @dummy.valid? - @dummy.avatar = nil - assert @dummy.valid? - - Dummy.validates_attachment_presence :avatar - @d2 = Dummy.find(@dummy.id) - @d2.avatar = @file - assert @d2.valid? - @d2.avatar = @bad_file - assert ! @d2.valid? - @d2.avatar = nil - assert ! @d2.valid? - end - - should "be able to reload without saving and not have the file disappear" do - @dummy.avatar = @file - assert @dummy.save - @dummy.avatar = nil - assert_nil @dummy.avatar_file_name - @dummy.reload - assert_equal "5k.png", @dummy.avatar_file_name - end - - should "have the right content type" do - headers = s3_headers_for(@dummy.avatar, :original) - p headers - assert_equal 'image/png', headers['content-type'] - end - end - end -end - diff --git a/vendor/plugins/paperclip/test/iostream_test.rb b/vendor/plugins/paperclip/test/iostream_test.rb deleted file mode 100644 index 97030b50..00000000 --- a/vendor/plugins/paperclip/test/iostream_test.rb +++ /dev/null @@ -1,71 +0,0 @@ -require 'test/helper' - -class IOStreamTest < Test::Unit::TestCase - context "IOStream" do - should "be included in IO, File, Tempfile, and StringIO" do - [IO, File, Tempfile, StringIO].each do |klass| - assert klass.included_modules.include?(IOStream), "Not in #{klass}" - end - end - end - - context "A file" do - setup do - @file = File.new(File.join(File.dirname(__FILE__), "fixtures", "5k.png"), 'rb') - end - - teardown { @file.close } - - context "that is sent #stream_to" do - - context "and given a String" do - setup do - FileUtils.mkdir_p(File.join(ROOT, 'tmp')) - assert @result = @file.stream_to(File.join(ROOT, 'tmp', 'iostream.string.test')) - end - - should "return a File" do - assert @result.is_a?(File) - end - - should "contain the same data as the original file" do - @file.rewind; @result.rewind - assert_equal @file.read, @result.read - end - end - - context "and given a Tempfile" do - setup do - tempfile = Tempfile.new('iostream.test') - tempfile.binmode - assert @result = @file.stream_to(tempfile) - end - - should "return a Tempfile" do - assert @result.is_a?(Tempfile) - end - - should "contain the same data as the original file" do - @file.rewind; @result.rewind - assert_equal @file.read, @result.read - end - end - - end - - context "that is sent #to_tempfile" do - setup do - assert @tempfile = @file.to_tempfile - end - - should "convert it to a Tempfile" do - assert @tempfile.is_a?(Tempfile) - end - - should "have the Tempfile contain the same data as the file" do - @file.rewind; @tempfile.rewind - assert_equal @file.read, @tempfile.read - end - end - end -end diff --git a/vendor/plugins/paperclip/test/matchers/have_attached_file_matcher_test.rb b/vendor/plugins/paperclip/test/matchers/have_attached_file_matcher_test.rb deleted file mode 100644 index b29ec372..00000000 --- a/vendor/plugins/paperclip/test/matchers/have_attached_file_matcher_test.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'test/helper' - -class HaveAttachedFileMatcherTest < Test::Unit::TestCase - context "have_attached_file" do - setup do - @dummy_class = reset_class "Dummy" - reset_table "dummies" - @matcher = self.class.have_attached_file(:avatar) - end - - should "reject a class with no attachment" do - assert_rejects @matcher, @dummy_class - end - - should "accept a class with an attachment" do - modify_table("dummies"){|d| d.string :avatar_file_name } - @dummy_class.has_attached_file :avatar - assert_accepts @matcher, @dummy_class - end - end -end diff --git a/vendor/plugins/paperclip/test/matchers/validate_attachment_content_type_matcher_test.rb b/vendor/plugins/paperclip/test/matchers/validate_attachment_content_type_matcher_test.rb deleted file mode 100644 index 241eb5f1..00000000 --- a/vendor/plugins/paperclip/test/matchers/validate_attachment_content_type_matcher_test.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'test/helper' - -class ValidateAttachmentContentTypeMatcherTest < Test::Unit::TestCase - context "validate_attachment_content_type" do - setup do - reset_table("dummies") do |d| - d.string :avatar_file_name - end - @dummy_class = reset_class "Dummy" - @dummy_class.has_attached_file :avatar - @matcher = self.class.validate_attachment_content_type(:avatar). - allowing(%w(image/png image/jpeg)). - rejecting(%w(audio/mp3 application/octet-stream)) - end - - should "reject a class with no validation" do - assert_rejects @matcher, @dummy_class - end - - should "reject a class with a validation that doesn't match" do - @dummy_class.validates_attachment_content_type :avatar, :content_type => %r{audio/.*} - assert_rejects @matcher, @dummy_class - end - - should "accept a class with a validation" do - @dummy_class.validates_attachment_content_type :avatar, :content_type => %r{image/.*} - assert_accepts @matcher, @dummy_class - end - end -end diff --git a/vendor/plugins/paperclip/test/matchers/validate_attachment_presence_matcher_test.rb b/vendor/plugins/paperclip/test/matchers/validate_attachment_presence_matcher_test.rb deleted file mode 100644 index 860a7604..00000000 --- a/vendor/plugins/paperclip/test/matchers/validate_attachment_presence_matcher_test.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'test/helper' - -class ValidateAttachmentPresenceMatcherTest < Test::Unit::TestCase - context "validate_attachment_presence" do - setup do - reset_table("dummies"){|d| d.string :avatar_file_name } - @dummy_class = reset_class "Dummy" - @dummy_class.has_attached_file :avatar - @matcher = self.class.validate_attachment_presence(:avatar) - end - - should "reject a class with no validation" do - assert_rejects @matcher, @dummy_class - end - - should "accept a class with a validation" do - @dummy_class.validates_attachment_presence :avatar - assert_accepts @matcher, @dummy_class - end - end -end diff --git a/vendor/plugins/paperclip/test/matchers/validate_attachment_size_matcher_test.rb b/vendor/plugins/paperclip/test/matchers/validate_attachment_size_matcher_test.rb deleted file mode 100644 index 7e4c9b40..00000000 --- a/vendor/plugins/paperclip/test/matchers/validate_attachment_size_matcher_test.rb +++ /dev/null @@ -1,50 +0,0 @@ -require 'test/helper' - -class ValidateAttachmentSizeMatcherTest < Test::Unit::TestCase - context "validate_attachment_size" do - setup do - reset_table("dummies") do |d| - d.string :avatar_file_name - end - @dummy_class = reset_class "Dummy" - @dummy_class.has_attached_file :avatar - end - - context "of limited size" do - setup{ @matcher = self.class.validate_attachment_size(:avatar).in(256..1024) } - - should "reject a class with no validation" do - assert_rejects @matcher, @dummy_class - end - - should "reject a class with a validation that's too high" do - @dummy_class.validates_attachment_size :avatar, :in => 256..2048 - assert_rejects @matcher, @dummy_class - end - - should "reject a class with a validation that's too low" do - @dummy_class.validates_attachment_size :avatar, :in => 0..1024 - assert_rejects @matcher, @dummy_class - end - - should "accept a class with a validation that matches" do - @dummy_class.validates_attachment_size :avatar, :in => 256..1024 - assert_accepts @matcher, @dummy_class - end - end - - context "validates_attachment_size with infinite range" do - setup{ @matcher = self.class.validate_attachment_size(:avatar) } - - should "accept a class with an upper limit" do - @dummy_class.validates_attachment_size :avatar, :less_than => 1 - assert_accepts @matcher, @dummy_class - end - - should "accept a class with no upper limit" do - @dummy_class.validates_attachment_size :avatar, :greater_than => 1 - assert_accepts @matcher, @dummy_class - end - end - end -end diff --git a/vendor/plugins/paperclip/test/paperclip_test.rb b/vendor/plugins/paperclip/test/paperclip_test.rb deleted file mode 100644 index 83656498..00000000 --- a/vendor/plugins/paperclip/test/paperclip_test.rb +++ /dev/null @@ -1,233 +0,0 @@ -require 'test/helper' - -class PaperclipTest < Test::Unit::TestCase - [:image_magick_path, :convert_path].each do |path| - context "Calling Paperclip.run with an #{path} specified" do - setup do - Paperclip.options[:image_magick_path] = nil - Paperclip.options[:convert_path] = nil - Paperclip.options[path] = "/usr/bin" - end - - should "execute the right command" do - Paperclip.expects(:path_for_command).with("convert").returns("/usr/bin/convert") - Paperclip.expects(:bit_bucket).returns("/dev/null") - Paperclip.expects(:"`").with("/usr/bin/convert one.jpg two.jpg 2>/dev/null") - Paperclip.run("convert", "one.jpg two.jpg") - end - end - end - - context "Calling Paperclip.run with no path specified" do - setup do - Paperclip.options[:image_magick_path] = nil - Paperclip.options[:convert_path] = nil - end - - should "execute the right command" do - Paperclip.expects(:path_for_command).with("convert").returns("convert") - Paperclip.expects(:bit_bucket).returns("/dev/null") - Paperclip.expects(:"`").with("convert one.jpg two.jpg 2>/dev/null") - Paperclip.run("convert", "one.jpg two.jpg") - end - end - - should "raise when sent #processor and the name of a class that exists but isn't a subclass of Processor" do - assert_raises(Paperclip::PaperclipError){ Paperclip.processor(:attachment) } - end - - should "raise when sent #processor and the name of a class that doesn't exist" do - assert_raises(NameError){ Paperclip.processor(:boogey_man) } - end - - should "return a class when sent #processor and the name of a class under Paperclip" do - assert_equal ::Paperclip::Thumbnail, Paperclip.processor(:thumbnail) - end - - context "Paperclip.bit_bucket" do - context "on systems without /dev/null" do - setup do - File.expects(:exists?).with("/dev/null").returns(false) - end - - should "return 'NUL'" do - assert_equal "NUL", Paperclip.bit_bucket - end - end - - context "on systems with /dev/null" do - setup do - File.expects(:exists?).with("/dev/null").returns(true) - end - - should "return '/dev/null'" do - assert_equal "/dev/null", Paperclip.bit_bucket - end - end - end - - context "An ActiveRecord model with an 'avatar' attachment" do - setup do - rebuild_model :path => "tmp/:class/omg/:style.:extension" - @file = File.new(File.join(FIXTURES_DIR, "5k.png"), 'rb') - end - - teardown { @file.close } - - should "not error when trying to also create a 'blah' attachment" do - assert_nothing_raised do - Dummy.class_eval do - has_attached_file :blah - end - end - end - - context "that is attr_protected" do - setup do - Dummy.class_eval do - attr_protected :avatar - end - @dummy = Dummy.new - end - - should "not assign the avatar on mass-set" do - @dummy.attributes = { :other => "I'm set!", - :avatar => @file } - - assert_equal "I'm set!", @dummy.other - assert ! @dummy.avatar? - end - - should "still allow assigment on normal set" do - @dummy.other = "I'm set!" - @dummy.avatar = @file - - assert_equal "I'm set!", @dummy.other - assert @dummy.avatar? - end - end - - context "with a subclass" do - setup do - class ::SubDummy < Dummy; end - end - - should "be able to use the attachment from the subclass" do - assert_nothing_raised do - @subdummy = SubDummy.create(:avatar => @file) - end - end - - should "be able to see the attachment definition from the subclass's class" do - assert_equal "tmp/:class/omg/:style.:extension", SubDummy.attachment_definitions[:avatar][:path] - end - - teardown do - Object.send(:remove_const, "SubDummy") rescue nil - end - end - - should "have an #avatar method" do - assert Dummy.new.respond_to?(:avatar) - end - - should "have an #avatar= method" do - assert Dummy.new.respond_to?(:avatar=) - end - - context "that is valid" do - setup do - @dummy = Dummy.new - @dummy.avatar = @file - end - - should "be valid" do - assert @dummy.valid? - end - - context "then has a validation added that makes it invalid" do - setup do - assert @dummy.save - Dummy.class_eval do - validates_attachment_content_type :avatar, :content_type => ["text/plain"] - end - @dummy2 = Dummy.find(@dummy.id) - end - - should "be invalid when reloaded" do - assert ! @dummy2.valid?, @dummy2.errors.inspect - end - - should "be able to call #valid? twice without having duplicate errors" do - @dummy2.avatar.valid? - first_errors = @dummy2.avatar.errors - @dummy2.avatar.valid? - assert_equal first_errors, @dummy2.avatar.errors - end - end - end - - def self.should_validate validation, options, valid_file, invalid_file - context "with #{validation} validation and #{options.inspect} options" do - setup do - Dummy.send(:"validates_attachment_#{validation}", :avatar, options) - @dummy = Dummy.new - end - context "and assigning nil" do - setup do - @dummy.avatar = nil - @dummy.valid? - end - if validation == :presence - should "have an error on the attachment" do - assert @dummy.errors.on(:avatar) - end - else - should "not have an error on the attachment" do - assert_nil @dummy.errors.on(:avatar) - end - end - end - context "and assigned a valid file" do - setup do - @dummy.avatar = valid_file - @dummy.valid? - end - should "not have an error when assigned a valid file" do - assert ! @dummy.avatar.errors.key?(validation) - end - should "not have an error on the attachment" do - assert_nil @dummy.errors.on(:avatar) - end - end - context "and assigned an invalid file" do - setup do - @dummy.avatar = invalid_file - @dummy.valid? - end - should "have an error when assigned a valid file" do - assert_not_nil @dummy.avatar.errors[validation] - end - should "have an error on the attachment" do - assert @dummy.errors.on(:avatar) - end - end - end - end - - [[:presence, {}, "5k.png", nil], - [:size, {:in => 1..10240}, nil, "12k.png"], - [:size, {:less_than => 10240}, "5k.png", "12k.png"], - [:size, {:greater_than => 8096}, "12k.png", "5k.png"], - [:content_type, {:content_type => "image/png"}, "5k.png", "text.txt"], - [:content_type, {:content_type => "text/plain"}, "text.txt", "5k.png"], - [:content_type, {:content_type => %r{image/.*}}, "5k.png", "text.txt"]].each do |args| - validation, options, valid_file, invalid_file = args - valid_file &&= File.open(File.join(FIXTURES_DIR, valid_file), "rb") - invalid_file &&= File.open(File.join(FIXTURES_DIR, invalid_file), "rb") - - should_validate validation, options, valid_file, invalid_file - end - - end -end diff --git a/vendor/plugins/paperclip/test/processor_test.rb b/vendor/plugins/paperclip/test/processor_test.rb deleted file mode 100644 index a05f0a9d..00000000 --- a/vendor/plugins/paperclip/test/processor_test.rb +++ /dev/null @@ -1,10 +0,0 @@ -require 'test/helper' - -class ProcessorTest < Test::Unit::TestCase - should "instantiate and call #make when sent #make to the class" do - processor = mock - processor.expects(:make).with() - Paperclip::Processor.expects(:new).with(:one, :two, :three).returns(processor) - Paperclip::Processor.make(:one, :two, :three) - end -end diff --git a/vendor/plugins/paperclip/test/storage_test.rb b/vendor/plugins/paperclip/test/storage_test.rb deleted file mode 100644 index e2ed8a44..00000000 --- a/vendor/plugins/paperclip/test/storage_test.rb +++ /dev/null @@ -1,277 +0,0 @@ -require 'test/helper' - -class StorageTest < Test::Unit::TestCase - context "Parsing S3 credentials" do - setup do - rebuild_model :storage => :s3, - :bucket => "testing", - :s3_credentials => {:not => :important} - - @dummy = Dummy.new - @avatar = @dummy.avatar - - @current_env = ENV['RAILS_ENV'] - end - - teardown do - ENV['RAILS_ENV'] = @current_env - end - - should "get the correct credentials when RAILS_ENV is production" do - ENV['RAILS_ENV'] = 'production' - assert_equal({:key => "12345"}, - @avatar.parse_credentials('production' => {:key => '12345'}, - :development => {:key => "54321"})) - end - - should "get the correct credentials when RAILS_ENV is development" do - ENV['RAILS_ENV'] = 'development' - assert_equal({:key => "54321"}, - @avatar.parse_credentials('production' => {:key => '12345'}, - :development => {:key => "54321"})) - end - - should "return the argument if the key does not exist" do - ENV['RAILS_ENV'] = "not really an env" - assert_equal({:test => "12345"}, @avatar.parse_credentials(:test => "12345")) - end - end - - context "" do - setup do - rebuild_model :storage => :s3, - :s3_credentials => {}, - :bucket => "bucket", - :path => ":attachment/:basename.:extension", - :url => ":s3_path_url" - @dummy = Dummy.new - @dummy.avatar = StringIO.new(".") - end - - should "return a url based on an S3 path" do - assert_match %r{^http://s3.amazonaws.com/bucket/avatars/stringio.txt}, @dummy.avatar.url - end - end - context "" do - setup do - rebuild_model :storage => :s3, - :s3_credentials => {}, - :bucket => "bucket", - :path => ":attachment/:basename.:extension", - :url => ":s3_domain_url" - @dummy = Dummy.new - @dummy.avatar = StringIO.new(".") - end - - should "return a url based on an S3 subdomain" do - assert_match %r{^http://bucket.s3.amazonaws.com/avatars/stringio.txt}, @dummy.avatar.url - end - end - context "" do - setup do - rebuild_model :storage => :s3, - :s3_credentials => { - :production => { :bucket => "prod_bucket" }, - :development => { :bucket => "dev_bucket" } - }, - :s3_host_alias => "something.something.com", - :path => ":attachment/:basename.:extension", - :url => ":s3_alias_url" - @dummy = Dummy.new - @dummy.avatar = StringIO.new(".") - end - - should "return a url based on the host_alias" do - assert_match %r{^http://something.something.com/avatars/stringio.txt}, @dummy.avatar.url - end - end - - context "Parsing S3 credentials with a bucket in them" do - setup do - rebuild_model :storage => :s3, - :s3_credentials => { - :production => { :bucket => "prod_bucket" }, - :development => { :bucket => "dev_bucket" } - } - @dummy = Dummy.new - end - - should "get the right bucket in production", :before => lambda{ ENV.expects(:[]).returns('production') } do - assert_equal "prod_bucket", @dummy.avatar.bucket_name - end - - should "get the right bucket in development", :before => lambda{ ENV.expects(:[]).returns('development') } do - assert_equal "dev_bucket", @dummy.avatar.bucket_name - end - end - - context "An attachment with S3 storage" do - setup do - rebuild_model :storage => :s3, - :bucket => "testing", - :path => ":attachment/:style/:basename.:extension", - :s3_credentials => { - 'access_key_id' => "12345", - 'secret_access_key' => "54321" - } - end - - should "be extended by the S3 module" do - assert Dummy.new.avatar.is_a?(Paperclip::Storage::S3) - end - - should "not be extended by the Filesystem module" do - assert ! Dummy.new.avatar.is_a?(Paperclip::Storage::Filesystem) - end - - context "when assigned" do - setup do - @file = File.new(File.join(File.dirname(__FILE__), 'fixtures', '5k.png'), 'rb') - @dummy = Dummy.new - @dummy.avatar = @file - end - - teardown { @file.close } - - should "not get a bucket to get a URL" do - @dummy.avatar.expects(:s3).never - @dummy.avatar.expects(:s3_bucket).never - assert_match %r{^http://s3\.amazonaws\.com/testing/avatars/original/5k\.png}, @dummy.avatar.url - end - - context "and saved" do - setup do - @s3_mock = stub - @bucket_mock = stub - RightAws::S3.expects(:new).with("12345", "54321", {}).returns(@s3_mock) - @s3_mock.expects(:bucket).with("testing", true, "public-read").returns(@bucket_mock) - @key_mock = stub - @bucket_mock.expects(:key).returns(@key_mock) - @key_mock.expects(:data=) - @key_mock.expects(:put).with(nil, 'public-read', 'Content-type' => 'image/png') - @dummy.save - end - - should "succeed" do - assert true - end - end - - context "and remove" do - setup do - @s3_mock = stub - @bucket_mock = stub - RightAws::S3.expects(:new).with("12345", "54321", {}).returns(@s3_mock) - @s3_mock.expects(:bucket).with("testing", true, "public-read").returns(@bucket_mock) - @key_mock = stub - @bucket_mock.expects(:key).at_least(2).returns(@key_mock) - @key_mock.expects(:delete) - @dummy.destroy_attached_files - end - - should "succeed" do - assert true - end - end - end - end - - context "An attachment with S3 storage and bucket defined as a Proc" do - setup do - rebuild_model :storage => :s3, - :bucket => lambda { |attachment| "bucket_#{attachment.instance.other}" }, - :s3_credentials => {:not => :important} - end - - should "get the right bucket name" do - assert "bucket_a", Dummy.new(:other => 'a').avatar.bucket_name - assert "bucket_b", Dummy.new(:other => 'b').avatar.bucket_name - end - end - - context "An attachment with S3 storage and specific s3 headers set" do - setup do - rebuild_model :storage => :s3, - :bucket => "testing", - :path => ":attachment/:style/:basename.:extension", - :s3_credentials => { - 'access_key_id' => "12345", - 'secret_access_key' => "54321" - }, - :s3_headers => {'Cache-Control' => 'max-age=31557600'} - end - - context "when assigned" do - setup do - @file = File.new(File.join(File.dirname(__FILE__), 'fixtures', '5k.png'), 'rb') - @dummy = Dummy.new - @dummy.avatar = @file - end - - teardown { @file.close } - - context "and saved" do - setup do - @s3_mock = stub - @bucket_mock = stub - RightAws::S3.expects(:new).with("12345", "54321", {}).returns(@s3_mock) - @s3_mock.expects(:bucket).with("testing", true, "public-read").returns(@bucket_mock) - @key_mock = stub - @bucket_mock.expects(:key).returns(@key_mock) - @key_mock.expects(:data=) - @key_mock.expects(:put).with(nil, - 'public-read', - 'Content-type' => 'image/png', - 'Cache-Control' => 'max-age=31557600') - @dummy.save - end - - should "succeed" do - assert true - end - end - end - end - - unless ENV["S3_TEST_BUCKET"].blank? - context "Using S3 for real, an attachment with S3 storage" do - setup do - rebuild_model :styles => { :thumb => "100x100", :square => "32x32#" }, - :storage => :s3, - :bucket => ENV["S3_TEST_BUCKET"], - :path => ":class/:attachment/:id/:style.:extension", - :s3_credentials => File.new(File.join(File.dirname(__FILE__), "s3.yml")) - - Dummy.delete_all - @dummy = Dummy.new - end - - should "be extended by the S3 module" do - assert Dummy.new.avatar.is_a?(Paperclip::Storage::S3) - end - - context "when assigned" do - setup do - @file = File.new(File.join(File.dirname(__FILE__), 'fixtures', '5k.png'), 'rb') - @dummy.avatar = @file - end - - teardown { @file.close } - - should "still return a Tempfile when sent #to_io" do - assert_equal Tempfile, @dummy.avatar.to_io.class - end - - context "and saved" do - setup do - @dummy.save - end - - should "be on S3" do - assert true - end - end - end - end - end -end diff --git a/vendor/plugins/paperclip/test/thumbnail_test.rb b/vendor/plugins/paperclip/test/thumbnail_test.rb deleted file mode 100644 index 624e7fa4..00000000 --- a/vendor/plugins/paperclip/test/thumbnail_test.rb +++ /dev/null @@ -1,177 +0,0 @@ -require 'test/helper' - -class ThumbnailTest < Test::Unit::TestCase - - context "A Paperclip Tempfile" do - setup do - @tempfile = Paperclip::Tempfile.new("file.jpg") - end - - should "have its path contain a real extension" do - assert_equal ".jpg", File.extname(@tempfile.path) - end - - should "be a real Tempfile" do - assert @tempfile.is_a?(::Tempfile) - end - end - - context "Another Paperclip Tempfile" do - setup do - @tempfile = Paperclip::Tempfile.new("file") - end - - should "not have an extension if not given one" do - assert_equal "", File.extname(@tempfile.path) - end - - should "still be a real Tempfile" do - assert @tempfile.is_a?(::Tempfile) - end - end - - context "An image" do - setup do - @file = File.new(File.join(File.dirname(__FILE__), "fixtures", "5k.png"), 'rb') - end - - teardown { @file.close } - - [["600x600>", "434x66"], - ["400x400>", "400x61"], - ["32x32<", "434x66"] - ].each do |args| - context "being thumbnailed with a geometry of #{args[0]}" do - setup do - @thumb = Paperclip::Thumbnail.new(@file, :geometry => args[0]) - end - - should "start with dimensions of 434x66" do - cmd = %Q[identify -format "%wx%h" "#{@file.path}"] - assert_equal "434x66", `#{cmd}`.chomp - end - - should "report the correct target geometry" do - assert_equal args[0], @thumb.target_geometry.to_s - end - - context "when made" do - setup do - @thumb_result = @thumb.make - end - - should "be the size we expect it to be" do - cmd = %Q[identify -format "%wx%h" "#{@thumb_result.path}"] - assert_equal args[1], `#{cmd}`.chomp - end - end - end - end - - context "being thumbnailed at 100x50 with cropping" do - setup do - @thumb = Paperclip::Thumbnail.new(@file, :geometry => "100x50#") - end - - should "report its correct current and target geometries" do - assert_equal "100x50#", @thumb.target_geometry.to_s - assert_equal "434x66", @thumb.current_geometry.to_s - end - - should "report its correct format" do - assert_nil @thumb.format - end - - should "have whiny turned on by default" do - assert @thumb.whiny - end - - should "have convert_options set to nil by default" do - assert_equal nil, @thumb.convert_options - end - - should "send the right command to convert when sent #make" do - Paperclip.expects(:"`").with do |arg| - arg.match %r{convert\s+"#{File.expand_path(@thumb.file.path)}\[0\]"\s+-resize\s+\"x50\"\s+-crop\s+\"100x50\+114\+0\"\s+\+repage\s+".*?"} - end - @thumb.make - end - - should "create the thumbnail when sent #make" do - dst = @thumb.make - assert_match /100x50/, `identify "#{dst.path}"` - end - end - - context "being thumbnailed with convert options set" do - setup do - @thumb = Paperclip::Thumbnail.new(@file, - :geometry => "100x50#", - :convert_options => "-strip -depth 8") - end - - should "have convert_options value set" do - assert_equal "-strip -depth 8", @thumb.convert_options - end - - should "send the right command to convert when sent #make" do - Paperclip.expects(:"`").with do |arg| - arg.match %r{convert\s+"#{File.expand_path(@thumb.file.path)}\[0\]"\s+-resize\s+"x50"\s+-crop\s+"100x50\+114\+0"\s+\+repage\s+-strip\s+-depth\s+8\s+".*?"} - end - @thumb.make - end - - should "create the thumbnail when sent #make" do - dst = @thumb.make - assert_match /100x50/, `identify "#{dst.path}"` - end - - context "redefined to have bad convert_options setting" do - setup do - @thumb = Paperclip::Thumbnail.new(@file, - :geometry => "100x50#", - :convert_options => "-this-aint-no-option") - end - - should "error when trying to create the thumbnail" do - assert_raises(Paperclip::PaperclipError) do - @thumb.make - end - end - end - end - end - - context "A multipage PDF" do - setup do - @file = File.new(File.join(File.dirname(__FILE__), "fixtures", "twopage.pdf"), 'rb') - end - - teardown { @file.close } - - should "start with two pages with dimensions 612x792" do - cmd = %Q[identify -format "%wx%h" "#{@file.path}"] - assert_equal "612x792"*2, `#{cmd}`.chomp - end - - context "being thumbnailed at 100x100 with cropping" do - setup do - @thumb = Paperclip::Thumbnail.new(@file, :geometry => "100x100#", :format => :png) - end - - should "report its correct current and target geometries" do - assert_equal "100x100#", @thumb.target_geometry.to_s - assert_equal "612x792", @thumb.current_geometry.to_s - end - - should "report its correct format" do - assert_equal :png, @thumb.format - end - - should "create the thumbnail when sent #make" do - dst = @thumb.make - assert_match /100x100/, `identify "#{dst.path}"` - end - end - end -end -- cgit v1.3