Permalink
Browse files

Fix for broken validate_attachment_content_type matcher (github issue…

… 211)
  • Loading branch information...
1 parent 44b02fa commit ae9d7e91b4125b51904c83deb0fa7c0013de5bea @jcbpl jcbpl committed with jyurek Jul 1, 2010
View
3 lib/paperclip/matchers/validate_attachment_content_type_matcher.rb
@@ -57,7 +57,8 @@ def allow_types?(types)
file = StringIO.new(".")
file.content_type = type
(subject = @subject.new).attachment_for(@attachment_name).assign(file)
- subject.valid? && subject.errors[:"#{@attachment_name}_content_type"].blank?
+ subject.valid?
+ subject.errors[:"#{@attachment_name}_content_type"].blank?
end
end
View
10 test/matchers/validate_attachment_content_type_matcher_test.rb
@@ -4,6 +4,7 @@ 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
@@ -33,5 +34,14 @@ class ValidateAttachmentContentTypeMatcherTest < Test::Unit::TestCase
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

0 comments on commit ae9d7e9

Please sign in to comment.