Skip to content

Commit

Permalink
Extra tests for thoughtbot#947 to check works in more situations
Browse files Browse the repository at this point in the history
  • Loading branch information
tamc committed Jul 10, 2012
1 parent 4d87f60 commit 493604c
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions test/integration_test.rb
Expand Up @@ -641,19 +641,36 @@ 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')
end

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
Expand Down

0 comments on commit 493604c

Please sign in to comment.