Skip to content
Browse files

Change the content_type macro itself

  • Loading branch information...
1 parent 2824259 commit 9e73929c0717232a2067835da66c3ac4d378ef32 @jyurek jyurek committed Feb 7, 2009
Showing with 3 additions and 29 deletions.
  1. +3 −29 shoulda_macros/paperclip.rb
View
32 shoulda_macros/paperclip.rb
@@ -37,35 +37,9 @@ def should_validate_attachment_content_type name, options = {}
klass = self.name.gsub(/Test$/, '').constantize
valid = [options[:valid]].flatten
invalid = [options[:invalid]].flatten
- context "Class #{klass.name} validating content_types on #{name}" do
- valid.each do |type|
- context "being assigned a file with a content_type of #{type}" do
- setup do
- @file = StringIO.new(".")
- class << @file; attr_accessor :content_type; end
- @file.content_type = type
- @attachment = klass.new.send(name)
- @attachment.assign(@file)
- end
- should "not have a :content_type validation error" do
- assert ! @attachment.errors[:content_type]
- end
- end
- end
- invalid.each do |type|
- context "being assigned a file with a content_type of #{type}" do
- setup do
- @file = StringIO.new(".")
- class << @file; attr_accessor :content_type; end
- @file.content_type = type
- @attachment = klass.new.send(name)
- @attachment.assign(@file)
- end
- should "have a :content_type validation error" do
- assert @attachment.errors[:content_type]
- end
- end
- end
+ matcher = validate_attachment_presence(name).allows(valid).rejects(invalid)
+ should matcher.description do
+ assert_accepts(matcher, klass)
end
end

0 comments on commit 9e73929

Please sign in to comment.
Something went wrong with that request. Please try again.