Commit 073c06c1 by Tom Counsell Committed by Prem Sichanugrist

Extra tests for #947 to check works in more situations

parent b256381c
...@@ -641,7 +641,7 @@ class IntegrationTest < Test::Unit::TestCase ...@@ -641,7 +641,7 @@ class IntegrationTest < Test::Unit::TestCase
end end
end end
context "Copying attachment between models" do context "Copying attachments between models" do
setup do setup do
rebuild_model rebuild_model
@file = File.new(fixture_file("5k.png"), 'rb') @file = File.new(fixture_file("5k.png"), 'rb')
...@@ -649,11 +649,28 @@ class IntegrationTest < Test::Unit::TestCase ...@@ -649,11 +649,28 @@ class IntegrationTest < Test::Unit::TestCase
teardown { @file.close } 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! original = Dummy.create!
copy = Dummy.new copy = Dummy.new
copy.avatar = @file
assert copy.save
assert copy.avatar.present?
copy.avatar = original.avatar copy.avatar = original.avatar
copy.save assert copy.save
assert !copy.avatar.present? assert !copy.avatar.present?
end end
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