From 073c06c1ed450cf8150e4702a1a5f3b4b51c717b Mon Sep 17 00:00:00 2001 From: Tom Counsell Date: Tue, 10 Jul 2012 17:29:39 +0100 Subject: [PATCH] Extra tests for #947 to check works in more situations --- test/integration_test.rb | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/test/integration_test.rb b/test/integration_test.rb index f1ae492f7..f1523ae8e 100644 --- a/test/integration_test.rb +++ b/test/integration_test.rb @@ -641,7 +641,7 @@ def s3_headers_for attachment, style end end - context "Copying attachment between models" do + context "Copying attachments between models" do setup do rebuild_model @file = File.new(fixture_file("5k.png"), 'rb') @@ -649,11 +649,28 @@ def s3_headers_for attachment, style teardown { @file.close } - should "should succeed when attachment is empty" do + should "succeed when original attachment is a file" do + original = Dummy.new + original.avatar = @file + assert original.save + + copy = Dummy.new + copy.avatar = original.avatar + assert copy.save + + assert copy.avatar.present? + end + + should "succeed when original attachment is empty" do original = Dummy.create! + copy = Dummy.new + copy.avatar = @file + assert copy.save + assert copy.avatar.present? + copy.avatar = original.avatar - copy.save + assert copy.save assert !copy.avatar.present? end end