Skip to content

Commit

Permalink
Fix for broken validate_attachment_content_type matcher (github issue…
Browse files Browse the repository at this point in the history
… 211)
  • Loading branch information
Jake Paul authored and Jon Yurek committed Jul 1, 2010
1 parent 44b02fa commit ae9d7e9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 10 additions & 0 deletions test/matchers/validate_attachment_content_type_matcher_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.