Remove old user dossier form
This commit is contained in:
parent
d1613b4af1
commit
c91abe73c5
37 changed files with 0 additions and 1276 deletions
|
@ -1,439 +0,0 @@
|
|||
shared_examples 'description_controller_spec' do
|
||||
describe 'GET #show' do
|
||||
before do
|
||||
dossier.update_column :autorisation_donnees, true
|
||||
end
|
||||
context 'user is not connected' do
|
||||
before do
|
||||
sign_out dossier.user
|
||||
end
|
||||
|
||||
it 'redirects to users/sign_in' do
|
||||
get :show, params: { dossier_id: dossier_id }
|
||||
expect(response).to redirect_to('/users/sign_in')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when all is ok' do
|
||||
before do
|
||||
dossier.etablissement = create(:etablissement)
|
||||
get :show, params: { dossier_id: dossier_id }
|
||||
end
|
||||
|
||||
it 'returns http success' do
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
|
||||
context 'procedure is archived' do
|
||||
render_views
|
||||
let(:archived) { true }
|
||||
|
||||
it { expect(response).to have_http_status(:success) }
|
||||
it { expect(response.body).to_not have_content(I18n.t('errors.messages.procedure_archived')) }
|
||||
|
||||
context 'dossier is a brouillon' do
|
||||
let(:state) { 'brouillon' }
|
||||
|
||||
it { expect(response).to have_http_status(:success) }
|
||||
it { expect(response.body).to have_content(I18n.t('errors.messages.procedure_archived')) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it 'redirection vers start si mauvais dossier ID' do
|
||||
get :show, params: { dossier_id: bad_dossier_id }
|
||||
|
||||
expect(flash[:alert]).to be_present
|
||||
expect(response).to redirect_to(root_path)
|
||||
end
|
||||
|
||||
it_behaves_like "not owner of dossier", :show
|
||||
|
||||
describe 'before_action authorized_routes?' do
|
||||
context 'when dossier does not have a valid state' do
|
||||
before do
|
||||
dossier.state = 'en_instruction'
|
||||
dossier.save
|
||||
|
||||
get :show, params: { dossier_id: dossier.id }
|
||||
end
|
||||
|
||||
it { is_expected.to redirect_to root_path }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'before action check_autorisation_donnees' do
|
||||
subject { get :show, params: { dossier_id: dossier_id } }
|
||||
|
||||
context 'when dossier does not have a valid autorisations_donness (nil)' do
|
||||
before do
|
||||
dossier.update_column :autorisation_donnees, nil
|
||||
end
|
||||
|
||||
it { expect(subject).to redirect_to "/users/dossiers/#{dossier.id}" }
|
||||
end
|
||||
|
||||
context 'when dossier does not have a valid autorisations_donness (false)' do
|
||||
before do
|
||||
dossier.update_column :autorisation_donnees, false
|
||||
end
|
||||
|
||||
it { expect(subject).to redirect_to "/users/dossiers/#{dossier.id}" }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'before action check_starter_dossier_informations' do
|
||||
subject { get :show, params: { dossier_id: dossier_id } }
|
||||
|
||||
context 'when dossier does not have an etablissement datas' do
|
||||
it { expect(dossier.etablissement).to be_nil }
|
||||
it { expect(subject).to redirect_to "/users/dossiers/#{dossier.id}" }
|
||||
end
|
||||
|
||||
context 'when dossier does not have an individual datas' do
|
||||
before do
|
||||
procedure.update_column :for_individual, true
|
||||
end
|
||||
|
||||
it { expect(dossier.individual).to be_nil }
|
||||
it { expect(subject).to redirect_to "/users/dossiers/#{dossier.id}" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #update' do
|
||||
context 'Tous les attributs sont bons' do
|
||||
describe 'Premier enregistrement des données' do
|
||||
let(:state) { 'brouillon' }
|
||||
|
||||
def submit_dossier
|
||||
post :update, params: { dossier_id: dossier_id, submit_action: submit }
|
||||
dossier.reload
|
||||
end
|
||||
|
||||
context "when the user submits the dossier" do
|
||||
let(:submit) { 'nouveaux' }
|
||||
|
||||
it "redirection vers la page recapitulative" do
|
||||
submit_dossier
|
||||
|
||||
expect(response).to redirect_to("/users/dossiers/#{dossier_id}/recapitulatif")
|
||||
end
|
||||
|
||||
it 'etat du dossier est en construction' do
|
||||
submit_dossier
|
||||
|
||||
expect(dossier.state).to eq('en_construction')
|
||||
end
|
||||
|
||||
context 'sending the accusé de réception mail' do
|
||||
before { Timecop.freeze(DateTime.now) }
|
||||
|
||||
after { Timecop.return }
|
||||
|
||||
it 'sets the state of the dossier before sending the mail' do
|
||||
sender = double("notification sender")
|
||||
allow(sender).to receive(:deliver_later)
|
||||
expect(NotificationMailer)
|
||||
.to receive(:send_initiated_notification)
|
||||
.with(have_attributes(en_construction_at: DateTime.now))
|
||||
.and_return(sender)
|
||||
|
||||
submit_dossier
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when user saves a brouillon' do
|
||||
let(:submit) { 'brouillon' }
|
||||
|
||||
it "reste sur la page du dossier" do
|
||||
submit_dossier
|
||||
expect(response).to redirect_to("/users/dossiers/#{dossier_id}/description")
|
||||
end
|
||||
|
||||
it 'etat du dossier est brouillon' do
|
||||
submit_dossier
|
||||
expect(dossier.state).to eq('brouillon')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when user saves a brouillon and goes to dashboard' do
|
||||
let(:submit) { 'brouillon_then_dashboard' }
|
||||
|
||||
it "goes to dashboard" do
|
||||
submit_dossier
|
||||
expect(response).to redirect_to("/users/dossiers?liste=brouillon")
|
||||
end
|
||||
|
||||
it 'etat du dossier est brouillon' do
|
||||
submit_dossier
|
||||
expect(dossier.state).to eq('brouillon')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'En train de manipuler un dossier non brouillon' do
|
||||
before do
|
||||
dossier.en_construction!
|
||||
post :update, params: { dossier_id: dossier_id }
|
||||
dossier.reload
|
||||
end
|
||||
|
||||
it 'Redirection vers la page récapitulatif' do
|
||||
expect(response).to redirect_to("/users/dossiers/#{dossier_id}/recapitulatif")
|
||||
end
|
||||
|
||||
it 'etat du dossier n\'est pas soumis' do
|
||||
expect(dossier.state).not_to eq('brouillon')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Sauvegarde des champs' do
|
||||
let(:champs_dossier) { dossier.champs }
|
||||
let(:dossier_text_value) { 'test value' }
|
||||
let(:dossier_date_value) { '2018-01-31' }
|
||||
let(:dossier_hour_value) { '17' }
|
||||
let(:dossier_minute_value) { '00' }
|
||||
let(:dossier_datetime_champ_id) { dossier.champs.find { |c| c.type_champ == "datetime" }.id }
|
||||
let(:dossier_text_champ_id) { dossier.champs.find { |c| c.type_champ == "text" }.id }
|
||||
let(:params) {
|
||||
{
|
||||
dossier_id: dossier_id,
|
||||
champs: {
|
||||
"'#{dossier_text_champ_id}'" => dossier_text_value,
|
||||
"'#{dossier_datetime_champ_id}'" => dossier_date_value
|
||||
},
|
||||
time_hour: {
|
||||
"'#{dossier_datetime_champ_id}'" => dossier_hour_value,
|
||||
},
|
||||
time_minute: {
|
||||
"'#{dossier_datetime_champ_id}'" => dossier_minute_value,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
before do
|
||||
post :update, params: params
|
||||
dossier.reload
|
||||
end
|
||||
|
||||
it { expect(dossier.champs.find(dossier_text_champ_id).value).to eq(dossier_text_value) }
|
||||
it { expect(response).to redirect_to users_dossier_recapitulatif_path }
|
||||
|
||||
context 'when champs is type_de_champ datetime' do
|
||||
it { expect(dossier.champs.find(dossier_datetime_champ_id).value).to eq("#{dossier_date_value} #{dossier_hour_value}:#{dossier_minute_value}") }
|
||||
end
|
||||
|
||||
context 'when champs value is empty' do
|
||||
let(:dossier_text_value) { '' }
|
||||
|
||||
it { expect(dossier.champs.find(dossier_text_champ_id).value).to eq(dossier_text_value) }
|
||||
it { expect(response).to redirect_to users_dossier_recapitulatif_path }
|
||||
|
||||
context 'when champs is mandatory' do
|
||||
let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ_mandatory, :with_datetime) }
|
||||
|
||||
it { expect(response).not_to redirect_to users_dossier_recapitulatif_path }
|
||||
it { expect(flash[:alert]).to be_present }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'Sauvegarde des pièces justificatives', vcr: { cassette_name: 'controllers_users_description_controller_sauvegarde_pj' } do
|
||||
let(:all_pj_type) { dossier.procedure.type_de_piece_justificative_ids }
|
||||
before do
|
||||
post :update, params: {
|
||||
dossier_id: dossier_id,
|
||||
"piece_justificative_#{all_pj_type[0].to_s}" => piece_justificative_0,
|
||||
"piece_justificative_#{all_pj_type[1].to_s}" => piece_justificative_1
|
||||
}
|
||||
dossier.reload
|
||||
end
|
||||
|
||||
describe 'clamav anti-virus presence', vcr: { cassette_name: 'controllers_users_description_controller_clamav_presence' } do
|
||||
it 'ClamavService safe_file? is call' do
|
||||
expect(ClamavService).to receive(:safe_file?).twice
|
||||
|
||||
post :update, params: {
|
||||
dossier_id: dossier_id,
|
||||
"piece_justificative_#{all_pj_type[0].to_s}" => piece_justificative_0,
|
||||
"piece_justificative_#{all_pj_type[1].to_s}" => piece_justificative_1
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
context 'for piece 0' do
|
||||
subject { dossier.retrieve_last_piece_justificative_by_type all_pj_type[0].to_s }
|
||||
it { expect(subject.content).not_to be_nil }
|
||||
it { expect(subject.user).to eq user }
|
||||
end
|
||||
context 'for piece 1' do
|
||||
subject { dossier.retrieve_last_piece_justificative_by_type all_pj_type[1].to_s }
|
||||
it { expect(subject.content).not_to be_nil }
|
||||
it { expect(subject.user).to eq user }
|
||||
end
|
||||
end
|
||||
|
||||
context 'La procédure est archivée' do
|
||||
let(:archived) { true }
|
||||
|
||||
before do
|
||||
post :update, params: { dossier_id: dossier.id }
|
||||
end
|
||||
|
||||
it { expect(response.status).to eq(302) }
|
||||
|
||||
context 'Le dossier est en brouillon' do
|
||||
let(:state) { 'brouillon' }
|
||||
|
||||
it { expect(response.status).to eq(403) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #pieces_justificatives', vcr: { cassette_name: 'controllers_users_description_controller_pieces_justificatives' } do
|
||||
let(:all_pj_type) { dossier.procedure.type_de_piece_justificative_ids }
|
||||
|
||||
subject {
|
||||
patch :pieces_justificatives, params: {
|
||||
dossier_id: dossier.id,
|
||||
"piece_justificative_#{all_pj_type[0].to_s}" => piece_justificative_0,
|
||||
"piece_justificative_#{all_pj_type[1].to_s}" => piece_justificative_1
|
||||
}
|
||||
}
|
||||
|
||||
context 'when user is a guest' do
|
||||
let(:guest) { create :user }
|
||||
|
||||
before do
|
||||
create :invite, dossier: dossier, email: guest.email, user: guest
|
||||
|
||||
sign_in guest
|
||||
end
|
||||
|
||||
context 'when PJ have no documents' do
|
||||
it { expect(dossier.pieces_justificatives.size).to eq 0 }
|
||||
|
||||
context 'when upload two PJ' do
|
||||
before do
|
||||
subject
|
||||
dossier.reload
|
||||
end
|
||||
|
||||
it { expect(dossier.pieces_justificatives.size).to eq 2 }
|
||||
it { expect(flash[:notice]).to be_present }
|
||||
it { is_expected.to redirect_to users_dossiers_invite_path(id: guest.invites.find_by(dossier_id: dossier.id).id) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when PJ have already a document' do
|
||||
before do
|
||||
create :piece_justificative, :rib, dossier: dossier, type_de_piece_justificative_id: all_pj_type[0]
|
||||
create :piece_justificative, :contrat, dossier: dossier, type_de_piece_justificative_id: all_pj_type[1]
|
||||
end
|
||||
|
||||
it { expect(dossier.pieces_justificatives.size).to eq 2 }
|
||||
|
||||
context 'when upload two PJ', vcr: { cassette_name: 'controllers_users_description_controller_upload_2pj' } do
|
||||
before do
|
||||
subject
|
||||
dossier.reload
|
||||
end
|
||||
|
||||
it { expect(dossier.pieces_justificatives.size).to eq 4 }
|
||||
it { expect(flash[:notice]).to be_present }
|
||||
it { is_expected.to redirect_to users_dossiers_invite_path(id: guest.invites.find_by(dossier_id: dossier.id).id) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when one of PJs is not valid' do
|
||||
let(:piece_justificative_0) { Rack::Test::UploadedFile.new("./spec/support/files/entreprise.json", 'application/json') }
|
||||
|
||||
it { expect(dossier.pieces_justificatives.size).to eq 0 }
|
||||
|
||||
context 'when upload two PJ' do
|
||||
before do
|
||||
subject
|
||||
dossier.reload
|
||||
end
|
||||
|
||||
it { expect(dossier.pieces_justificatives.size).to eq 1 }
|
||||
it { expect(flash[:alert]).to be_present }
|
||||
it { is_expected.to redirect_to users_dossiers_invite_path(id: guest.invites.find_by(dossier_id: dossier.id).id) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples 'description_controller_spec_POST_piece_justificatives_for_owner' do
|
||||
let(:all_pj_type) { dossier.procedure.type_de_piece_justificative_ids }
|
||||
|
||||
subject {
|
||||
patch :pieces_justificatives, params: {
|
||||
dossier_id: dossier.id,
|
||||
"piece_justificative_#{all_pj_type[0].to_s}" => piece_justificative_0,
|
||||
"piece_justificative_#{all_pj_type[1].to_s}" => piece_justificative_1
|
||||
}
|
||||
}
|
||||
|
||||
context 'when user is the owner', vcr: { cassette_name: 'controllers_users_description_controller_pieces_justificatives' } do
|
||||
before do
|
||||
sign_in user
|
||||
end
|
||||
|
||||
context 'when PJ have no documents' do
|
||||
it { expect(dossier.pieces_justificatives.size).to eq 0 }
|
||||
|
||||
context 'when upload two PJ' do
|
||||
before do
|
||||
subject
|
||||
dossier.reload
|
||||
end
|
||||
|
||||
it { expect(dossier.pieces_justificatives.size).to eq 2 }
|
||||
it { expect(flash[:notice]).to be_present }
|
||||
it { is_expected.to redirect_to recapitulatif_path }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when PJ have already a document', vcr: { cassette_name: 'controllers_users_description_controller_pj_already_exist' } do
|
||||
before do
|
||||
create :piece_justificative, :rib, dossier: dossier, type_de_piece_justificative_id: all_pj_type[0]
|
||||
create :piece_justificative, :contrat, dossier: dossier, type_de_piece_justificative_id: all_pj_type[1]
|
||||
end
|
||||
|
||||
it { expect(dossier.pieces_justificatives.size).to eq 2 }
|
||||
|
||||
context 'when upload two PJ', vcr: { cassette_name: 'controllers_users_description_controller_pj_already_exist_upload_2pj' } do
|
||||
before do
|
||||
subject
|
||||
dossier.reload
|
||||
end
|
||||
|
||||
it { expect(dossier.pieces_justificatives.size).to eq 4 }
|
||||
it { expect(flash[:notice]).to be_present }
|
||||
it { is_expected.to redirect_to recapitulatif_path }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when one of PJs is not valid' do
|
||||
let(:piece_justificative_0) { Rack::Test::UploadedFile.new("./spec/support/files/entreprise.json", 'application/json') }
|
||||
|
||||
it { expect(dossier.pieces_justificatives.size).to eq 0 }
|
||||
|
||||
context 'when upload two PJ' do
|
||||
before do
|
||||
subject
|
||||
dossier.reload
|
||||
end
|
||||
|
||||
it { expect(dossier.pieces_justificatives.size).to eq 1 }
|
||||
it { expect(flash[:alert]).to be_present }
|
||||
it { is_expected.to redirect_to recapitulatif_path }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,51 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
require 'controllers/users/description_controller_shared_example'
|
||||
|
||||
describe Users::DescriptionController, type: :controller, vcr: { cassette_name: 'controllers_users_description_controller' } do
|
||||
let(:owner_user) { create(:user) }
|
||||
let(:invite_by_user) { create :user, email: 'invite@plop.com' }
|
||||
let(:archived) { false }
|
||||
let(:state) { 'en_construction' }
|
||||
let(:procedure) do
|
||||
if archived
|
||||
create(:procedure, :archived, :with_two_type_de_piece_justificative, :with_type_de_champ, :with_datetime)
|
||||
else
|
||||
create(:procedure, :published, :with_two_type_de_piece_justificative, :with_type_de_champ, :with_datetime)
|
||||
end
|
||||
end
|
||||
let(:dossier) { create(:dossier, procedure: procedure, user: owner_user, state: state) }
|
||||
|
||||
let(:dossier_id) { dossier.id }
|
||||
let(:bad_dossier_id) { Dossier.count + 10000 }
|
||||
|
||||
let(:name_piece_justificative) { 'dossierPDF.pdf' }
|
||||
let(:name_piece_justificative_0) { 'piece_justificative_0.pdf' }
|
||||
let(:name_piece_justificative_1) { 'piece_justificative_1.pdf' }
|
||||
|
||||
let(:piece_justificative_0) { Rack::Test::UploadedFile.new("./spec/support/files/#{name_piece_justificative_0}", 'application/pdf') }
|
||||
let(:piece_justificative_1) { Rack::Test::UploadedFile.new("./spec/support/files/#{name_piece_justificative_1}", 'application/pdf') }
|
||||
|
||||
before do
|
||||
allow(ClamavService).to receive(:safe_file?).and_return(true)
|
||||
|
||||
create :invite, dossier: dossier, user: invite_by_user, email: invite_by_user.email, type: 'InviteUser'
|
||||
|
||||
sign_in user
|
||||
end
|
||||
|
||||
context 'when sign in user is the owner' do
|
||||
let(:user) { owner_user }
|
||||
let(:recapitulatif_path) { users_dossier_recapitulatif_path }
|
||||
|
||||
it_should_behave_like "description_controller_spec"
|
||||
it_should_behave_like "description_controller_spec_POST_piece_justificatives_for_owner"
|
||||
end
|
||||
|
||||
context 'when sign in user is an invite by owner' do
|
||||
let(:user) { invite_by_user }
|
||||
let(:recapitulatif_path) { users_dossiers_invite_path(id: dossier_id) }
|
||||
|
||||
it_should_behave_like "description_controller_spec"
|
||||
end
|
||||
end
|
|
@ -1,44 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature 'user is on description page' do
|
||||
let!(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ) }
|
||||
let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, autorisation_donnees: true) }
|
||||
|
||||
before do
|
||||
allow(ClamavService).to receive(:safe_file?).and_return(true)
|
||||
|
||||
visit users_dossier_description_path dossier
|
||||
|
||||
within('#new_user') do
|
||||
page.find_by_id('user_email').set dossier.user.email
|
||||
page.find_by_id('user_password').set dossier.user.password
|
||||
page.click_on 'Se connecter'
|
||||
end
|
||||
end
|
||||
|
||||
it { expect(page).to have_css('#description-page') }
|
||||
|
||||
context 'he fill description fields' do
|
||||
before do
|
||||
find_by_id("champs_#{dossier.champs.first.id}").set 'mon nom'
|
||||
end
|
||||
context 'before submit' do
|
||||
it 'pieces_justificatives are empty' do
|
||||
dossier.pieces_justificatives.each do |piece_justificative|
|
||||
expect(piece_justificative).to be_empty
|
||||
end
|
||||
end
|
||||
end
|
||||
context 'when he adds a piece_justificative and submit form', vcr: { cassette_name: 'description_page_upload_piece_justificative_adds_cerfa_and_submit' } do
|
||||
before do
|
||||
file_input_id = "piece_justificative_#{dossier.types_de_piece_justificative.first.id.to_s}"
|
||||
attach_file(file_input_id, File.path('spec/support/files/dossierPDF.pdf'))
|
||||
click_on('Soumettre mon dossier')
|
||||
dossier.reload
|
||||
end
|
||||
scenario 'fills the given piece_justificative' do
|
||||
expect(dossier.pieces_justificatives.first).not_to be_empty
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -69,25 +69,6 @@ describe UserRoutesAuthorizationService do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'Users::DescriptionController' do
|
||||
let(:controller) { Users::DescriptionController }
|
||||
|
||||
describe 'brouillon' do
|
||||
let(:state) { 'brouillon' }
|
||||
it { is_expected.to be_truthy }
|
||||
end
|
||||
|
||||
describe 'en_construction' do
|
||||
let(:state) { 'en_construction' }
|
||||
it { is_expected.to be_truthy }
|
||||
end
|
||||
|
||||
describe 'accepte' do
|
||||
let(:state) { 'accepte' }
|
||||
it { is_expected.to be_falsey }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'recapitulatif' do
|
||||
let(:controller) { Users::RecapitulatifController }
|
||||
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'users/description/_pieces_justificatives.html.haml', type: :view do
|
||||
let!(:procedure) { create(:procedure) }
|
||||
let!(:tpj1) do
|
||||
create(
|
||||
:type_de_piece_justificative,
|
||||
procedure: procedure,
|
||||
libelle: "Première pièce jointe",
|
||||
description: "Première description",
|
||||
order_place: 1,
|
||||
mandatory: true
|
||||
)
|
||||
end
|
||||
let!(:tpj2) do
|
||||
create(
|
||||
:type_de_piece_justificative,
|
||||
procedure: procedure,
|
||||
libelle: "Seconde pièce jointe",
|
||||
description: "Seconde description",
|
||||
order_place: 2,
|
||||
lien_demarche: "https://www.google.fr"
|
||||
)
|
||||
end
|
||||
let!(:dossier) { create(:dossier, :procedure => procedure) }
|
||||
|
||||
before do
|
||||
render 'users/description/pieces_justificatives.html.haml', dossier: dossier
|
||||
end
|
||||
|
||||
it 'should render two PJ with their title, mandatory status and description' do
|
||||
expect(rendered).to include("Première pièce jointe *")
|
||||
expect(rendered).to include("Seconde pièce jointe")
|
||||
expect(rendered.index("Première pièce jointe")).to be < rendered.index("Seconde pièce jointe")
|
||||
|
||||
expect(rendered).to include("Première description")
|
||||
expect(rendered).to include("Seconde description")
|
||||
|
||||
expect(rendered).to have_selector("input[type=file]", count: 2)
|
||||
end
|
||||
end
|
|
@ -1,15 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'users/description/champs/date.html.haml', type: :view do
|
||||
let(:type_champ) { create(:type_de_champ_date) }
|
||||
|
||||
before do
|
||||
render 'users/description/champs/date.html.haml', champ: champ
|
||||
end
|
||||
|
||||
let!(:champ) { create(:champ, type_de_champ: type_champ, value: "2017-09-19").decorate }
|
||||
|
||||
it 'should render an input for the dossier link' do
|
||||
expect(rendered).to have_css("input[value='2017-09-19']")
|
||||
end
|
||||
end
|
|
@ -1,13 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'users/description/champs/departements.html.haml', vcr: { cassette_name: 'geoapi_departements' }, type: :view do
|
||||
let(:champ) { create(:champ) }
|
||||
|
||||
before do
|
||||
render 'users/description/champs/departements.html.haml', champ: champ.decorate
|
||||
end
|
||||
|
||||
it 'should render departments drop down list' do
|
||||
expect(rendered).to include("Ain")
|
||||
end
|
||||
end
|
|
@ -1,55 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'users/description/champs/dossier_link.html.haml', type: :view do
|
||||
let(:type_champ) { create(:type_de_champ_dossier_link) }
|
||||
|
||||
before do
|
||||
render 'users/description/champs/dossier_link.html.haml', champ: champ
|
||||
end
|
||||
|
||||
context 'in all cases' do
|
||||
let!(:champ) { create(:champ, type_de_champ: type_champ, value: nil) }
|
||||
|
||||
it 'should render an input for the dossier link' do
|
||||
expect(rendered).to have_css("input[type=number][placeholder='Numéro de dossier']")
|
||||
end
|
||||
end
|
||||
|
||||
context 'When no dossier is provided' do
|
||||
let!(:champ) { create(:champ, type_de_champ: type_champ, value: nil) }
|
||||
|
||||
it 'should not display the procedure libelle' do
|
||||
expect(rendered).to have_css('.text-info[style*="display: none"]')
|
||||
end
|
||||
|
||||
it 'should not display a warning' do
|
||||
expect(rendered).to have_css('.text-warning[style*="display: none"]')
|
||||
end
|
||||
end
|
||||
|
||||
context 'When a dossier whith a procedure is provided' do
|
||||
let!(:procedure) { create(:procedure) }
|
||||
let!(:dossier) { create(:dossier, procedure: procedure) }
|
||||
let!(:champ) { create(:champ, type_de_champ: type_champ, value: dossier.id) }
|
||||
|
||||
it 'should display the procedure libelle' do
|
||||
expect(rendered).not_to have_css('.text-info[style*="display: none"]')
|
||||
end
|
||||
|
||||
it 'should not display a warning' do
|
||||
expect(rendered).to have_css('.text-warning[style*="display: none"]')
|
||||
end
|
||||
end
|
||||
|
||||
context 'When a unknown dossier id is provided' do
|
||||
let!(:champ) { create(:champ, type_de_champ: type_champ, value: 666) }
|
||||
|
||||
it 'should not display the procedure libelle' do
|
||||
expect(rendered).to have_css('.text-info[style*="display: none"]')
|
||||
end
|
||||
|
||||
it 'should display a warning' do
|
||||
expect(rendered).not_to have_css('.text-warning[style*="display: none"]')
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,20 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'users/description/champs/engagement.html.haml', type: :view do
|
||||
let(:type_champ) { create(:type_de_champ_engagement) }
|
||||
|
||||
subject { render 'users/description/champs/engagement.html.haml', champ: champ }
|
||||
|
||||
context "when the value is on" do
|
||||
let!(:champ) { create(:champ, type_de_champ: type_champ, value: "on").decorate }
|
||||
|
||||
it { is_expected.to have_selector("input[type='checkbox'][checked]") }
|
||||
end
|
||||
|
||||
context "when the value is nil" do
|
||||
let!(:champ) { create(:champ, type_de_champ: type_champ, value: nil).decorate }
|
||||
|
||||
it { is_expected.to have_selector("input[type='checkbox']") }
|
||||
it { is_expected.not_to have_selector("input[type='checkbox'][checked]") }
|
||||
end
|
||||
end
|
|
@ -1,13 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'users/description/champs/pays.html.haml', type: :view do
|
||||
let(:champ) { create(:champ) }
|
||||
|
||||
before do
|
||||
render 'users/description/champs/pays.html.haml', champ: champ.decorate
|
||||
end
|
||||
|
||||
it 'should render pays drop down list' do
|
||||
expect(rendered).to include("FRANCE")
|
||||
end
|
||||
end
|
|
@ -1,13 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'users/description/champs/regions.html.haml', vcr: { cassette_name: 'geoapi_regions' }, type: :view do
|
||||
let(:champ) { create(:champ) }
|
||||
|
||||
before do
|
||||
render 'users/description/champs/regions.html.haml', champ: champ.decorate
|
||||
end
|
||||
|
||||
it 'should render regions drop down list' do
|
||||
expect(rendered).to include("Normandie")
|
||||
end
|
||||
end
|
|
@ -1,55 +0,0 @@
|
|||
describe 'users/description/champs/render_list_champs.html.haml', type: :view do
|
||||
let(:type_champ) { create(:type_de_champ_checkbox) }
|
||||
|
||||
context "with any champ" do
|
||||
let!(:champ) { create(:champ, type_de_champ: type_champ, value: nil) }
|
||||
|
||||
before do
|
||||
render 'users/description/champs/render_list_champs.html.haml', champs: Champ.all, order_place: 0
|
||||
end
|
||||
|
||||
it "should render the champ's libelle" do
|
||||
expect(rendered).to have_content(champ.libelle)
|
||||
end
|
||||
end
|
||||
|
||||
context "with a checkbox champ" do
|
||||
context "whose value equals nil" do
|
||||
let!(:champ_checkbox_checked) { create(:champ, type_de_champ: type_champ, value: nil) }
|
||||
|
||||
before do
|
||||
render 'users/description/champs/render_list_champs.html.haml', champs: Champ.all, order_place: 0
|
||||
end
|
||||
|
||||
it 'should not render a checked checkbox' do
|
||||
expect(rendered).not_to have_css('input[type=checkbox][checked]')
|
||||
end
|
||||
end
|
||||
|
||||
context "whose value equals 'on'" do
|
||||
let!(:champ_checkbox_checked) { create(:champ, type_de_champ: type_champ, value: 'on') }
|
||||
|
||||
before do
|
||||
render 'users/description/champs/render_list_champs.html.haml', champs: Champ.all, order_place: 0
|
||||
end
|
||||
|
||||
it 'should render a checked checkbox' do
|
||||
expect(rendered).to have_css('input[type=checkbox][checked]')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a dossier_link' do
|
||||
let(:type_champ) { create(:type_de_champ_dossier_link) }
|
||||
let!(:champ) { create(:champ, type_de_champ: type_champ, value: nil) }
|
||||
|
||||
before do
|
||||
render 'users/description/champs/render_list_champs.html.haml', champs: Champ.all, order_place: 0
|
||||
end
|
||||
|
||||
it 'should render the _dossier_link partial' do
|
||||
expect(view).to render_template(partial: 'users/description/champs/_dossier_link',
|
||||
locals: { champ: champ })
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,25 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'users/description/champs/yes_no.html.haml', type: :view do
|
||||
let(:type_champ) { create(:type_de_champ_yes_no) }
|
||||
|
||||
before do
|
||||
render 'users/description/champs/yes_no.html.haml', champ: champ
|
||||
end
|
||||
|
||||
context "when the value is Oui" do
|
||||
let!(:champ) { create(:champ, type_de_champ: type_champ, value: "true").decorate }
|
||||
|
||||
it 'should select the Oui radio button' do
|
||||
expect(rendered).to have_selector("input[value='true'][checked]")
|
||||
end
|
||||
end
|
||||
|
||||
context "when the value is Non" do
|
||||
let!(:champ) { create(:champ, type_de_champ: type_champ, value: "false").decorate }
|
||||
|
||||
it 'should select the Non radio button' do
|
||||
expect(rendered).to have_selector("input[value='false'][checked]")
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,108 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'users/description/show.html.haml', type: :view do
|
||||
let(:user) { create(:user) }
|
||||
let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, :with_datetime) }
|
||||
let(:dossier) { create(:dossier, procedure: procedure, user: user) }
|
||||
let(:dossier_id) { dossier.id }
|
||||
|
||||
before do
|
||||
sign_in user
|
||||
assign(:dossier, dossier)
|
||||
assign(:procedure, dossier.procedure)
|
||||
assign(:champs, dossier.ordered_champs)
|
||||
end
|
||||
|
||||
context 'tous les attributs sont présents sur la page' do
|
||||
before do
|
||||
render
|
||||
end
|
||||
it 'Le formulaire envoie vers /users/dossiers/:dossier_id/description en #POST' do
|
||||
expect(rendered).to have_selector("form[action='/users/dossiers/#{dossier_id}/description'][method=post]")
|
||||
end
|
||||
end
|
||||
|
||||
context 'si la page précédente n\'est pas recapitulatif' do
|
||||
before do
|
||||
render
|
||||
end
|
||||
it 'le bouton "Terminer" est présent' do
|
||||
expect(rendered).to have_selector('#suivant')
|
||||
end
|
||||
end
|
||||
|
||||
context 'si la page précédente est recapitularif' do
|
||||
before do
|
||||
dossier.en_construction!
|
||||
dossier.reload
|
||||
render
|
||||
end
|
||||
|
||||
it 'le bouton "Terminer" n\'est pas présent' do
|
||||
expect(rendered).to_not have_selector('#suivant')
|
||||
end
|
||||
|
||||
it 'le bouton "Modification terminé" est présent' do
|
||||
expect(rendered).to have_selector('#modification_terminee')
|
||||
end
|
||||
|
||||
it 'le lien de retour au récapitulatif est présent' do
|
||||
expect(rendered).to have_selector("a[href='/users/dossiers/#{dossier_id}/recapitulatif']")
|
||||
end
|
||||
end
|
||||
|
||||
context 'Champs' do
|
||||
let(:champs) { dossier.champs }
|
||||
let(:types_de_champ) { procedure.types_de_champ.where(type_champ: 'datetime').first }
|
||||
let(:champ_datetime) { champs.where(type_de_champ_id: types_de_champ.id).first }
|
||||
|
||||
before do
|
||||
champ_datetime.value = "2016-06-22 12:05"
|
||||
champ_datetime.save
|
||||
render
|
||||
end
|
||||
|
||||
describe 'first champs' do
|
||||
subject { dossier.champs.first }
|
||||
it { expect(rendered).to have_css("#champs_#{subject.id}") }
|
||||
end
|
||||
|
||||
describe 'last champs' do
|
||||
subject { dossier.champs.last }
|
||||
it { expect(rendered).to have_css("#champs_#{subject.id}") }
|
||||
end
|
||||
|
||||
describe 'datetime value is correctly setup when is not nil' do
|
||||
it { expect(rendered).to have_css("input[type='date'][id='champs_#{champ_datetime.id}'][value='2016-06-22']") }
|
||||
it { expect(rendered).to have_css("option[value='12'][selected='selected']") }
|
||||
it { expect(rendered).to have_css("option[value='05'][selected='selected']") }
|
||||
end
|
||||
end
|
||||
|
||||
context 'Pièces justificatives' do
|
||||
let(:all_type_pj_procedure_id) { dossier.procedure.type_de_piece_justificative_ids }
|
||||
|
||||
before do
|
||||
render
|
||||
end
|
||||
|
||||
context 'la liste des pièces justificatives a envoyé est affichée' do
|
||||
it 'RIB' do
|
||||
expect(rendered).to have_css("#piece_justificative_#{all_type_pj_procedure_id[0]}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'display title Documents administratifs' do
|
||||
before do
|
||||
render
|
||||
end
|
||||
|
||||
let(:procedure) { create :procedure, lien_demarche: '' }
|
||||
let(:dossier) { create(:dossier, procedure: procedure) }
|
||||
|
||||
context 'when dossier not have piece justificative and demarche link' do
|
||||
it { expect(rendered).not_to have_content 'Documents administratifs' }
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue