Commit 9e73929c by Jon Yurek

Change the content_type macro itself

parent 28242594
......@@ -37,35 +37,9 @@ module Paperclip
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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment