specs: refactor dossiers_controller_spec
This commit is contained in:
parent
b8706757e3
commit
2261c6c5d2
1 changed files with 21 additions and 7 deletions
|
@ -541,10 +541,16 @@ describe Users::DossiersController, type: :controller do
|
|||
{
|
||||
id: dossier.id,
|
||||
dossier: {
|
||||
champs_attributes: {
|
||||
id: first_champ.id,
|
||||
value: value
|
||||
}
|
||||
champs_attributes: [
|
||||
{
|
||||
id: first_champ.id,
|
||||
value: value
|
||||
},
|
||||
{
|
||||
id: piece_justificative_champ.id,
|
||||
piece_justificative_file: file
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
end
|
||||
|
@ -561,7 +567,6 @@ describe Users::DossiersController, type: :controller do
|
|||
|
||||
it 'redirects to the dossiers list' do
|
||||
subject
|
||||
|
||||
expect(response).to redirect_to(dossiers_path)
|
||||
expect(flash.alert).to eq('Votre dossier ne peut plus être modifié')
|
||||
end
|
||||
|
@ -570,13 +575,22 @@ describe Users::DossiersController, type: :controller do
|
|||
context 'when dossier can be updated by the owner' do
|
||||
it 'updates the champs' do
|
||||
subject
|
||||
|
||||
expect(response).to redirect_to(demande_dossier_path(dossier))
|
||||
expect(first_champ.reload.value).to eq('beautiful value')
|
||||
expect(piece_justificative_champ.reload.piece_justificative_file).to be_attached
|
||||
end
|
||||
|
||||
it 'updates the dossier modification date' do
|
||||
subject
|
||||
expect(dossier.reload.updated_at.year).to eq(2100)
|
||||
end
|
||||
|
||||
it 'updates the dossier state' do
|
||||
subject
|
||||
expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_construction))
|
||||
end
|
||||
|
||||
it { is_expected.to redirect_to(demande_dossier_path(dossier)) }
|
||||
|
||||
context 'when only files champs are modified' do
|
||||
let(:submit_payload) do
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue