Sha256: 65fd257f39e7d7629a2d722021e652a5a203419df54594851f748d36ee4e98c6

Contents?: true

Size: 1.07 KB

Versions: 17

Compression:

Stored size: 1.07 KB

Contents

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
        d.string :avatar_content_type
      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

Version data entries

17 entries across 17 versions & 7 rubygems

Version Path
paperclip-cloudfiles-2.3.1.1.6 test/matchers/validate_attachment_content_type_matcher_test.rb
paperclip-cloudfiles-2.3.1.1.5 test/matchers/validate_attachment_content_type_matcher_test.rb
mwd-paperclip-2.3.1.1b test/matchers/validate_attachment_content_type_matcher_test.rb
mwd-paperclip-2.3.1.1.mwd.b test/matchers/validate_attachment_content_type_matcher_test.rb
mwd-paperclip-2.3.1.1 test/matchers/validate_attachment_content_type_matcher_test.rb
alg-paperclip-2.3.1.2 test/matchers/validate_attachment_content_type_matcher_test.rb
bteitelb-paperclip-2.3.1.13 test/matchers/validate_attachment_content_type_matcher_test.rb
bteitelb-paperclip-2.3.1.12 test/matchers/validate_attachment_content_type_matcher_test.rb
alg-paperclip-2.3.1.1 test/matchers/validate_attachment_content_type_matcher_test.rb
paperclip-cloudfiles-2.3.1.1.4 test/matchers/validate_attachment_content_type_matcher_test.rb
paperclip-cloudfiles-2.3.1.1.3 test/matchers/validate_attachment_content_type_matcher_test.rb
paperclip-cloudfiles-2.3.1.1.2 test/matchers/validate_attachment_content_type_matcher_test.rb
paperclip-cloudfiles-2.3.1.1.1 test/matchers/validate_attachment_content_type_matcher_test.rb
tristandunn-paperclip-2.3.1.1 test/matchers/validate_attachment_content_type_matcher_test.rb
monde-paperclip-2.3.1.1 test/matchers/validate_attachment_content_type_matcher_test.rb
novelys-paperclip-2.3.1.1 test/matchers/validate_attachment_content_type_matcher_test.rb
paperclip-cloudfiles-2.3.1.1.0 test/matchers/validate_attachment_content_type_matcher_test.rb