test/paperclip_test.rb in thoughtbot-paperclip-2.2.1 vs test/paperclip_test.rb in thoughtbot-paperclip-2.2.2
- old
+ new
@@ -175,9 +175,24 @@
context "with #{validation} validation and #{options.inspect} options" do
setup do
Dummy.send(:"validates_attachment_#{validation}", :avatar, options)
@dummy = Dummy.new
end
+ context "and assigning nil" do
+ setup do
+ @dummy.avatar = nil
+ @dummy.valid?
+ end
+ if validation == :presence
+ should "have an error on the attachment" do
+ assert @dummy.errors.on(:avatar)
+ end
+ else
+ should "not have an error on the attachment" do
+ assert_nil @dummy.errors.on(:avatar)
+ end
+ end
+ end
context "and assigned a valid file" do
setup do
@dummy.avatar = valid_file
@dummy.valid?
end