diff --git a/app/controllers/users/commencer_controller.rb b/app/controllers/users/commencer_controller.rb index 324b24f8f..71155061a 100644 --- a/app/controllers/users/commencer_controller.rb +++ b/app/controllers/users/commencer_controller.rb @@ -71,8 +71,8 @@ module Users if procedure&.close? flash.alert = procedure.service.presence ? - t('errors.messages.procedure_archived.with_service_and_phone_email', service_phone_number: procedure.service.telephone, service_email: procedure.service.email) : - t('errors.messages.procedure_archived.with_organisation_only', organisation_name: procedure.organisation_name) + t('errors.messages.procedure_archived.with_service_and_phone_email', service_name: procedure.organisation, service_phone_number: procedure.service.telephone, service_email: procedure.service.email) : + t('errors.messages.procedure_archived.with_organisation_only', organisation_name: procedure.organisation) else flash.alert = t('errors.messages.procedure_not_found') end diff --git a/spec/controllers/users/commencer_controller_spec.rb b/spec/controllers/users/commencer_controller_spec.rb index a499b8f1e..39517f752 100644 --- a/spec/controllers/users/commencer_controller_spec.rb +++ b/spec/controllers/users/commencer_controller_spec.rb @@ -33,8 +33,19 @@ describe Users::CommencerController, type: :controller do end end - context 'when procedure is closed' do + context 'when procedure without service is closed' do it 'works' do + published_procedure.service = nil + published_procedure.organisation = "hello" + published_procedure.close! + get :commencer, params: { path: published_procedure.path } + expect(response).to redirect_to(root_path) + end + end + + context 'when procedure with service is closed' do + it 'works' do + published_procedure.service = create(:service) published_procedure.close! get :commencer, params: { path: published_procedure.path } expect(response).to redirect_to(root_path)