fix specs
This commit is contained in:
parent
4a51a9a351
commit
b6cc35df68
8 changed files with 45 additions and 12 deletions
|
@ -12,10 +12,21 @@ function syncFormToPreview() {
|
|||
syncInputToElement('#procedure_libelle', '.procedure-title');
|
||||
syncInputToElement('#procedure_description', '.procedure-description-body');
|
||||
syncInputToElement('#procedure_description_what', '.js_description_what p');
|
||||
syncInputToElement('#procedure_description_for_who', '.js_description_for_who p');
|
||||
syncInputToElement(
|
||||
'#procedure_description_for_who',
|
||||
'.js_description_for_who p'
|
||||
);
|
||||
}
|
||||
|
||||
delegate('input', '.procedure-form #procedure_libelle', syncFormToPreview);
|
||||
delegate('input', '.procedure-form #procedure_description', syncFormToPreview);
|
||||
delegate('input', '.procedure-form #procedure_description_what', syncFormToPreview);
|
||||
delegate('input', '.procedure-form #procedure_description_for_who', syncFormToPreview);
|
||||
delegate(
|
||||
'input',
|
||||
'.procedure-form #procedure_description_what',
|
||||
syncFormToPreview
|
||||
);
|
||||
delegate(
|
||||
'input',
|
||||
'.procedure-form #procedure_description_for_who',
|
||||
syncFormToPreview
|
||||
);
|
||||
|
|
|
@ -282,8 +282,8 @@ class Procedure < ApplicationRecord
|
|||
}
|
||||
|
||||
validates :libelle, presence: true, allow_blank: false, allow_nil: false
|
||||
validates :description, presence: true, allow_blank: false, allow_nil: false, if: -> { description_what.nil? && description_for_who.nil?}
|
||||
validates :description_what, :description_for_who, presence: true, allow_blank: false, allow_nil: false, if: -> { description.nil?}
|
||||
validates :description, presence: true, allow_blank: false, allow_nil: false, if: -> { description_what.nil? && description_for_who.nil? }
|
||||
validates :description_what, :description_for_who, presence: true, allow_blank: false, allow_nil: false, if: -> { description.nil? }
|
||||
validates :administrateurs, presence: true
|
||||
validates :lien_site_web, presence: true, if: :publiee?
|
||||
validates :draft_types_de_champ_public,
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
= render partial: 'shared/procedure_description', locals: { procedure: procedure }
|
||||
- else
|
||||
= render partial: 'layouts/commencer/no_procedure'
|
||||
= yield
|
||||
|
||||
- content_for :footer do
|
||||
- if procedure
|
||||
|
|
|
@ -37,12 +37,12 @@
|
|||
.fr-accordions-group
|
||||
%section.fr-accordion
|
||||
%h3.fr-accordion__title
|
||||
%button.fr-accordion__btn{"aria-controls" => "accordion-114", "aria-expanded" => "true"} Quel est l’objet de cette démarche ?
|
||||
%button.fr-accordion__btn{ "aria-controls" => "accordion-114", "aria-expanded" => "true" } Quel est l’objet de cette démarche ?
|
||||
#accordion-114.fr-collapse.js_description_what
|
||||
= h render SimpleFormatComponent.new(procedure.description_what, allow_a: true)
|
||||
|
||||
%section.fr-accordion
|
||||
%h3.fr-accordion__title
|
||||
%button.fr-accordion__btn{"aria-controls" => "accordion-115", "aria-expanded" => "false"} À qui s’adresse la démarche ?
|
||||
%button.fr-accordion__btn{ "aria-controls" => "accordion-115", "aria-expanded" => "false" } À qui s’adresse la démarche ?
|
||||
#accordion-115.fr-collapse.js_description_for_who
|
||||
= h render SimpleFormatComponent.new(procedure.description_for_who, allow_a: true)
|
||||
|
|
|
@ -178,9 +178,26 @@ describe Procedure do
|
|||
end
|
||||
|
||||
context 'description' do
|
||||
it { is_expected.not_to allow_value(nil).for(:description) }
|
||||
it { is_expected.not_to allow_value('').for(:description) }
|
||||
it { is_expected.to allow_value('Description Demande de subvention').for(:description) }
|
||||
context 'description can not be nil if description_what and description_for_who are nil too' do
|
||||
let(:procedure) { build(:procedure, description: nil) }
|
||||
it { is_expected.to allow_value('Description Demande de subvention').for(:description) }
|
||||
it { expect(procedure.valid?).to eq(false) }
|
||||
end
|
||||
|
||||
context 'description can be nil if description_what and description_for_who are filled' do
|
||||
let(:procedure) { build(:procedure, description: nil, description_for_who: 'for who', description_what: 'what') }
|
||||
it { expect(procedure.valid?).to eq(true) }
|
||||
end
|
||||
|
||||
context 'description_what and description_for_who can not be nil if description is nil too' do
|
||||
let(:procedure) { build(:procedure, description: nil) }
|
||||
it { expect(procedure.valid?).to eq(false) }
|
||||
end
|
||||
|
||||
context 'description_what and description_for_who can be nil if description is filled' do
|
||||
let(:procedure) { build(:procedure, description: 'description') }
|
||||
it { expect(procedure.valid?).to eq(true) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'organisation' do
|
||||
|
|
|
@ -5,5 +5,9 @@ module Capybara
|
|||
def has_procedure_description?(procedure)
|
||||
has_content?(procedure.libelle) && has_content?(procedure.description) && has_content?(procedure.service.email)
|
||||
end
|
||||
|
||||
def has_procedure_sumup_description?(procedure)
|
||||
has_content?(procedure.libelle) && has_content?(procedure.service.email)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -43,7 +43,7 @@ describe 'Signin in:' do
|
|||
click_on 'Commencer la démarche'
|
||||
|
||||
expect(page).to have_current_path identite_dossier_path(user.reload.dossiers.last)
|
||||
expect(page).to have_procedure_description(procedure)
|
||||
expect(page).to have_procedure_sumup_description(procedure)
|
||||
expect(page).to have_content "Données d’identité"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -84,7 +84,7 @@ describe 'Signing up:' do
|
|||
click_on 'Commencer la démarche'
|
||||
|
||||
expect(page).to have_current_path identite_dossier_path(procedure.reload.dossiers.last)
|
||||
expect(page).to have_procedure_description(procedure)
|
||||
expect(page).to have_procedure_sumup_description(procedure)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue