fix tests
This commit is contained in:
parent
6f47655301
commit
314b0f5dc0
6 changed files with 28 additions and 20 deletions
|
@ -19,7 +19,7 @@
|
|||
= f.label :duree_conservation_dossiers_hors_ds, "Hors demarches-simplifiees.fr* (durée en mois après la fin de l'instruction)"
|
||||
= f.number_field :duree_conservation_dossiers_hors_ds, class: 'form-control', placeholder: '6', required: true
|
||||
|
||||
- if @procedure.new?
|
||||
- if @procedure.created_at.present?
|
||||
.form-group
|
||||
%h4 Où les usagers trouveront-ils le lien vers la démarche ?
|
||||
= f.text_field :lien_site_web, class: 'form-control', placeholder: 'https://exemple.gouv.fr/ma_demarche'
|
||||
|
|
|
@ -333,8 +333,7 @@ describe Admin::ProceduresController, type: :controller do
|
|||
end
|
||||
|
||||
describe 'PUT #publish' do
|
||||
let(:lien_site_web) { 'http://mon-site.gouv.fr' }
|
||||
let(:procedure) { create(:procedure, administrateur: admin, lien_site_web: nil) }
|
||||
let(:procedure) { create(:procedure, administrateur: admin, lien_site_web: lien_site_web) }
|
||||
let(:procedure2) { create(:procedure, :published, administrateur: admin, lien_site_web: lien_site_web) }
|
||||
let(:procedure3) { create(:procedure, :published, lien_site_web: lien_site_web) }
|
||||
let(:lien_site_web) { 'http://some.administration/' }
|
||||
|
@ -348,6 +347,7 @@ describe Admin::ProceduresController, type: :controller do
|
|||
|
||||
context 'procedure path does not exist' do
|
||||
let(:path) { 'new_path' }
|
||||
let(:lien_site_web) { 'http://mon-site.gouv.fr' }
|
||||
|
||||
it 'publish the given procedure' do
|
||||
expect(procedure.publiee?).to be_truthy
|
||||
|
@ -360,6 +360,7 @@ describe Admin::ProceduresController, type: :controller do
|
|||
|
||||
context 'procedure path exists and is owned by current administrator' do
|
||||
let(:path) { procedure2.path }
|
||||
let(:lien_site_web) { 'http://mon-site.gouv.fr' }
|
||||
|
||||
it 'publish the given procedure' do
|
||||
expect(procedure.publiee?).to be_truthy
|
||||
|
@ -377,11 +378,12 @@ describe Admin::ProceduresController, type: :controller do
|
|||
|
||||
context 'procedure path exists and is not owned by current administrator' do
|
||||
let(:path) { procedure3.path }
|
||||
let(:lien_site_web) { 'http://mon-site.gouv.fr' }
|
||||
|
||||
it 'does not publish the given procedure' do
|
||||
expect(procedure.publiee?).to be_falsey
|
||||
expect(procedure.path).not_to match(path)
|
||||
expect(procedure.lien_site_web).not_to match(lien_site_web)
|
||||
expect(procedure.lien_site_web).to match(lien_site_web)
|
||||
expect(response.status).to eq 200
|
||||
end
|
||||
|
||||
|
@ -394,26 +396,16 @@ describe Admin::ProceduresController, type: :controller do
|
|||
|
||||
context 'procedure path is invalid' do
|
||||
let(:path) { 'Invalid Procedure Path' }
|
||||
let(:lien_site_web) { 'http://mon-site.gouv.fr' }
|
||||
|
||||
it 'does not publish the given procedure' do
|
||||
expect(procedure.publiee?).to be_falsey
|
||||
expect(procedure.path).not_to match(path)
|
||||
expect(procedure.lien_site_web).not_to match(lien_site_web)
|
||||
expect(procedure.lien_site_web).to match(lien_site_web)
|
||||
expect(response).to redirect_to :admin_procedures
|
||||
expect(flash[:alert]).to have_content 'Lien de la démarche invalide'
|
||||
end
|
||||
end
|
||||
|
||||
context 'procedure path is valid but lien_site_web is missing' do
|
||||
let(:path) { 'new_path' }
|
||||
let(:lien_site_web) { nil }
|
||||
|
||||
it 'does not publish the given procedure' do
|
||||
expect(procedure.publiee?).to be_falsey
|
||||
expect(flash[:alert]).to have_content 'Lien de la démarche invalide'
|
||||
expect(response).to redirect_to :admin_procedures
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when admin is not the owner of the procedure' do
|
||||
|
@ -432,6 +424,21 @@ describe Admin::ProceduresController, type: :controller do
|
|||
expect(flash[:alert]).to have_content 'Démarche inexistante'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the admin does not provide a lien_site_web' do
|
||||
before do
|
||||
put :publish, params: { procedure_id: procedure.id, path: path, lien_site_web: lien_site_web }
|
||||
procedure.reload
|
||||
end
|
||||
context 'procedure path is valid but lien_site_web is missing' do
|
||||
let(:path) { 'new_path2' }
|
||||
let(:lien_site_web) { nil }
|
||||
|
||||
it 'does not publish the given procedure' do
|
||||
expect(procedure.publiee?).to be_falsey
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PUT #archive' do
|
||||
|
|
|
@ -38,7 +38,7 @@ FactoryBot.define do
|
|||
after(:build) do |procedure, _evaluator|
|
||||
procedure.for_individual = true
|
||||
procedure.types_de_champ << create(:type_de_champ, libelle: 'Texte obligatoire', mandatory: true)
|
||||
procedure.publish!(procedure.administrateurs.first, generate(:published_path))
|
||||
procedure.publish!(procedure.administrateurs.first, generate(:published_path), procedure.lien_site_web)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -123,6 +123,7 @@ feature 'As an administrateur I wanna create a new procedure', js: true do
|
|||
|
||||
within '#publish-modal' do
|
||||
expect(page).to have_field('procedure_path')
|
||||
fill_in 'lien_site_web', with: 'http://some.website'
|
||||
click_on 'publish'
|
||||
end
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ require 'spec_helper'
|
|||
|
||||
describe 'admin/procedures/edit.html.haml', type: :view, vcr: { cassette_name: 'admin_procedure_edit' } do
|
||||
let(:logo) { Rack::Test::UploadedFile.new("./spec/fixtures/files/logo_test_procedure.png", 'image/png') }
|
||||
let(:procedure) { create(:procedure, logo: logo) }
|
||||
let(:procedure) { create(:procedure, logo: logo, lien_site_web: 'http://some.website') }
|
||||
|
||||
before do
|
||||
assign(:procedure, procedure)
|
||||
|
|
|
@ -41,7 +41,7 @@ describe 'admin/procedures/show.html.haml', type: :view do
|
|||
|
||||
describe 'procedure is published' do
|
||||
before do
|
||||
procedure.publish!(procedure.administrateurs.first, 'fake_path')
|
||||
procedure.publish!(procedure.administrateurs.first, 'fake_path', procedure.lien_site_web)
|
||||
procedure.reload
|
||||
render
|
||||
end
|
||||
|
@ -59,7 +59,7 @@ describe 'admin/procedures/show.html.haml', type: :view do
|
|||
|
||||
describe 'procedure is archived' do
|
||||
before do
|
||||
procedure.publish!(procedure.administrateurs.first, 'fake_path')
|
||||
procedure.publish!(procedure.administrateurs.first, 'fake_path', procedure.lien_site_web)
|
||||
procedure.archive!
|
||||
procedure.reload
|
||||
render
|
||||
|
|
Loading…
Reference in a new issue