DEV: Convert the downsizing script to a rake task (#18976)

…to make it testable!
This commit is contained in:
Jarek Radosz
2022-11-11 13:00:44 +01:00
committed by GitHub
parent 39bf56959f
commit bc22fe4fdf
3 changed files with 160 additions and 146 deletions
+20
View File
@@ -216,4 +216,24 @@ RSpec.describe "tasks/uploads" do
)
end
end
describe "uploads:downsize" do
def invoke_task
capture_stdout do
Rake::Task["uploads:downsize"].invoke
end
end
before do
STDIN.stubs(:beep)
end
fab!(:upload) { Fabricate(:image_upload, width: 200, height: 200) }
it "corrects upload attributes" do
upload.update!(thumbnail_height: 0)
expect { invoke_task }.to change { upload.reload.thumbnail_height }.to(200)
end
end
end