Handle "réactiver" feature with permanent procedure url
This commit is contained in:
parent
e5002dbb11
commit
92a5100a09
4 changed files with 23 additions and 17 deletions
|
@ -73,7 +73,7 @@ class Procedure < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def publish(path)
|
||||
self.update_attributes!({ published: true })
|
||||
self.update_attributes!({ published: true, archived: false })
|
||||
ProcedurePath.create!(path: path, procedure: self, administrateur: self.administrateur)
|
||||
end
|
||||
|
||||
|
|
|
@ -6,10 +6,14 @@
|
|||
%button.close{"aria-label" => "Close", "data-dismiss" => "modal", :type => "button"}
|
||||
%span{"aria-hidden" => "true"} ×
|
||||
%h4#myModalLabel.modal-title
|
||||
Publier la procédure
|
||||
=@procedure.archived?? 'Réactiver' : 'Publier'
|
||||
la procédure
|
||||
%span#publishModal_title
|
||||
.modal-body
|
||||
Vous vous apprêtez à publier votre procédure au public.
|
||||
Vous vous apprêtez à
|
||||
=@procedure.archived?? 'republier' : 'publier'
|
||||
votre procédure au public.
|
||||
- unless @procedure.archived?
|
||||
%b
|
||||
Elle ne pourra plus être modifiée à l'issue de cette publication.
|
||||
%br
|
||||
|
@ -39,7 +43,7 @@
|
|||
Ce lien n'est pas valide. Seuls les caractères a-z, 0-9 et '_' sont autorisés.
|
||||
.modal-footer
|
||||
= submit_tag 'Annuler', class: %w(btn btn btn-default), id: 'cancel', data: { dismiss: 'modal' }
|
||||
= submit_tag 'Publier', class: %w(btn btn btn-success),
|
||||
= submit_tag "#{@procedure.archived?? 'Réactiver' : 'Publier'}", class: %w(btn btn btn-success),
|
||||
id: 'publish',
|
||||
data: { disable_with: 'Publication en cours', submit: true},
|
||||
disabled: :disabled
|
||||
|
|
|
@ -8,13 +8,16 @@
|
|||
%br
|
||||
=render partial: '/admin/procedures/modal_publish'
|
||||
|
||||
-if @facade.procedure.archived?
|
||||
%a.btn.btn-small.btn-default.text-info{"data-target" => "#publishModal", "data-toggle" => "modal", :type => "button", style:'float: right; margin-top: 10px'}
|
||||
%i.fa.fa-eraser
|
||||
Réactiver
|
||||
%br
|
||||
=render partial: '/admin/procedures/modal_publish'
|
||||
-else
|
||||
= form_tag admin_procedure_archive_path(procedure_id: @facade.procedure.id, archive: !@facade.procedure.archived?), method: :put, style:'float: right; margin-top: 10px' do
|
||||
%button#archive.btn.btn-small.btn-default.text-info{type: :button}
|
||||
%i.fa.fa-eraser
|
||||
- if @facade.procedure.archived
|
||||
= 'Réactiver'
|
||||
- else
|
||||
= 'Archiver'
|
||||
#confirm
|
||||
%button#valid.btn.btn-small.btn-success{type: :submit}
|
||||
|
|
|
@ -355,26 +355,25 @@ describe Admin::ProceduresController, type: :controller do
|
|||
|
||||
context 'when admin is the owner of the procedure' do
|
||||
before do
|
||||
put :archive, procedure_id: procedure.id, archive: archive
|
||||
put :archive, procedure_id: procedure.id
|
||||
procedure.reload
|
||||
end
|
||||
|
||||
context 'when owner want archive procedure' do
|
||||
|
||||
let(:archive) { true }
|
||||
|
||||
it { expect(procedure.archived).to be_truthy }
|
||||
it { expect(response).to redirect_to :admin_procedures }
|
||||
it { expect(flash[:notice]).to have_content 'Procédure archivée' }
|
||||
end
|
||||
|
||||
context 'when owner want reactive procedure' do
|
||||
|
||||
let(:archive) { false }
|
||||
before do
|
||||
put :publish, procedure_id: procedure.id, procedure_path: 'fake_path'
|
||||
procedure.reload
|
||||
end
|
||||
|
||||
it { expect(procedure.archived).to be_falsey }
|
||||
it { expect(response).to redirect_to :admin_procedures }
|
||||
it { expect(flash[:notice]).to have_content 'Procédure éditée' }
|
||||
it { expect(flash[:notice]).to have_content 'Procédure publiée' }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue