spec/integration_spec.rb in paperclip-storage-ftp-1.2.6 vs spec/integration_spec.rb in paperclip-storage-ftp-1.2.7
- old
+ new
@@ -135,6 +135,20 @@
Timeout.timeout(UserWithConnectTimeout::TIMEOUT + 1) do
expect { user.save! }.to raise_error(Errno::ETIMEDOUT)
end
end
end
+
+ context "performance" do
+ let(:user) { UserWithOneServerAndDeepPath.new }
+ let(:padded_user_id) { user.id.to_s.rjust(3, "0") }
+ let(:uploaded_file_deep_path) { FtpServer::USER1_PATH + "/img/user_with_one_server_and_deep_paths/avatars/000/000/#{padded_user_id}/original/avatar.jpg" }
+
+ it "triggers minimal amount of ftp commands" do
+ expect_any_instance_of(Net::FTP).to receive(:nlst).exactly(7).times.and_call_original
+ expect_any_instance_of(Net::FTP).to receive(:mkdir).exactly(9).times.and_call_original
+ user.avatar = file
+ user.save!
+ File.exist?(uploaded_file_deep_path).should be true
+ end
+ end
end