Sha256: 615700aff70691d7472b8b4169744c2a988032cade415f51714cfe34739429b4

Contents?: true

Size: 1.41 KB

Versions: 24

Compression:

Stored size: 1.41 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 :title
        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

    context "given a class with no validation" do
      should_reject_dummy_class
    end

    context "given a class with a validation that doesn't match" do
      setup do
        @dummy_class.validates_attachment_content_type :avatar, :content_type => %r{audio/.*}
      end

      should_reject_dummy_class
    end

    context "given a class with a matching validation" do
      setup do
        @dummy_class.validates_attachment_content_type :avatar, :content_type => %r{image/.*}
      end

      should_accept_dummy_class
    end
    
    context "given a class with other validations but matching types" do
      setup do
        @dummy_class.validates_presence_of :title
        @dummy_class.validates_attachment_content_type :avatar, :content_type => %r{image/.*}
      end
      
      should_accept_dummy_class
    end
  end
end

Version data entries

24 entries across 24 versions & 11 rubygems

Version Path
cemeng-paperclip-2.3.6 test/matchers/validate_attachment_content_type_matcher_test.rb
paperclip-cloudfiles-2.3.8.6 test/matchers/validate_attachment_content_type_matcher_test.rb
sayso-paperclip-2.3.10.001 test/matchers/validate_attachment_content_type_matcher_test.rb
paperclip-cloudfiles-2.3.8.5 test/matchers/validate_attachment_content_type_matcher_test.rb
ryansch-paperclip-2.3.10 test/matchers/validate_attachment_content_type_matcher_test.rb
paperclip-2.3.11 test/matchers/validate_attachment_content_type_matcher_test.rb
paperclip-2.3.10 test/matchers/validate_attachment_content_type_matcher_test.rb
paperclip-2.3.9 test/matchers/validate_attachment_content_type_matcher_test.rb
paperclip-cloudfiles-2.3.8.4 test/matchers/validate_attachment_content_type_matcher_test.rb
paperclip-youtube-2.3.8.2 test/matchers/validate_attachment_content_type_matcher_test.rb
paperclip-youtube-2.3.8.1 test/matchers/validate_attachment_content_type_matcher_test.rb
paperclip-cloudfiles-2.3.8.3 test/matchers/validate_attachment_content_type_matcher_test.rb
whitby3001-paperclip-cloudfiles-2.3.8.1 test/matchers/validate_attachment_content_type_matcher_test.rb
organicinternet-paperclip-2.3.8.1 test/matchers/validate_attachment_content_type_matcher_test.rb
arielvalentin-paperclip-2.3.6 test/matchers/validate_attachment_content_type_matcher_test.rb
paperclip-cloudfiles-2.3.8.1 test/matchers/validate_attachment_content_type_matcher_test.rb
twm_paperclip-2.3.8t test/matchers/validate_attachment_content_type_matcher_test.rb
reenhanced-paperclip-2.3.8 test/matchers/validate_attachment_content_type_matcher_test.rb
paperclip-cloudfiles-2.3.8 test/matchers/validate_attachment_content_type_matcher_test.rb
paperclip-2.3.8 test/matchers/validate_attachment_content_type_matcher_test.rb