Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Neff <benjamin@coding4coffee.ch>2019-07-02 03:37:02 +0300
committerBenjamin Neff <benjamin@coding4coffee.ch>2019-07-03 14:24:27 +0300
commitdf4e79b842fa16b370c8c4b07b82bdd328f3ef7e (patch)
tree0f139c72c9f21f5ad0b2745d1f24cd8189483c8c /spec/workers
parent397dbdbee84182094c71f67ab1082c22a4166ac9 (diff)
Cleanup pending photos which were never posted with cronjob
Only delete photos older than a day, so we don't delete photos for posts which were uploaded 10 minutes ago and the author is still writing the post for it. closes #8041
Diffstat (limited to 'spec/workers')
-rw-r--r--spec/workers/cleanup_pending_photos_spec.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/workers/cleanup_pending_photos_spec.rb b/spec/workers/cleanup_pending_photos_spec.rb
new file mode 100644
index 000000000..1a92cac96
--- /dev/null
+++ b/spec/workers/cleanup_pending_photos_spec.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+describe Workers::CleanupPendingPhotos do
+ let!(:photo) { FactoryGirl.create(:photo, author: alice.person, pending: true) }
+
+ it "removes pending photos" do
+ Timecop.travel(25.hours) do
+ Workers::CleanupPendingPhotos.new.perform
+ expect(Photo).not_to exist(photo.id)
+ end
+ end
+
+ it "does not remove pending photos newer than one day" do
+ Timecop.travel(1.hour) do
+ Workers::CleanupPendingPhotos.new.perform
+ expect(Photo).to exist(photo.id)
+ end
+ end
+
+ it "does not remove posted photos" do
+ StatusMessageCreationService.new(alice).create(
+ status_message: {text: "Post with photo"},
+ public: true,
+ photos: [photo.id]
+ )
+ Timecop.travel(25.hours) do
+ Workers::CleanupPendingPhotos.new.perform
+ expect(Photo).to exist(photo.id)
+ end
+ end
+end