Use enum to the fullest with Service.type_organismes
This commit is contained in:
parent
2d3b553e4d
commit
ee25bba38c
3 changed files with 6 additions and 6 deletions
|
@ -30,7 +30,7 @@ describe NewAdministrateur::ServicesController, type: :controller do
|
||||||
it { expect(Service.last.nom).to eq('super service') }
|
it { expect(Service.last.nom).to eq('super service') }
|
||||||
it { expect(Service.last.organisme).to eq('organisme') }
|
it { expect(Service.last.organisme).to eq('organisme') }
|
||||||
it { expect(Service.last.siret).to eq('01234567891234') }
|
it { expect(Service.last.siret).to eq('01234567891234') }
|
||||||
it { expect(Service.last.type_organisme).to eq('region') }
|
it { expect(Service.last.type_organisme).to eq(Service.type_organismes.fetch(:region)) }
|
||||||
it { expect(Service.last.email).to eq('email@toto.com') }
|
it { expect(Service.last.email).to eq('email@toto.com') }
|
||||||
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') }
|
||||||
|
@ -48,7 +48,7 @@ describe NewAdministrateur::ServicesController, type: :controller do
|
||||||
|
|
||||||
describe '#update' do
|
describe '#update' do
|
||||||
let!(:service) { create(:service, administrateur: admin) }
|
let!(:service) { create(:service, administrateur: admin) }
|
||||||
let(:service_params) { { nom: 'nom', type_organisme: 'region' } }
|
let(:service_params) { { nom: 'nom', type_organisme: Service.type_organismes.fetch(:region) } }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
sign_in admin
|
sign_in admin
|
||||||
|
@ -64,12 +64,12 @@ describe NewAdministrateur::ServicesController, type: :controller do
|
||||||
it { expect(flash.alert).to be_nil }
|
it { expect(flash.alert).to be_nil }
|
||||||
it { expect(flash.notice).to eq('nom modifié') }
|
it { expect(flash.notice).to eq('nom modifié') }
|
||||||
it { expect(Service.last.nom).to eq('nom') }
|
it { expect(Service.last.nom).to eq('nom') }
|
||||||
it { expect(Service.last.type_organisme).to eq('region') }
|
it { expect(Service.last.type_organisme).to eq(Service.type_organismes.fetch(:region)) }
|
||||||
it { expect(response).to redirect_to(services_path(procedure_id: procedure.id)) }
|
it { expect(response).to redirect_to(services_path(procedure_id: procedure.id)) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when updating a service with invalid data' do
|
context 'when updating a service with invalid data' do
|
||||||
let(:service_params) { { nom: '', type_organisme: 'region' } }
|
let(:service_params) { { nom: '', type_organisme: Service.type_organismes.fetch(:region) } }
|
||||||
|
|
||||||
it { expect(flash.alert).not_to be_nil }
|
it { expect(flash.alert).not_to be_nil }
|
||||||
it { expect(response).to render_template(:edit) }
|
it { expect(response).to render_template(:edit) }
|
||||||
|
|
|
@ -2,7 +2,7 @@ FactoryBot.define do
|
||||||
factory :service do
|
factory :service do
|
||||||
nom 'service'
|
nom 'service'
|
||||||
organisme 'organisme'
|
organisme 'organisme'
|
||||||
type_organisme 'commune'
|
type_organisme Service.type_organismes.fetch(:commune)
|
||||||
administrateur { create(:administrateur) }
|
administrateur { create(:administrateur) }
|
||||||
email 'email@toto.com'
|
email 'email@toto.com'
|
||||||
telephone '1234'
|
telephone '1234'
|
||||||
|
|
|
@ -5,7 +5,7 @@ describe Service, type: :model do
|
||||||
{
|
{
|
||||||
nom: 'service des jardins',
|
nom: 'service des jardins',
|
||||||
organisme: 'mairie des iles',
|
organisme: 'mairie des iles',
|
||||||
type_organisme: 'commune',
|
type_organisme: Service.type_organismes.fetch(:commune),
|
||||||
email: 'super@email.com',
|
email: 'super@email.com',
|
||||||
telephone: '1212202',
|
telephone: '1212202',
|
||||||
horaires: 'du lundi au vendredi',
|
horaires: 'du lundi au vendredi',
|
||||||
|
|
Loading…
Reference in a new issue