views: display revision errors on the procedure dashboard
This commit is contained in:
parent
52b0fbf9b7
commit
9db62178d2
4 changed files with 48 additions and 6 deletions
|
@ -23,6 +23,10 @@
|
|||
color: $blue-france-500;
|
||||
}
|
||||
|
||||
.card-admin-status-error {
|
||||
color: $light-red;
|
||||
}
|
||||
|
||||
.card-admin-title {
|
||||
font-weight: bold;
|
||||
font-size: 18px;
|
||||
|
|
|
@ -52,15 +52,22 @@
|
|||
%p.button Modifier
|
||||
|
||||
- if !@procedure.locked? || @procedure.feature_enabled?(:procedure_revisions)
|
||||
= link_to champs_admin_procedure_path(@procedure), class: 'card-admin' do
|
||||
- if @procedure.draft_types_de_champ.count > 0
|
||||
%div
|
||||
%span.icon.accept
|
||||
%p.card-admin-status-accept Validé
|
||||
- else
|
||||
- @procedure.validate(:publication)
|
||||
- error_messages = @procedure.errors.messages_for(:draft_revision).to_sentence
|
||||
|
||||
= link_to champs_admin_procedure_path(@procedure), class: 'card-admin', title: error_messages do
|
||||
- if @procedure.draft_types_de_champ.count == 0
|
||||
%div
|
||||
%span.icon.clock
|
||||
%p.card-admin-status-todo À faire
|
||||
- elsif error_messages.present?
|
||||
%div
|
||||
%span.icon.refuse
|
||||
%p.card-admin-status-error À modifier
|
||||
- else
|
||||
%div
|
||||
%span.icon.accept
|
||||
%p.card-admin-status-accept Validé
|
||||
%div
|
||||
%p.card-admin-title
|
||||
%span.badge.baseline= @procedure.draft_types_de_champ.count
|
||||
|
|
|
@ -622,6 +622,19 @@ describe Administrateurs::ProceduresController, type: :controller do
|
|||
let(:path) { 'Invalid Procedure Path' }
|
||||
it { expect { put :publish, params: { procedure_id: procedure.id, path: path, lien_site_web: lien_site_web } }.to raise_error(ActiveRecord::RecordInvalid) }
|
||||
end
|
||||
|
||||
context 'procedure revision is invalid' do
|
||||
let(:path) { 'new_path' }
|
||||
let(:empty_repetition) { build(:type_de_champ_repetition, types_de_champ: []) }
|
||||
let(:procedure) do
|
||||
create(:procedure,
|
||||
administrateur: admin,
|
||||
lien_site_web: lien_site_web,
|
||||
types_de_champ: [empty_repetition])
|
||||
end
|
||||
|
||||
it { expect { put :publish, params: { procedure_id: procedure.id, path: path, lien_site_web: lien_site_web } }.to raise_error(ActiveRecord::RecordInvalid) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when admin is not the owner of the procedure' do
|
||||
|
|
|
@ -50,5 +50,23 @@ describe 'Creating a new procedure', js: true do
|
|||
expect(page).to have_field('libelle de champ')
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'a warning is displayed when creating an invalid procedure' do
|
||||
visit champs_admin_procedure_path(procedure)
|
||||
|
||||
# Add an empty repetition type de champ
|
||||
add_champ(remove_flash_message: true)
|
||||
select('Bloc répétable', from: 'champ-0-type_champ')
|
||||
fill_in 'champ-0-libelle', with: 'libellé de champ'
|
||||
blur
|
||||
expect(page).to have_content('Formulaire enregistré')
|
||||
|
||||
click_link procedure.libelle
|
||||
expect(page).to have_current_path(admin_procedure_path(procedure))
|
||||
|
||||
champs_card = find('.card-admin', text: 'Champs du formulaire')
|
||||
expect(champs_card).to have_selector('.icon.refuse')
|
||||
expect(champs_card).to have_content('À modifier')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue