Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
Add @mraidel test coverage
Browse files Browse the repository at this point in the history
See: #2540
  • Loading branch information
Sid Raval committed Mar 2, 2018
1 parent 7ed9ec1 commit 282f1b3
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions spec/paperclip/io_adapters/abstract_adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,39 @@ def content_type
expect { subject.original_filename = nil }.not_to raise_error
end
end

context "#link_or_copy_file" do
class TestLinkOrCopyAdapter < Paperclip::AbstractAdapter
public :copy_to_tempfile, :destination
end

subject { TestLinkOrCopyAdapter.new(nil) }
let(:body) { "body" }

let(:file) do
t = Tempfile.new("destination")
t.print(body)
t.rewind
t
end

after do
file.close
file.unlink
end

it "should be able to read the file" do
expect(subject.copy_to_tempfile(file).read).to eq(body)
end

it "should be able to reopen the file after symlink has failed" do
FileUtils.expects(:ln).raises(Errno::EXDEV)
# after the failed symlink the file reports a size of zero
# which makes it necessary to reopen it
# we simulate this condition by closing the file
subject.destination.close

expect(subject.copy_to_tempfile(file).read).to eq(body)
end
end
end

0 comments on commit 282f1b3

Please sign in to comment.