Rename Procedure#archived? -> #archivee?

This commit is contained in:
gregoirenovel 2017-07-13 15:09:25 +02:00
parent 07d390db09
commit cfec05506a
11 changed files with 33 additions and 23 deletions

View file

@ -53,7 +53,7 @@ class Admin::ProceduresController < AdminController
def destroy
procedure = Procedure.find(params[:id])
return render json: {}, status: 401 if procedure.published? || procedure.archived?
return render json: {}, status: 401 if procedure.published? || procedure.archivee?
procedure.destroy

View file

@ -47,7 +47,7 @@ class Users::DossiersController < UsersController
end
end
if procedure.archived?
if procedure.archivee?
@dossier = Dossier.new(procedure: procedure)

View file

@ -285,7 +285,7 @@ class Dossier < ActiveRecord::Base
end
def can_be_initiated?
!(procedure.archived? && draft?)
!(procedure.archivee? && draft?)
end
def text_summary

View file

@ -133,7 +133,7 @@ class Procedure < ActiveRecord::Base
self.update_attributes!(archived_at: Time.now)
end
def archived?
def archivee?
archived_at.present?
end

View file

@ -20,7 +20,7 @@
= procedure.created_at_fr
%td
= link_to('Cloner', admin_procedure_clone_path(procedure.id), 'data-method' => :put, class: 'btn-sm btn-primary clone-btn')
- unless procedure.published? || procedure.archived?
- unless procedure.published? || procedure.archivee?
= link_to('X', url_for(controller: 'admin/procedures', action: :destroy, id: procedure.id), 'data-method' => :delete, class: 'btn-sm btn-danger')
= smart_listing.paginate

View file

@ -6,14 +6,14 @@
%button.close{ "aria-label" => "Close", "data-dismiss" => "modal", :type => "button" }
%span{ "aria-hidden" => "true" } ×
%h4#myModalLabel.modal-title
= @procedure.archived? ? 'Réactiver' : 'Publier'
= @procedure.archivee? ? 'Réactiver' : 'Publier'
la procédure
%span#publish-modal-title
.modal-body
Vous vous apprêtez à
= @procedure.archived? ? 'republier' : 'publier'
= @procedure.archivee? ? 'republier' : 'publier'
votre procédure au public.
- unless @procedure.archived?
- unless @procedure.archivee?
%b
Elle ne pourra plus être modifiée à l'issue de cette publication.
%br
@ -42,7 +42,7 @@
#path_is_invalid.text-danger.center.message
= t('activerecord.errors.models.procedure_path.attributes.path.format')
.modal-footer
= submit_tag "#{@procedure.archived? ? 'Réactiver' : 'Publier'}", class: %w(btn btn btn-success),
= submit_tag "#{@procedure.archivee? ? 'Réactiver' : 'Publier'}", class: %w(btn btn btn-success),
id: 'publish',
disabled: :disabled
= button_tag 'Annuler', class: %w(btn btn btn-default), id: 'cancel', data: { dismiss: 'modal' }

View file

@ -18,7 +18,7 @@
= render partial: '/admin/procedures/modal_transfer'
- if @facade.procedure.archived?
- if @facade.procedure.archivee?
%a#reenable.btn.btn-small.btn-default.text-info{ "data-target" => "#publish-modal", "data-toggle" => "modal", :type => "button", style: 'float: right; margin-top: 10px;' }
%i.fa.fa-eraser
Réactiver
@ -26,7 +26,7 @@
= render partial: '/admin/procedures/modal_publish'
- elsif @facade.procedure.published?
= form_tag admin_procedure_archive_path(procedure_id: @facade.procedure.id, archive: !@facade.procedure.archived?), method: :put, style: 'float: right; margin-top: 10px;' do
= form_tag admin_procedure_archive_path(procedure_id: @facade.procedure.id, archive: !@facade.procedure.archivee?), method: :put, style: 'float: right; margin-top: 10px;' do
%button#archive.btn.btn-small.btn-default.text-info{ type: :button }
%i.fa.fa-eraser
Archiver
@ -130,7 +130,7 @@
- else
= pie_chart @facade.dossiers_for_pie_highchart
- if @facade.procedure.published? || @facade.procedure.archived?
- if @facade.procedure.published? || @facade.procedure.archivee?
%h3 Supprimer la procédure
.alert.alert-danger
%p

View file

@ -42,5 +42,5 @@
- elsif !@dossier.draft?
= render partial: '/layouts/modifications_terminees'
- else
= submit_tag 'Soumettre mon dossier', id: 'suivant', name: 'submit[nouveaux]', class: 'btn btn btn-success', style: 'float: right;', disabled: @procedure.archived?, data: { disable_with: 'Soumettre votre dossier', submit: true }
= submit_tag 'Enregistrer un brouillon', id: 'brouillon', name: 'submit[brouillon]', class: 'btn btn-xs btn-default', style: 'float: right; margin-right: 10px; margin-top: 6px;', disabled: @procedure.archived?, data: { disable_with: 'Enregistrer un brouillon', submit: true }
= submit_tag 'Soumettre mon dossier', id: 'suivant', name: 'submit[nouveaux]', class: 'btn btn btn-success', style: 'float: right;', disabled: @procedure.archivee?, data: { disable_with: 'Soumettre votre dossier', submit: true }
= submit_tag 'Enregistrer un brouillon', id: 'brouillon', name: 'submit[brouillon]', class: 'btn btn-xs btn-default', style: 'float: right; margin-right: 10px; margin-top: 6px;', disabled: @procedure.archivee?, data: { disable_with: 'Enregistrer un brouillon', submit: true }

View file

@ -316,7 +316,7 @@ describe Admin::ProceduresController, type: :controller do
it 'archive previous procedure' do
expect(procedure2.published?).to be_truthy
expect(procedure2.archived?).to be_truthy
expect(procedure2.archivee?).to be_truthy
expect(procedure2.path).to be_nil
end
end
@ -332,7 +332,7 @@ describe Admin::ProceduresController, type: :controller do
it 'previous procedure remains published' do
expect(procedure2.published?).to be_truthy
expect(procedure2.archived?).to be_falsey
expect(procedure2.archivee?).to be_falsey
expect(procedure2.path).to match(/fake_path/)
end
end
@ -377,7 +377,7 @@ describe Admin::ProceduresController, type: :controller do
end
context 'when owner want archive procedure' do
it { expect(procedure.archived?).to be_truthy }
it { expect(procedure.archivee?).to be_truthy }
it { expect(response).to redirect_to :admin_procedures }
it { expect(flash[:notice]).to have_content 'Procédure archivée' }
end
@ -388,7 +388,7 @@ describe Admin::ProceduresController, type: :controller do
procedure.reload
end
it { expect(procedure.archived?).to be_falsey }
it { expect(procedure.archivee?).to be_falsey }
it { expect(response.status).to eq 200 }
it { expect(flash[:notice]).to have_content 'Procédure publiée' }
end

View file

@ -243,6 +243,16 @@ describe Procedure do
end
end
describe "#archivee?" do
let(:procedure_brouillon) { Procedure.new() }
let(:procedure_publiee) { Procedure.new(published_at: Time.now) }
let(:procedure_archivee) { Procedure.new(published_at: Time.now, archived_at: Time.now) }
it { expect(procedure_brouillon.archivee?).to be_falsey }
it { expect(procedure_publiee.archivee?).to be_falsey }
it { expect(procedure_archivee.archivee?).to be_truthy }
end
describe 'archive' do
let(:procedure) { create(:procedure, :published) }
let(:procedure_path) { ProcedurePath.find(procedure.procedure_path.id) }
@ -254,7 +264,7 @@ describe Procedure do
end
it { expect(procedure.published?).to be_truthy }
it { expect(procedure.archived?).to be_truthy }
it { expect(procedure.archivee?).to be_truthy }
it { expect(procedure.archived_at).to eq(now) }
after do

View file

@ -14,7 +14,7 @@ RSpec.describe AutoArchiveProcedureWorker, type: :worker do
procedure.reload
end
it { expect(procedure.archived?).to eq false }
it { expect(procedure.archivee?).to eq false }
end
context "when procedures have auto_archive_on set on yesterday or today" do
@ -49,8 +49,8 @@ RSpec.describe AutoArchiveProcedureWorker, type: :worker do
it { expect(dossier8.state).to eq 'without_continuation' }
it { expect(dossier9.state).to eq 'received' }
it { expect(procedure_hier.archived?).to eq true }
it { expect(procedure_aujourdhui.archived?).to eq true }
it { expect(procedure_hier.archivee?).to eq true }
it { expect(procedure_aujourdhui.archivee?).to eq true }
end
context "when procedures have auto_archive_on set on future" do
@ -58,6 +58,6 @@ RSpec.describe AutoArchiveProcedureWorker, type: :worker do
subject
end
it { expect(procedure_demain.archived?).to eq false }
it { expect(procedure_demain.archivee?).to eq false }
end
end