Service: can update a service
This commit is contained in:
parent
c54c85bad8
commit
365cb9b44d
7 changed files with 70 additions and 4 deletions
|
@ -24,4 +24,29 @@ describe NewAdministrateur::ServicesController, type: :controller do
|
|||
it { expect(response).to render_template(:new) }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#update' do
|
||||
let!(:service) { create(:service, administrateur: admin) }
|
||||
let(:service_params) { { nom: 'nom', type_organisme: 'region' } }
|
||||
|
||||
before do
|
||||
sign_in admin
|
||||
patch :update, params: { id: service.id, service: service_params }
|
||||
end
|
||||
|
||||
context 'when updating a service' do
|
||||
it { expect(flash.alert).to be_nil }
|
||||
it { expect(flash.notice).to eq('nom modifié') }
|
||||
it { expect(Service.last.nom).to eq('nom') }
|
||||
it { expect(Service.last.type_organisme).to eq('region') }
|
||||
it { expect(response).to redirect_to(services_path) }
|
||||
end
|
||||
|
||||
context 'when updating a service with invalid data' do
|
||||
let(:service_params) { { nom: '', type_organisme: 'region' } }
|
||||
|
||||
it { expect(flash.alert).not_to be_nil }
|
||||
it { expect(response).to render_template(:edit) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue