fix(expiration_banner): only show expirations info when flip is enabled

fix(lint): lint haml

fix(spec): enable flipper and allow procedure to receive flipper check when checking banner presence

fix(doc): add missing documentation on readme regarding system testing with a visual feedback

fix(typo): add missing accent

clean(PR): feedback from Tchak, better to wrap feature check for expirability by procedure within dossier.expirable? helper
This commit is contained in:
Martin 2021-11-26 14:31:30 +01:00
parent 89244407be
commit 725521c3a1
9 changed files with 101 additions and 81 deletions

View file

@ -109,6 +109,10 @@ Pour exécuter les tests de l'application, plusieurs possibilités :
bin/rspec --only-failures bin/rspec --only-failures
- Lancer un ou des tests systèmes avec un browser
NO_HEADLESS=1 bin/rspec spec/system
### Ajout de taches à exécuter au déploiement ### Ajout de taches à exécuter au déploiement
rails generate after_party:task task_name rails generate after_party:task task_name

View file

@ -545,7 +545,7 @@ class Dossier < ApplicationRecord
end end
def expirable? def expirable?
[brouillon?, en_construction?, termine?].any? [brouillon?, en_construction?, termine? && procedure.feature_enabled?(:procedure_process_expired_dossiers_termine)].any?
end end
def approximative_expiration_date_reference def approximative_expiration_date_reference

View file

@ -1,14 +1,25 @@
- if dossier.expirable? && dossier.close_to_expiration? -# small expires mention
.card.warning.mt-2.mb-3 - if dossier.expirable?
.card-title= t('shared.dossiers.header.banner.title') %p.expires_at
%p %small= t("shared.dossiers.header.expires_at.#{dossier.state}", date: safe_expiration_date(dossier))
- if dossier.brouillon? -# big banner warning
= t('shared.dossiers.header.banner.states.brouillon') - if dossier.close_to_expiration?
- elsif dossier.en_construction? .card.warning.mt-2.mb-3
= t('shared.dossiers.header.banner.states.en_construction') .card-title= t('shared.dossiers.header.banner.title')
- elsif dossier.termine? %p
= t('shared.dossiers.header.banner.states.termine') - if dossier.brouillon?
= t('shared.dossiers.header.banner.states.brouillon')
- elsif dossier.en_construction?
= t('shared.dossiers.header.banner.states.en_construction')
- elsif dossier.termine?
= t('shared.dossiers.header.banner.states.termine')
- if dossier.expiration_can_be_extended?
%br
= button_to t('shared.dossiers.header.banner.button_delay_expiration'), users_dossier_repousser_expiration_path(dossier), class: 'button secondary mt-2'
- else
%p.expires_at_en_instruction
%small= t("shared.dossiers.header.expires_at.en_instruction")
- if dossier.expiration_can_be_extended?
%br
= button_to t('shared.dossiers.header.banner.button_delay_expiration'), users_dossier_repousser_expiration_path(dossier), class: 'button secondary mt-2'

View file

@ -6,7 +6,7 @@
= t('views.users.dossiers.show.header.dossier_number', dossier_id: dossier.id) = t('views.users.dossiers.show.header.dossier_number', dossier_id: dossier.id)
= t('views.users.dossiers.show.header.created_date', date_du_dossier: I18n.l(dossier.created_at)) = t('views.users.dossiers.show.header.created_date', date_du_dossier: I18n.l(dossier.created_at))
= render(partial: 'shared/dossiers/short_expires_message', locals: {dossier: dossier}) = render(partial: 'shared/dossiers/expiration_banner', locals: {dossier: dossier})
.header-actions .header-actions
- if current_user.owns?(dossier) - if current_user.owns?(dossier)

View file

@ -1,9 +0,0 @@
- if dossier.expirable?
%p.expires_at
%small= t("shared.dossiers.header.expires_at.#{dossier.state}", date: safe_expiration_date(dossier))
- else
%p.expires_at_en_instruction
%small= t("shared.dossiers.header.expires_at.en_instruction")
= render(partial: 'shared/dossiers/expiration_banner', locals: {dossier: dossier})

View file

@ -10,7 +10,7 @@
- if dossier.en_construction_at.present? - if dossier.en_construction_at.present?
= t('views.users.dossiers.show.header.submit_date', date_du_dossier: I18n.l(dossier.en_construction_at)) = t('views.users.dossiers.show.header.submit_date', date_du_dossier: I18n.l(dossier.en_construction_at))
= render(partial: 'shared/dossiers/short_expires_message', locals: {dossier: dossier}) = render(partial: 'shared/dossiers/expiration_banner', locals: {dossier: dossier})
- if current_user.owns?(dossier) - if current_user.owns?(dossier)

View file

@ -166,6 +166,8 @@ describe 'The user' do
end end
scenario 'extends dossier experation date more than one time, ', js: true do scenario 'extends dossier experation date more than one time, ', js: true do
Flipper.enable(:procedure_process_expired_dossiers_termine)
allow(simple_procedure).to receive(:feature_enabled?).with(:procedure_process_expired_dossiers_termine).and_return(true)
user_old_dossier = create(:dossier, user_old_dossier = create(:dossier,
procedure: simple_procedure, procedure: simple_procedure,
created_at: simple_procedure.duree_conservation_dossiers_dans_ds.month.ago, created_at: simple_procedure.duree_conservation_dossiers_dans_ds.month.ago,

View file

@ -0,0 +1,68 @@
describe 'shared/dossiers/expiration_banner.html.haml', type: :view do
include DossierHelper
let(:dossier) { build(:dossier, state, attributes.merge(id: 1, state: state)) }
let(:i18n_key_state) { state }
subject do
render('shared/dossiers/expiration_banner.html.haml',
dossier: dossier,
current_user: build(:user))
end
context 'with procedure having procedure_process_expired_dossiers_termine not enabled' do
before { allow(dossier.procedure).to receive(:feature_enabled?).with(:procedure_process_expired_dossiers_termine).and_return(false) }
let(:attributes) { { processed_at: 6.months.ago } }
let(:state) { :accepte }
it 'render estimated expiration date' do
expect(subject).not_to have_selector('.expires_at')
end
end
context 'with procedure having procedure_process_expired_dossiers_termine enabled' do
before { allow(dossier.procedure).to receive(:feature_enabled?).with(:procedure_process_expired_dossiers_termine).and_return(true) }
context 'with dossier.brouillon?' do
let(:attributes) { { created_at: 6.months.ago } }
let(:state) { :brouillon }
it 'render estimated expiration date' do
expect(subject).to have_selector('.expires_at',
text: I18n.t("shared.dossiers.header.expires_at.#{i18n_key_state}",
date: safe_expiration_date(dossier)))
end
end
context 'with dossier.en_construction?' do
let(:attributes) { { en_construction_at: 6.months.ago } }
let(:state) { :en_construction }
it 'render estimated expiration date' do
expect(subject).to have_selector('.expires_at',
text: I18n.t("shared.dossiers.header.expires_at.#{i18n_key_state}",
date: safe_expiration_date(dossier)))
end
end
context 'with dossier.en_instruction?' do
let(:state) { :en_instruction }
let(:attributes) { {} }
it 'render estimated expiration date' do
expect(subject).to have_selector('p.expires_at_en_instruction',
text: I18n.t("shared.dossiers.header.expires_at.#{i18n_key_state}"))
end
end
context 'with dossier.en_processed_at?' do
let(:state) { :accepte }
let(:attributes) { {} }
it 'render estimated expiration date' do
allow(dossier).to receive(:processed_at).and_return(6.months.ago)
expect(subject).to have_selector('.expires_at',
text: I18n.t("shared.dossiers.header.expires_at.#{i18n_key_state}",
date: safe_expiration_date(dossier)))
end
end
end
end

View file

@ -1,56 +0,0 @@
describe 'shared/dossiers/short_expires_message.html.haml', type: :view do
include DossierHelper
let(:dossier) do
build(:dossier, state, attributes.merge(id: 1, state: state))
end
let(:i18n_key_state) { state }
subject do
render('shared/dossiers/short_expires_message.html.haml',
dossier: dossier,
current_user: build(:user))
end
context 'with dossier.brouillon?' do
let(:attributes) { { created_at: 6.months.ago } }
let(:state) { :brouillon }
it 'render estimated expiration date' do
expect(subject).to have_selector('.expires_at',
text: I18n.t("shared.dossiers.header.expires_at.#{i18n_key_state}",
date: safe_expiration_date(dossier)))
end
end
context 'with dossier.en_construction?' do
let(:attributes) { { en_construction_at: 6.months.ago } }
let(:state) { :en_construction }
it 'render estimated expiration date' do
expect(subject).to have_selector('.expires_at',
text: I18n.t("shared.dossiers.header.expires_at.#{i18n_key_state}",
date: safe_expiration_date(dossier)))
end
end
context 'with dossier.en_instruction?' do
let(:state) { :en_instruction }
let(:attributes) { {} }
it 'render estimated expiration date' do
expect(subject).to have_selector('p.expires_at_en_instruction',
text: I18n.t("shared.dossiers.header.expires_at.#{i18n_key_state}"))
end
end
context 'with dossier.en_processed_at?' do
let(:state) { :accepte }
let(:attributes) { {} }
it 'render estimated expiration date' do
allow(dossier).to receive(:processed_at).and_return(6.months.ago)
expect(subject).to have_selector('.expires_at',
text: I18n.t("shared.dossiers.header.expires_at.#{i18n_key_state}",
date: safe_expiration_date(dossier)))
end
end
end