Remove path availability dead code when creating/editing a procedure
There’s no “path” field anymore in the Procedure form, it can only be set when publishing.
This commit is contained in:
parent
b9968b76b0
commit
92e6032115
5 changed files with 0 additions and 101 deletions
|
@ -43,8 +43,6 @@ class Admin::ProceduresController < AdminController
|
|||
end
|
||||
|
||||
def edit
|
||||
@path = @procedure.path || @procedure.default_path
|
||||
@availability = @procedure.path_availability(current_administrateur, @path)
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
@ -63,13 +61,10 @@ class Admin::ProceduresController < AdminController
|
|||
|
||||
def new
|
||||
@procedure ||= Procedure.new(for_individual: true)
|
||||
@availability = Procedure::PATH_AVAILABLE
|
||||
end
|
||||
|
||||
def create
|
||||
@procedure = Procedure.new(procedure_params.merge(administrateurs: [current_administrateur]))
|
||||
@path = @procedure.path
|
||||
@availability = Procedure.path_availability(current_administrateur, @procedure.path)
|
||||
|
||||
if !@procedure.save
|
||||
flash.now.alert = @procedure.errors.full_messages
|
||||
|
@ -87,10 +82,6 @@ class Admin::ProceduresController < AdminController
|
|||
|
||||
if !@procedure.update(procedure_params)
|
||||
flash.now.alert = @procedure.errors.full_messages
|
||||
@path = procedure_params[:path]
|
||||
if @path.present?
|
||||
@availability = @procedure.path_availability(current_administrateur, @path)
|
||||
end
|
||||
render 'edit'
|
||||
elsif @procedure.brouillon?
|
||||
reset_procedure
|
||||
|
@ -234,18 +225,6 @@ class Admin::ProceduresController < AdminController
|
|||
render json: json_path_list
|
||||
end
|
||||
|
||||
def check_availability
|
||||
path = params[:procedure][:path]
|
||||
procedure_id = params[:procedure][:id]
|
||||
|
||||
if procedure_id.present?
|
||||
procedure = current_administrateur.procedures.find(procedure_id)
|
||||
@availability = procedure.path_availability(current_administrateur, path)
|
||||
else
|
||||
@availability = Procedure.path_availability(current_administrateur, path)
|
||||
end
|
||||
end
|
||||
|
||||
def delete_logo
|
||||
@procedure.logo.purge_later
|
||||
@procedure.logo_active_storage.purge_later
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
- case availability
|
||||
- when Procedure::PATH_AVAILABLE_PUBLIEE
|
||||
Ce lien est déjà utilisé par une de vos démarche.
|
||||
%br
|
||||
Si vous voulez l’utiliser, l’ancienne démarche sera archivée lors de la publication de la démarche (plus accessible du public).
|
||||
- when Procedure::PATH_NOT_AVAILABLE_BROUILLON
|
||||
Une démarche en test existe déjà avec ce lien.
|
||||
- when Procedure::PATH_NOT_AVAILABLE
|
||||
Ce lien est déjà utilisé par une démarche.
|
||||
%br
|
||||
Vous ne pouvez pas l’utiliser car il appartient à un autre administrateur.
|
|
@ -1,11 +0,0 @@
|
|||
<% if @availability == Procedure::PATH_AVAILABLE %>
|
||||
<%= remove_element('.unavailable-path-message', inner: true) %>
|
||||
<% else %>
|
||||
<%= render_to_element('.unavailable-path-message', partial: 'unavailable', locals: { availability: @availability }) %>
|
||||
<% end %>
|
||||
|
||||
<% if @availability.in?(Procedure::PATH_CAN_PUBLISH) %>
|
||||
<%= enable_element('button[type=submit]') %>
|
||||
<% else %>
|
||||
<%= disable_element('button[type=submit]') %>
|
||||
<% end %>
|
|
@ -160,7 +160,6 @@ Rails.application.routes.draw do
|
|||
get 'procedures/archived' => 'procedures#archived'
|
||||
get 'procedures/draft' => 'procedures#draft'
|
||||
get 'procedures/path_list' => 'procedures#path_list'
|
||||
get 'procedures/available' => 'procedures#check_availability'
|
||||
|
||||
resources :procedures do
|
||||
collection do
|
||||
|
|
|
@ -716,63 +716,6 @@ describe Admin::ProceduresController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
describe "GET #check_availability" do
|
||||
render_views
|
||||
let(:procedure) { create(:procedure, :with_path, administrateur: admin) }
|
||||
let(:params) {
|
||||
{
|
||||
procedure: {
|
||||
path: path,
|
||||
id: procedure.id
|
||||
}
|
||||
}
|
||||
}
|
||||
let(:path) { generate(:published_path) }
|
||||
|
||||
before do
|
||||
get :check_availability, params: params, format: 'js'
|
||||
end
|
||||
|
||||
context 'self path' do
|
||||
let(:path) { procedure.path }
|
||||
|
||||
it { expect(response.body).to include("innerHTML = ''") }
|
||||
end
|
||||
|
||||
context 'available path' do
|
||||
it { expect(response.body).to include("innerHTML = ''") }
|
||||
end
|
||||
|
||||
context 'my path (brouillon)' do
|
||||
let(:procedure_owned) { create(:procedure, :with_path, administrateur: admin) }
|
||||
let(:path) { procedure_owned.path }
|
||||
|
||||
it {
|
||||
expect(response.body).to include('Une démarche en test existe déjà avec ce lien.')
|
||||
}
|
||||
end
|
||||
|
||||
context 'my path' do
|
||||
let(:procedure_owned) { create(:procedure, :published, administrateur: admin) }
|
||||
let(:path) { procedure_owned.path }
|
||||
|
||||
it {
|
||||
expect(response.body).to include('Ce lien est déjà utilisé par une de vos démarche.')
|
||||
expect(response.body).to include('Si vous voulez l’utiliser, l’ancienne démarche sera archivée')
|
||||
}
|
||||
end
|
||||
|
||||
context 'unavailable path' do
|
||||
let(:procedure_not_owned) { create(:procedure, :with_path, administrateur: create(:administrateur)) }
|
||||
let(:path) { procedure_not_owned.path }
|
||||
|
||||
it {
|
||||
expect(response.body).to include('Ce lien est déjà utilisé par une démarche.')
|
||||
expect(response.body).to include('Vous ne pouvez pas l’utiliser car il appartient à un autre administrateur.')
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PATCH #monavis' do
|
||||
let!(:procedure) { create(:procedure, administrateur: admin) }
|
||||
let(:procedure_params) {
|
||||
|
|
Loading…
Reference in a new issue