Add coverage for CustomFilter#expires_in method (#33142)

This commit is contained in:
Matt Jankowski 2024-12-02 16:52:17 -05:00 committed by GitHub
parent 2381ed55d7
commit be43b01eb1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -27,4 +27,28 @@ RSpec.describe CustomFilter do
it { is_expected.to normalize(:context).from(['home', 'notifications', 'public ', '']).to(%w(home notifications public)) }
end
end
describe '#expires_in' do
subject { custom_filter.expires_in }
let(:custom_filter) { Fabricate.build(:custom_filter, expires_at: expires_at) }
context 'when expires_at is nil' do
let(:expires_at) { nil }
it { is_expected.to be_nil }
end
context 'when expires is beyond the end of the range' do
let(:expires_at) { described_class::EXPIRATION_DURATIONS.last.from_now + 2.days }
it { is_expected.to be_nil }
end
context 'when expires is before the start of the range' do
let(:expires_at) { described_class::EXPIRATION_DURATIONS.first.from_now - 10.minutes }
it { is_expected.to eq(described_class::EXPIRATION_DURATIONS.first) }
end
end
end