spec/paperclip/storage/ftp_spec.rb in paperclip-storage-ftp-1.2.3 vs spec/paperclip/storage/ftp_spec.rb in paperclip-storage-ftp-1.2.4
- old
+ new
@@ -78,10 +78,21 @@
attachment.to_file.should == file
end
end
context "#flush_writes" do
+ it "doesn't connect to the servers if there is nothing to write" do
+ attachment.instance_variable_set(:@queued_for_write, {})
+
+ attachment.should_not_receive(:with_ftp_servers)
+ attachment.should_receive(:after_flush_writes).with(no_args)
+
+ attachment.flush_writes
+
+ attachment.queued_for_write.should == {}
+ end
+
it "stores the files on every server" do
original_file = double("original_file", :path => "/tmp/original/foo.jpg")
thumb_file = double("thumb_file", :path => "/tmp/thumb/foo.jpg")
attachment.instance_variable_set(:@queued_for_write, {
@@ -103,9 +114,19 @@
attachment.queued_for_write.should == {}
end
end
context "#flush_deletes" do
+ it "doesn't connect to the servers if there is nothing to delete" do
+ attachment.instance_variable_set(:@queued_for_delete, [])
+
+ attachment.should_not_receive(:with_ftp_servers)
+
+ attachment.flush_deletes
+
+ attachment.instance_variable_get(:@queued_for_delete).should == []
+ end
+
it "deletes the files on every server" do
attachment.instance_variable_set(:@queued_for_delete, [
"/files/original/foo.jpg",
"/files/thumb/foo.jpg"
])