|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +RSpec.describe MaintenanceBanner do |
| 4 | + let(:config) do |
| 5 | + { |
| 6 | + start: Time.zone.parse('2026-04-23T14:00:00+02:00'), |
| 7 | + end: Time.zone.parse('2026-04-23T19:30:00+02:00'), |
| 8 | + title: 'Maintenance ProConnect ce soir à 18h', |
| 9 | + description: 'Une opération de maintenance aura lieu ce soir.' |
| 10 | + } |
| 11 | + end |
| 12 | + |
| 13 | + before { allow(described_class).to receive(:config).and_return(config) } |
| 14 | + |
| 15 | + describe '.active?' do |
| 16 | + subject { described_class.active? } |
| 17 | + |
| 18 | + context 'when current time is within the window' do |
| 19 | + before { travel_to(Time.zone.parse('2026-04-23T16:00:00+02:00')) } |
| 20 | + |
| 21 | + it { is_expected.to be true } |
| 22 | + end |
| 23 | + |
| 24 | + context 'when current time is before the window' do |
| 25 | + before { travel_to(Time.zone.parse('2026-04-23T13:59:00+02:00')) } |
| 26 | + |
| 27 | + it { is_expected.to be false } |
| 28 | + end |
| 29 | + |
| 30 | + context 'when current time is after the window' do |
| 31 | + before { travel_to(Time.zone.parse('2026-04-23T19:31:00+02:00')) } |
| 32 | + |
| 33 | + it { is_expected.to be false } |
| 34 | + end |
| 35 | + |
| 36 | + context 'when current date is not the maintenance day' do |
| 37 | + before { travel_to(Time.zone.parse('2026-04-22T16:00:00+02:00')) } |
| 38 | + |
| 39 | + it { is_expected.to be false } |
| 40 | + end |
| 41 | + end |
| 42 | + |
| 43 | + describe '.title' do |
| 44 | + it { expect(described_class.title).to eq('Maintenance ProConnect ce soir à 18h') } |
| 45 | + end |
| 46 | + |
| 47 | + describe '.description' do |
| 48 | + it { expect(described_class.description).to be_present } |
| 49 | + end |
| 50 | +end |
0 commit comments