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:
parent
89244407be
commit
725521c3a1
9 changed files with 101 additions and 81 deletions
|
@ -109,6 +109,10 @@ Pour exécuter les tests de l'application, plusieurs possibilités :
|
|||
|
||||
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
|
||||
|
||||
rails generate after_party:task task_name
|
||||
|
|
|
@ -545,7 +545,7 @@ class Dossier < ApplicationRecord
|
|||
end
|
||||
|
||||
def expirable?
|
||||
[brouillon?, en_construction?, termine?].any?
|
||||
[brouillon?, en_construction?, termine? && procedure.feature_enabled?(:procedure_process_expired_dossiers_termine)].any?
|
||||
end
|
||||
|
||||
def approximative_expiration_date_reference
|
||||
|
|
|
@ -1,14 +1,25 @@
|
|||
- if dossier.expirable? && dossier.close_to_expiration?
|
||||
.card.warning.mt-2.mb-3
|
||||
.card-title= t('shared.dossiers.header.banner.title')
|
||||
%p
|
||||
- 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')
|
||||
-# small expires mention
|
||||
- if dossier.expirable?
|
||||
%p.expires_at
|
||||
%small= t("shared.dossiers.header.expires_at.#{dossier.state}", date: safe_expiration_date(dossier))
|
||||
-# big banner warning
|
||||
- if dossier.close_to_expiration?
|
||||
.card.warning.mt-2.mb-3
|
||||
.card-title= t('shared.dossiers.header.banner.title')
|
||||
%p
|
||||
- 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'
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
= 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))
|
||||
|
||||
= render(partial: 'shared/dossiers/short_expires_message', locals: {dossier: dossier})
|
||||
= render(partial: 'shared/dossiers/expiration_banner', locals: {dossier: dossier})
|
||||
|
||||
.header-actions
|
||||
- if current_user.owns?(dossier)
|
||||
|
|
|
@ -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})
|
|
@ -10,7 +10,7 @@
|
|||
- if dossier.en_construction_at.present?
|
||||
= 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)
|
||||
|
|
|
@ -166,6 +166,8 @@ describe 'The user' do
|
|||
end
|
||||
|
||||
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,
|
||||
procedure: simple_procedure,
|
||||
created_at: simple_procedure.duree_conservation_dossiers_dans_ds.month.ago,
|
||||
|
|
|
@ -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
|
|
@ -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
|
Loading…
Reference in a new issue