refactor(spec/services): dynamic procedure reference instead of hardcoded id
This commit is contained in:
parent
a4d9a45280
commit
54181bd920
1 changed files with 6 additions and 6 deletions
|
@ -20,7 +20,7 @@ describe Administrateurs::ServicesController, type: :controller do
|
||||||
horaires: 'horaires',
|
horaires: 'horaires',
|
||||||
adresse: 'adresse'
|
adresse: 'adresse'
|
||||||
},
|
},
|
||||||
procedure_id: 12
|
procedure_id: procedure.id
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ describe Administrateurs::ServicesController, type: :controller do
|
||||||
it { expect(Service.last.telephone).to eq('1234') }
|
it { expect(Service.last.telephone).to eq('1234') }
|
||||||
it { expect(Service.last.horaires).to eq('horaires') }
|
it { expect(Service.last.horaires).to eq('horaires') }
|
||||||
it { expect(Service.last.adresse).to eq('adresse') }
|
it { expect(Service.last.adresse).to eq('adresse') }
|
||||||
it { expect(response).to redirect_to(admin_services_path(procedure_id: 12)) }
|
it { expect(response).to redirect_to(admin_services_path(procedure_id: procedure.id)) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when submitting an invalid service' do
|
context 'when submitting an invalid service' do
|
||||||
|
@ -113,13 +113,13 @@ describe Administrateurs::ServicesController, type: :controller do
|
||||||
context 'when a service has no related procedure' do
|
context 'when a service has no related procedure' do
|
||||||
before do
|
before do
|
||||||
sign_in(admin.user)
|
sign_in(admin.user)
|
||||||
delete :destroy, params: { id: service.id, procedure_id: 12 }
|
delete :destroy, params: { id: service.id, procedure_id: procedure.id }
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect { service.reload }.to raise_error(ActiveRecord::RecordNotFound) }
|
it { expect { service.reload }.to raise_error(ActiveRecord::RecordNotFound) }
|
||||||
it { expect(flash.alert).to be_nil }
|
it { expect(flash.alert).to be_nil }
|
||||||
it { expect(flash.notice).to eq("#{service.nom} est supprimé") }
|
it { expect(flash.notice).to eq("#{service.nom} est supprimé") }
|
||||||
it { expect(response).to redirect_to(admin_services_path(procedure_id: 12)) }
|
it { expect(response).to redirect_to(admin_services_path(procedure_id: procedure.id)) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when a service still has some related procedures' do
|
context 'when a service still has some related procedures' do
|
||||||
|
@ -127,13 +127,13 @@ describe Administrateurs::ServicesController, type: :controller do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
sign_in(admin.user)
|
sign_in(admin.user)
|
||||||
delete :destroy, params: { id: service.id, procedure_id: 12 }
|
delete :destroy, params: { id: service.id, procedure_id: procedure.id }
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(service.reload).not_to be_nil }
|
it { expect(service.reload).not_to be_nil }
|
||||||
it { expect(flash.alert).to eq("la démarche #{procedure.libelle} utilise encore le service #{service.nom}. Veuillez l'affecter à un autre service avant de pouvoir le supprimer") }
|
it { expect(flash.alert).to eq("la démarche #{procedure.libelle} utilise encore le service #{service.nom}. Veuillez l'affecter à un autre service avant de pouvoir le supprimer") }
|
||||||
it { expect(flash.notice).to be_nil }
|
it { expect(flash.notice).to be_nil }
|
||||||
it { expect(response).to redirect_to(admin_services_path(procedure_id: 12)) }
|
it { expect(response).to redirect_to(admin_services_path(procedure_id: procedure.id)) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when a service has some related discarded procedures" do
|
context "when a service has some related discarded procedures" do
|
||||||
|
|
Loading…
Reference in a new issue