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:
Diffstat (limited to 'spec/workers/cleanup_pending_photos_spec.rb')
-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