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
31 lines
865 B
Ruby
31 lines
865 B
Ruby
# 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
|