<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>test/fixtures/text.txt</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -2,3 +2,4 @@
 *.swp
 tmp
 s3.yml
+public
\ No newline at end of file</diff>
      <filename>.gitignore</filename>
    </modified>
    <modified>
      <diff>@@ -37,6 +37,9 @@ require 'paperclip/attachment'
 module Paperclip
 
   VERSION = &quot;2.1.0&quot;
+  
+  @@content_types      = ['image/jpeg', 'image/pjpeg', 'image/gif', 'image/png', 'image/x-png', 'image/jpg']
+  mattr_reader :content_types
 
   class &lt;&lt; self
     # Provides configurability to Paperclip. There are a number of options available, such as:
@@ -166,6 +169,22 @@ module Paperclip
         end
       end
     end
+    
+    # Places ActiveRecord-style validations on the content type of the file assigned. The
+    # possible options are:
+    # * +content_type+: Allowed content types.  Can be a single content type or an array.  Allows all by default.  Use :image to allow all standard image types.
+    # * +message+: The message to display when the uploaded file has an invalid content type.
+    def validates_attachment_content_type name, options = {}
+      attachment_definitions[name][:validations] &lt;&lt; lambda do |attachment, instance|
+        options[:content_type] = [options[:content_type]].flatten.collect! { |t| t == :image ? Paperclip.content_types : t }.flatten unless options[:content_type].nil?
+        
+        unless options[:content_type].empty?
+          unless options[:content_type].include?(instance[:&quot;#{name}_content_type&quot;])
+            options[:message] || ActiveRecord::Errors.default_error_messages[:inclusion]
+          end
+        end
+      end
+    end
 
     # Returns the attachment definitions defined by each call to has_attached_file.
     def attachment_definitions</diff>
      <filename>lib/paperclip.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,7 +9,8 @@ module Paperclip
       type = self.path.match(/\.(\w+)$/)[1] rescue &quot;octet-stream&quot;
       case type
       when &quot;jpg&quot;, &quot;png&quot;, &quot;gif&quot; then &quot;image/#{type}&quot;
-      when &quot;txt&quot;, &quot;csv&quot;, &quot;xml&quot;, &quot;html&quot;, &quot;htm&quot;, &quot;css&quot;, &quot;js&quot; then &quot;text/#{type}&quot;
+      when &quot;txt&quot; then &quot;text/plain&quot;
+      when &quot;csv&quot;, &quot;xml&quot;, &quot;html&quot;, &quot;htm&quot;, &quot;css&quot;, &quot;js&quot; then &quot;text/#{type}&quot;
       else &quot;x-application/#{type}&quot;
       end
     end</diff>
      <filename>lib/paperclip/upfile.rb</filename>
    </modified>
    <modified>
      <diff>@@ -64,12 +64,15 @@ class PaperclipTest &lt; Test::Unit::TestCase
       assert Dummy.new.respond_to?(:avatar=)
     end
 
-    [[:presence,   nil,               &quot;5k.png&quot;, nil],
-     [:size,       {:in =&gt; 1..10240}, &quot;5k.png&quot;, &quot;12k.png&quot;]].each do |args|
+    [[:presence,   nil,                                &quot;5k.png&quot;, nil],
+     [:size,       {:in =&gt; 1..10240},                  &quot;5k.png&quot;, &quot;12k.png&quot;],
+     [:content_type1,{:content_type =&gt; &quot;image/png&quot;},   &quot;5k.png&quot;, &quot;text.txt&quot;],
+     [:content_type2, {:content_type =&gt; :image},       &quot;5k.png&quot;, &quot;text.txt&quot;],
+     [:content_type3, {:content_type =&gt; &quot;text/plain&quot;}, &quot;text.txt&quot;, &quot;5k.png&quot;]].each do |args|
       context &quot;with #{args[0]} validations&quot; do
         setup do
           Dummy.class_eval do
-            send(*[:&quot;validates_attachment_#{args[0]}&quot;, :avatar, args[1]].compact)
+            send(*[:&quot;validates_attachment_#{args[0].to_s[/[a-z_]*/]}&quot;, :avatar, args[1]].compact)
           end
           @dummy = Dummy.new
         end</diff>
      <filename>test/test_paperclip.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>5bbafae09788d25a85fbfecf57791480a9dd0754</id>
    </parent>
  </parents>
  <author>
    <name>austin.bain</name>
    <email>austin@austin-bains-macbook-pro.local</email>
  </author>
  <url>http://github.com/jim/paperclip/commit/044acfcd9ba187f1b17bc7ebabec6681477f79c3</url>
  <id>044acfcd9ba187f1b17bc7ebabec6681477f79c3</id>
  <committed-date>2008-05-02T13:34:39-07:00</committed-date>
  <authored-date>2008-05-02T13:34:39-07:00</authored-date>
  <message>Added a validation to validate against the content-type

Added tests to prove that the new validation is working.
Added the public directory to .gitignore
Changed the upfile content_type code to assign txt files to text/plain mime type</message>
  <tree>6e4df831970aaddfa081a9fc3bc28f96ffb8fc13</tree>
  <committer>
    <name>austin.bain</name>
    <email>austin@austin-bains-macbook-pro.local</email>
  </committer>
</commit>
