Skip to content

Commit 55661b4

Browse files
committed
Afficher une bannière de maintenance ProConnect sur toutes les pages
Bannière configurable via config/maintenance_banner.yml (dates, titre, description). Active uniquement dans la plage horaire définie, fermable par l'utilisateur.
1 parent 50b77ca commit 55661b4

5 files changed

Lines changed: 82 additions & 0 deletions

File tree

app/models/maintenance_banner.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class MaintenanceBanner
2+
def self.active?
3+
Time.zone.now.between?(config[:start], config[:end])
4+
end
5+
6+
def self.title = config[:title]
7+
def self.description = config[:description]
8+
9+
def self.config
10+
Rails.application.config_for(:maintenance_banner)
11+
end
12+
private_class_method :config
13+
end

app/views/layouts/application.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
<% end %>
4343

4444
<%= render partial: 'shared/impersonation_warning' %>
45+
<%= render partial: 'shared/maintenance_banner' %>
4546

4647
<%= render partial: 'layouts/header' %>
4748

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<% if MaintenanceBanner.active? %>
2+
<%= render DsfrComponent::NoticeComponent.new(
3+
title: MaintenanceBanner.title,
4+
description: MaintenanceBanner.description,
5+
type: 'warning',
6+
dismissible: true,
7+
html_attributes: { class: 'fr-notice--full-width' }
8+
) %>
9+
<% end %>

config/maintenance_banner.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
shared:
2+
start: "2026-04-23T14:00:00+02:00"
3+
end: "2026-04-23T19:30:00+02:00"
4+
title: "Maintenance ProConnect ce soir à 18h"
5+
description: "Une opération de maintenance sera effectuée par ProConnect,
6+
le service de connexion à DataPass, ce soir à partir de 18h00.
7+
Aucune connexion ne sera possible alors, et ce pour une durée
8+
d’1h environ : nous vous conseillons de ne pas utiliser DataPass
9+
durant ce laps de temps, afin d’éviter tout désagrément."
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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

Comments
 (0)