2023-05-24 18:55:40 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
require 'mastodon/cli/preview_cards'
|
|
|
|
|
|
|
|
describe Mastodon::CLI::PreviewCards do
|
2023-10-17 20:06:16 +09:00
|
|
|
let(:cli) { described_class.new }
|
|
|
|
|
2023-12-01 21:00:34 +09:00
|
|
|
it_behaves_like 'CLI Command'
|
2023-10-17 20:06:16 +09:00
|
|
|
|
|
|
|
describe '#remove' do
|
|
|
|
context 'with relevant preview cards' do
|
|
|
|
before do
|
|
|
|
Fabricate(:preview_card, updated_at: 10.years.ago, type: :link)
|
|
|
|
Fabricate(:preview_card, updated_at: 10.months.ago, type: :photo)
|
|
|
|
Fabricate(:preview_card, updated_at: 10.days.ago, type: :photo)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with no arguments' do
|
|
|
|
it 'deletes thumbnails for local preview cards' do
|
|
|
|
expect { cli.invoke(:remove) }.to output(
|
|
|
|
a_string_including('Removed 2 preview cards')
|
|
|
|
.and(a_string_including('approx. 119 KB'))
|
|
|
|
).to_stdout
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with the --link option' do
|
|
|
|
let(:options) { { link: true } }
|
|
|
|
|
|
|
|
it 'deletes thumbnails for local preview cards' do
|
|
|
|
expect { cli.invoke(:remove, [], options) }.to output(
|
|
|
|
a_string_including('Removed 1 link-type preview cards')
|
|
|
|
.and(a_string_including('approx. 59.6 KB'))
|
|
|
|
).to_stdout
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with the --days option' do
|
|
|
|
let(:options) { { days: 365 } }
|
|
|
|
|
|
|
|
it 'deletes thumbnails for local preview cards' do
|
|
|
|
expect { cli.invoke(:remove, [], options) }.to output(
|
|
|
|
a_string_including('Removed 1 preview cards')
|
|
|
|
.and(a_string_including('approx. 59.6 KB'))
|
|
|
|
).to_stdout
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2023-05-24 18:55:40 +09:00
|
|
|
end
|