commit
926b723d80
19 changed files with 110 additions and 64 deletions
|
@ -6,7 +6,7 @@ class Admin::ProceduresController < AdminController
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@procedures = smart_listing_create :procedures,
|
@procedures = smart_listing_create :procedures,
|
||||||
current_administrateur.procedures.published.not_archived.order(created_at: :desc),
|
current_administrateur.procedures.publiees.order(created_at: :desc),
|
||||||
partial: "admin/procedures/list",
|
partial: "admin/procedures/list",
|
||||||
array: true
|
array: true
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ class Admin::ProceduresController < AdminController
|
||||||
|
|
||||||
def archived
|
def archived
|
||||||
@procedures = smart_listing_create :procedures,
|
@procedures = smart_listing_create :procedures,
|
||||||
current_administrateur.procedures.archived.order(created_at: :desc),
|
current_administrateur.procedures.archivees.order(created_at: :desc),
|
||||||
partial: "admin/procedures/list",
|
partial: "admin/procedures/list",
|
||||||
array: true
|
array: true
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ class Admin::ProceduresController < AdminController
|
||||||
|
|
||||||
def draft
|
def draft
|
||||||
@procedures = smart_listing_create :procedures,
|
@procedures = smart_listing_create :procedures,
|
||||||
current_administrateur.procedures.not_published.not_archived.order(created_at: :desc),
|
current_administrateur.procedures.brouillons.order(created_at: :desc),
|
||||||
partial: "admin/procedures/list",
|
partial: "admin/procedures/list",
|
||||||
array: true
|
array: true
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ class Admin::ProceduresController < AdminController
|
||||||
def destroy
|
def destroy
|
||||||
procedure = Procedure.find(params[:id])
|
procedure = Procedure.find(params[:id])
|
||||||
|
|
||||||
return render json: {}, status: 401 if procedure.published? || procedure.archived?
|
return render json: {}, status: 401 if procedure.publiee_ou_archivee?
|
||||||
|
|
||||||
procedure.destroy
|
procedure.destroy
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ class DemoController < ApplicationController
|
||||||
return redirect_to root_path if Rails.env.production?
|
return redirect_to root_path if Rails.env.production?
|
||||||
|
|
||||||
smart_listing_create :procedures,
|
smart_listing_create :procedures,
|
||||||
Procedure.published.not_archived.order("id DESC"),
|
Procedure.publiees.order("id DESC"),
|
||||||
partial: "demo/list",
|
partial: "demo/list",
|
||||||
array: true
|
array: true
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,7 +4,7 @@ class StatsController < ApplicationController
|
||||||
MEAN_NUMBER_OF_CHAMPS_IN_A_FORM = 24.0
|
MEAN_NUMBER_OF_CHAMPS_IN_A_FORM = 24.0
|
||||||
|
|
||||||
def index
|
def index
|
||||||
procedures = Procedure.published
|
procedures = Procedure.publiee_ou_archivee
|
||||||
dossiers = Dossier.where.not(:state => :draft)
|
dossiers = Dossier.where.not(:state => :draft)
|
||||||
|
|
||||||
@procedures_count = procedures.count
|
@procedures_count = procedures.count
|
||||||
|
|
|
@ -47,7 +47,7 @@ class Users::DossiersController < UsersController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if procedure.archived?
|
if procedure.archivee?
|
||||||
|
|
||||||
@dossier = Dossier.new(procedure: procedure)
|
@dossier = Dossier.new(procedure: procedure)
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ class Users::DossiersController < UsersController
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
procedure = Procedure.not_archived.published.find(params[:procedure_id])
|
procedure = Procedure.publiees.find(params[:procedure_id])
|
||||||
|
|
||||||
dossier = Dossier.create(procedure: procedure, user: current_user, state: 'draft')
|
dossier = Dossier.create(procedure: procedure, user: current_user, state: 'draft')
|
||||||
siret = params[:siret] || current_user.siret
|
siret = params[:siret] || current_user.siret
|
||||||
|
|
|
@ -285,7 +285,7 @@ class Dossier < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_be_initiated?
|
def can_be_initiated?
|
||||||
!(procedure.archived? && draft?)
|
!(procedure.archivee? && draft?)
|
||||||
end
|
end
|
||||||
|
|
||||||
def text_summary
|
def text_summary
|
||||||
|
|
|
@ -108,7 +108,7 @@ class Gestionnaire < ActiveRecord::Base
|
||||||
start_date = DateTime.now.beginning_of_week
|
start_date = DateTime.now.beginning_of_week
|
||||||
|
|
||||||
active_procedure_overviews = procedures
|
active_procedure_overviews = procedures
|
||||||
.published
|
.publiees
|
||||||
.map { |procedure| procedure.procedure_overview(start_date) }
|
.map { |procedure| procedure.procedure_overview(start_date) }
|
||||||
.select(&:had_some_activities?)
|
.select(&:had_some_activities?)
|
||||||
|
|
||||||
|
|
|
@ -32,11 +32,11 @@ class Procedure < ActiveRecord::Base
|
||||||
mount_uploader :logo, ProcedureLogoUploader
|
mount_uploader :logo, ProcedureLogoUploader
|
||||||
|
|
||||||
default_scope { where(hidden_at: nil) }
|
default_scope { where(hidden_at: nil) }
|
||||||
scope :published, -> { where.not(published_at: nil) }
|
scope :brouillons, -> { where(published_at: nil).where(archived_at: nil) }
|
||||||
scope :not_published, -> { where(published_at: nil) }
|
scope :publiees, -> { where.not(published_at: nil).where(archived_at: nil) }
|
||||||
scope :archived, -> { where.not(archived_at: nil) }
|
scope :archivees, -> { where.not(archived_at: nil) }
|
||||||
scope :not_archived, -> { where(archived_at: nil) }
|
scope :publiee_ou_archivee, -> { where.not(published_at: nil) }
|
||||||
scope :by_libelle, -> { order(libelle: :asc) }
|
scope :by_libelle, -> { order(libelle: :asc) }
|
||||||
|
|
||||||
validates :libelle, presence: true, allow_blank: false, allow_nil: false
|
validates :libelle, presence: true, allow_blank: false, allow_nil: false
|
||||||
validates :description, presence: true, allow_blank: false, allow_nil: false
|
validates :description, presence: true, allow_blank: false, allow_nil: false
|
||||||
|
@ -64,7 +64,7 @@ class Procedure < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.active id
|
def self.active id
|
||||||
not_archived.published.find(id)
|
publiees.find(id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def switch_types_de_champ index_of_first_element
|
def switch_types_de_champ index_of_first_element
|
||||||
|
@ -94,7 +94,7 @@ class Procedure < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def locked?
|
def locked?
|
||||||
published?
|
publiee_ou_archivee?
|
||||||
end
|
end
|
||||||
|
|
||||||
def clone
|
def clone
|
||||||
|
@ -120,23 +120,29 @@ class Procedure < ActiveRecord::Base
|
||||||
return procedure if procedure.save
|
return procedure if procedure.save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def brouillon?
|
||||||
|
published_at.nil?
|
||||||
|
end
|
||||||
|
|
||||||
def publish!(path)
|
def publish!(path)
|
||||||
self.update_attributes!({ published_at: Time.now, archived_at: nil })
|
self.update_attributes!({ published_at: Time.now, archived_at: nil })
|
||||||
ProcedurePath.create!(path: path, procedure: self, administrateur: self.administrateur)
|
ProcedurePath.create!(path: path, procedure: self, administrateur: self.administrateur)
|
||||||
end
|
end
|
||||||
|
|
||||||
# FIXME: remove once the published colummn has been deleted
|
def publiee?
|
||||||
def published?
|
published_at.present? && archived_at.nil?
|
||||||
published_at.present?
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def archive
|
def archive
|
||||||
self.update_attributes!(archived_at: Time.now)
|
self.update_attributes!(archived_at: Time.now)
|
||||||
end
|
end
|
||||||
|
|
||||||
# FIXME: remove once the archived colummn has been deleted
|
def archivee?
|
||||||
def archived?
|
published_at.present? && archived_at.present?
|
||||||
archived_at.present?
|
end
|
||||||
|
|
||||||
|
def publiee_ou_archivee?
|
||||||
|
publiee? || archivee?
|
||||||
end
|
end
|
||||||
|
|
||||||
def total_dossier
|
def total_dossier
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
= procedure.created_at_fr
|
= procedure.created_at_fr
|
||||||
%td
|
%td
|
||||||
= link_to('Cloner', admin_procedure_clone_path(procedure.id), 'data-method' => :put, class: 'btn-sm btn-primary clone-btn')
|
= 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.publiee_ou_archivee?
|
||||||
= link_to('X', url_for(controller: 'admin/procedures', action: :destroy, id: procedure.id), 'data-method' => :delete, class: 'btn-sm btn-danger')
|
= link_to('X', url_for(controller: 'admin/procedures', action: :destroy, id: procedure.id), 'data-method' => :delete, class: 'btn-sm btn-danger')
|
||||||
|
|
||||||
= smart_listing.paginate
|
= smart_listing.paginate
|
||||||
|
|
|
@ -6,14 +6,14 @@
|
||||||
%button.close{ "aria-label" => "Close", "data-dismiss" => "modal", :type => "button" }
|
%button.close{ "aria-label" => "Close", "data-dismiss" => "modal", :type => "button" }
|
||||||
%span{ "aria-hidden" => "true" } ×
|
%span{ "aria-hidden" => "true" } ×
|
||||||
%h4#myModalLabel.modal-title
|
%h4#myModalLabel.modal-title
|
||||||
= @procedure.archived? ? 'Réactiver' : 'Publier'
|
= @procedure.archivee? ? 'Réactiver' : 'Publier'
|
||||||
la procédure
|
la procédure
|
||||||
%span#publish-modal-title
|
%span#publish-modal-title
|
||||||
.modal-body
|
.modal-body
|
||||||
Vous vous apprêtez à
|
Vous vous apprêtez à
|
||||||
= @procedure.archived? ? 'republier' : 'publier'
|
= @procedure.archivee? ? 'republier' : 'publier'
|
||||||
votre procédure au public.
|
votre procédure au public.
|
||||||
- unless @procedure.archived?
|
- unless @procedure.archivee?
|
||||||
%b
|
%b
|
||||||
Elle ne pourra plus être modifiée à l'issue de cette publication.
|
Elle ne pourra plus être modifiée à l'issue de cette publication.
|
||||||
%br
|
%br
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
#path_is_invalid.text-danger.center.message
|
#path_is_invalid.text-danger.center.message
|
||||||
= t('activerecord.errors.models.procedure_path.attributes.path.format')
|
= t('activerecord.errors.models.procedure_path.attributes.path.format')
|
||||||
.modal-footer
|
.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',
|
id: 'publish',
|
||||||
disabled: :disabled
|
disabled: :disabled
|
||||||
= button_tag 'Annuler', class: %w(btn btn btn-default), id: 'cancel', data: { dismiss: 'modal' }
|
= button_tag 'Annuler', class: %w(btn btn btn-default), id: 'cancel', data: { dismiss: 'modal' }
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
.row.white-back
|
.row.white-back
|
||||||
#procedure_show
|
#procedure_show
|
||||||
- unless @facade.procedure.published?
|
- if @facade.procedure.brouillon?
|
||||||
- if @facade.procedure.gestionnaires.size == 0
|
- if @facade.procedure.gestionnaires.size == 0
|
||||||
%a.action_button.btn.btn-success#publish-procedure{ style: 'float: right; margin-top: 10px;', disabled: 'disabled', 'data-toggle' => :tooltip, title: 'Vous ne pouvez pas publier une procédure sans qu\'aucun accompagnateur ne soit affecté à celle-ci.' }
|
%a.action_button.btn.btn-success#publish-procedure{ style: 'float: right; margin-top: 10px;', disabled: 'disabled', 'data-toggle' => :tooltip, title: 'Vous ne pouvez pas publier une procédure sans qu\'aucun accompagnateur ne soit affecté à celle-ci.' }
|
||||||
%i.fa.fa-eraser
|
%i.fa.fa-eraser
|
||||||
|
@ -18,15 +18,15 @@
|
||||||
|
|
||||||
= render partial: '/admin/procedures/modal_transfer'
|
= 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;' }
|
%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
|
%i.fa.fa-eraser
|
||||||
Réactiver
|
Réactiver
|
||||||
|
|
||||||
= render partial: '/admin/procedures/modal_publish'
|
= render partial: '/admin/procedures/modal_publish'
|
||||||
|
|
||||||
- elsif @facade.procedure.published?
|
- elsif @facade.procedure.publiee?
|
||||||
= 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 }
|
%button#archive.btn.btn-small.btn-default.text-info{ type: :button }
|
||||||
%i.fa.fa-eraser
|
%i.fa.fa-eraser
|
||||||
Archiver
|
Archiver
|
||||||
|
@ -46,7 +46,7 @@
|
||||||
%div
|
%div
|
||||||
%h3 Lien procédure
|
%h3 Lien procédure
|
||||||
%div{ style: 'margin-left: 3%;' }
|
%div{ style: 'margin-left: 3%;' }
|
||||||
- if @facade.procedure.published?
|
- if @facade.procedure.publiee_ou_archivee?
|
||||||
= link_to @facade.procedure.lien, @facade.procedure.lien, target: '_blank'
|
= link_to @facade.procedure.lien, @facade.procedure.lien, target: '_blank'
|
||||||
- else
|
- else
|
||||||
%b
|
%b
|
||||||
|
@ -130,7 +130,7 @@
|
||||||
- else
|
- else
|
||||||
= pie_chart @facade.dossiers_for_pie_highchart
|
= pie_chart @facade.dossiers_for_pie_highchart
|
||||||
|
|
||||||
- if @facade.procedure.published? || @facade.procedure.archived?
|
- if @facade.procedure.publiee_ou_archivee?
|
||||||
%h3 Supprimer la procédure
|
%h3 Supprimer la procédure
|
||||||
.alert.alert-danger
|
.alert.alert-danger
|
||||||
%p
|
%p
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
= admin.last_sign_in_at.localtime.strftime('%d/%m/%Y')
|
= admin.last_sign_in_at.localtime.strftime('%d/%m/%Y')
|
||||||
)
|
)
|
||||||
%td
|
%td
|
||||||
= admin.procedures.published.count
|
= admin.procedures.publiees.count
|
||||||
%td
|
%td
|
||||||
- total_dossier = 0
|
- total_dossier = 0
|
||||||
- admin.procedures.each do |procedure| total_dossier += procedure.dossiers.state_not_brouillon.count end
|
- admin.procedures.each do |procedure| total_dossier += procedure.dossiers.state_not_brouillon.count end
|
||||||
|
|
|
@ -13,19 +13,19 @@
|
||||||
.procedure-list-element{ class: @draft_class }
|
.procedure-list-element{ class: @draft_class }
|
||||||
Brouillons
|
Brouillons
|
||||||
.badge.progress-bar-default
|
.badge.progress-bar-default
|
||||||
= current_administrateur.procedures.not_published.not_archived.count
|
= current_administrateur.procedures.brouillons.count
|
||||||
|
|
||||||
%a#active-procedures{ :href => "#{url_for :admin_procedures}" }
|
%a#active-procedures{ :href => "#{url_for :admin_procedures}" }
|
||||||
.procedure-list-element{ class: @active_class }
|
.procedure-list-element{ class: @active_class }
|
||||||
Actives
|
Actives
|
||||||
.badge.progress-bar-success
|
.badge.progress-bar-success
|
||||||
= current_administrateur.procedures.published.not_archived.count
|
= current_administrateur.procedures.publiees.count
|
||||||
|
|
||||||
%a#archived-procedures{ :href => "#{url_for :admin_procedures_archived}" }
|
%a#archived-procedures{ :href => "#{url_for :admin_procedures_archived}" }
|
||||||
.procedure-list-element{ class: @archived_class }
|
.procedure-list-element{ class: @archived_class }
|
||||||
Archivées
|
Archivées
|
||||||
.badge.progress-bar-purple
|
.badge.progress-bar-purple
|
||||||
= current_administrateur.procedures.archived.count
|
= current_administrateur.procedures.archivees.count
|
||||||
|
|
||||||
.split-hr-left
|
.split-hr-left
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@
|
||||||
%ul.numbers
|
%ul.numbers
|
||||||
%li.number
|
%li.number
|
||||||
.number-value
|
.number-value
|
||||||
= number_with_delimiter(Procedure.published.count, :locale => :fr)
|
= number_with_delimiter(Procedure.publiee_ou_archivee.count, :locale => :fr)
|
||||||
.number-label<
|
.number-label<
|
||||||
procédures
|
procédures
|
||||||
%br<>
|
%br<>
|
||||||
|
|
|
@ -42,5 +42,5 @@
|
||||||
- elsif !@dossier.draft?
|
- elsif !@dossier.draft?
|
||||||
= render partial: '/layouts/modifications_terminees'
|
= render partial: '/layouts/modifications_terminees'
|
||||||
- else
|
- 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 '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.archived?, data: { disable_with: 'Enregistrer un brouillon', 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 }
|
||||||
|
|
|
@ -2,7 +2,7 @@ class AutoArchiveProcedureWorker
|
||||||
include Sidekiq::Worker
|
include Sidekiq::Worker
|
||||||
|
|
||||||
def perform(*args)
|
def perform(*args)
|
||||||
Procedure.not_archived.where("auto_archive_on <= ?", Date.today).each do |procedure|
|
Procedure.publiees.where("auto_archive_on <= ?", Date.today).each do |procedure|
|
||||||
procedure.dossiers.state_en_construction.each do |dossier|
|
procedure.dossiers.state_en_construction.each do |dossier|
|
||||||
dossier.received!
|
dossier.received!
|
||||||
end
|
end
|
||||||
|
|
|
@ -297,7 +297,7 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
let(:procedure_path) { 'new_path' }
|
let(:procedure_path) { 'new_path' }
|
||||||
|
|
||||||
it 'publish the given procedure' do
|
it 'publish the given procedure' do
|
||||||
expect(procedure.published?).to be_truthy
|
expect(procedure.publiee?).to be_truthy
|
||||||
expect(procedure.path).to eq(procedure_path)
|
expect(procedure.path).to eq(procedure_path)
|
||||||
expect(response.status).to eq 200
|
expect(response.status).to eq 200
|
||||||
expect(flash[:notice]).to have_content 'Procédure publiée'
|
expect(flash[:notice]).to have_content 'Procédure publiée'
|
||||||
|
@ -308,15 +308,14 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
let(:procedure_path) { procedure2.path }
|
let(:procedure_path) { procedure2.path }
|
||||||
|
|
||||||
it 'publish the given procedure' do
|
it 'publish the given procedure' do
|
||||||
expect(procedure.published?).to be_truthy
|
expect(procedure.publiee?).to be_truthy
|
||||||
expect(procedure.path).to eq(procedure_path)
|
expect(procedure.path).to eq(procedure_path)
|
||||||
expect(response.status).to eq 200
|
expect(response.status).to eq 200
|
||||||
expect(flash[:notice]).to have_content 'Procédure publiée'
|
expect(flash[:notice]).to have_content 'Procédure publiée'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'archive previous procedure' do
|
it 'archive previous procedure' do
|
||||||
expect(procedure2.published?).to be_truthy
|
expect(procedure2.archivee?).to be_truthy
|
||||||
expect(procedure2.archived?).to be_truthy
|
|
||||||
expect(procedure2.path).to be_nil
|
expect(procedure2.path).to be_nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -325,14 +324,14 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
let(:procedure_path) { procedure3.path }
|
let(:procedure_path) { procedure3.path }
|
||||||
|
|
||||||
it 'does not publish the given procedure' do
|
it 'does not publish the given procedure' do
|
||||||
expect(procedure.published?).to be_falsey
|
expect(procedure.publiee?).to be_falsey
|
||||||
expect(procedure.path).to be_nil
|
expect(procedure.path).to be_nil
|
||||||
expect(response.status).to eq 200
|
expect(response.status).to eq 200
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'previous procedure remains published' do
|
it 'previous procedure remains published' do
|
||||||
expect(procedure2.published?).to be_truthy
|
expect(procedure2.publiee?).to be_truthy
|
||||||
expect(procedure2.archived?).to be_falsey
|
expect(procedure2.archivee?).to be_falsey
|
||||||
expect(procedure2.path).to match(/fake_path/)
|
expect(procedure2.path).to match(/fake_path/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -341,7 +340,7 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
let(:procedure_path) { 'Invalid Procedure Path' }
|
let(:procedure_path) { 'Invalid Procedure Path' }
|
||||||
|
|
||||||
it 'does not publish the given procedure' do
|
it 'does not publish the given procedure' do
|
||||||
expect(procedure.published?).to be_falsey
|
expect(procedure.publiee?).to be_falsey
|
||||||
expect(procedure.path).to be_nil
|
expect(procedure.path).to be_nil
|
||||||
expect(response).to redirect_to :admin_procedures
|
expect(response).to redirect_to :admin_procedures
|
||||||
expect(flash[:alert]).to have_content 'Lien de la procédure invalide'
|
expect(flash[:alert]).to have_content 'Lien de la procédure invalide'
|
||||||
|
@ -368,7 +367,7 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'PUT #archive' do
|
describe 'PUT #archive' do
|
||||||
let(:procedure) { create(:procedure, administrateur: admin) }
|
let(:procedure) { create(:procedure, :published, administrateur: admin) }
|
||||||
|
|
||||||
context 'when admin is the owner of the procedure' do
|
context 'when admin is the owner of the procedure' do
|
||||||
before do
|
before do
|
||||||
|
@ -377,7 +376,7 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when owner want archive procedure' do
|
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(response).to redirect_to :admin_procedures }
|
||||||
it { expect(flash[:notice]).to have_content 'Procédure archivée' }
|
it { expect(flash[:notice]).to have_content 'Procédure archivée' }
|
||||||
end
|
end
|
||||||
|
@ -388,7 +387,7 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
procedure.reload
|
procedure.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(procedure.archived?).to be_falsey }
|
it { expect(procedure.archivee?).to be_falsey }
|
||||||
it { expect(response.status).to eq 200 }
|
it { expect(response.status).to eq 200 }
|
||||||
it { expect(flash[:notice]).to have_content 'Procédure publiée' }
|
it { expect(flash[:notice]).to have_content 'Procédure publiée' }
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,7 +8,7 @@ describe Users::DescriptionController, type: :controller, vcr: {cassette_name: '
|
||||||
let(:archived_at) { nil }
|
let(:archived_at) { nil }
|
||||||
let(:state) { 'initiated' }
|
let(:state) { 'initiated' }
|
||||||
|
|
||||||
let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, :with_datetime, cerfa_flag: true, archived_at: archived_at) }
|
let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, :with_datetime, cerfa_flag: true, published_at: Time.now, archived_at: archived_at) }
|
||||||
let(:dossier) { create(:dossier, procedure: procedure, user: owner_user, state: state) }
|
let(:dossier) { create(:dossier, procedure: procedure, user: owner_user, state: state) }
|
||||||
|
|
||||||
let(:dossier_id) { dossier.id }
|
let(:dossier_id) { dossier.id }
|
||||||
|
|
|
@ -243,6 +243,48 @@ describe Procedure do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#brouillon?" 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.brouillon?).to be_truthy }
|
||||||
|
it { expect(procedure_publiee.brouillon?).to be_falsey }
|
||||||
|
it { expect(procedure_archivee.brouillon?).to be_falsey }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#publiee?" 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.publiee?).to be_falsey }
|
||||||
|
it { expect(procedure_publiee.publiee?).to be_truthy }
|
||||||
|
it { expect(procedure_archivee.publiee?).to be_falsey }
|
||||||
|
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) }
|
||||||
|
let(:procedure_batarde) { Procedure.new(published_at: nil, 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 }
|
||||||
|
it { expect(procedure_batarde.archivee?).to be_falsey }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#publiee_ou_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.publiee_ou_archivee?).to be_falsey }
|
||||||
|
it { expect(procedure_publiee.publiee_ou_archivee?).to be_truthy }
|
||||||
|
it { expect(procedure_archivee.publiee_ou_archivee?).to be_truthy }
|
||||||
|
end
|
||||||
|
|
||||||
describe 'archive' do
|
describe 'archive' do
|
||||||
let(:procedure) { create(:procedure, :published) }
|
let(:procedure) { create(:procedure, :published) }
|
||||||
let(:procedure_path) { ProcedurePath.find(procedure.procedure_path.id) }
|
let(:procedure_path) { ProcedurePath.find(procedure.procedure_path.id) }
|
||||||
|
@ -253,8 +295,7 @@ describe Procedure do
|
||||||
procedure.reload
|
procedure.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(procedure.published?).to be_truthy }
|
it { expect(procedure.archivee?).to be_truthy }
|
||||||
it { expect(procedure.archived?).to be_truthy }
|
|
||||||
it { expect(procedure.archived_at).to eq(now) }
|
it { expect(procedure.archived_at).to eq(now) }
|
||||||
|
|
||||||
after do
|
after do
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe AutoArchiveProcedureWorker, type: :worker do
|
RSpec.describe AutoArchiveProcedureWorker, type: :worker do
|
||||||
let!(:procedure) { create(:procedure, archived_at: nil, auto_archive_on: nil )}
|
let!(:procedure) { create(:procedure, published_at: Time.now, archived_at: nil, auto_archive_on: nil )}
|
||||||
let!(:procedure_hier) { create(:procedure, archived_at: nil, auto_archive_on: 1.day.ago )}
|
let!(:procedure_hier) { create(:procedure, published_at: Time.now, archived_at: nil, auto_archive_on: 1.day.ago )}
|
||||||
let!(:procedure_aujourdhui) { create(:procedure, archived_at: nil, auto_archive_on: Date.today )}
|
let!(:procedure_aujourdhui) { create(:procedure, published_at: Time.now, archived_at: nil, auto_archive_on: Date.today )}
|
||||||
let!(:procedure_demain) { create(:procedure, archived_at: nil, auto_archive_on: 1.day.from_now )}
|
let!(:procedure_demain) { create(:procedure, published_at: Time.now, archived_at: nil, auto_archive_on: 1.day.from_now )}
|
||||||
|
|
||||||
subject { AutoArchiveProcedureWorker.new.perform }
|
subject { AutoArchiveProcedureWorker.new.perform }
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ RSpec.describe AutoArchiveProcedureWorker, type: :worker do
|
||||||
procedure.reload
|
procedure.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(procedure.archived?).to eq false }
|
it { expect(procedure.archivee?).to eq false }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when procedures have auto_archive_on set on yesterday or today" do
|
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(dossier8.state).to eq 'without_continuation' }
|
||||||
it { expect(dossier9.state).to eq 'received' }
|
it { expect(dossier9.state).to eq 'received' }
|
||||||
|
|
||||||
it { expect(procedure_hier.archived?).to eq true }
|
it { expect(procedure_hier.archivee?).to eq true }
|
||||||
it { expect(procedure_aujourdhui.archived?).to eq true }
|
it { expect(procedure_aujourdhui.archivee?).to eq true }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when procedures have auto_archive_on set on future" do
|
context "when procedures have auto_archive_on set on future" do
|
||||||
|
@ -58,6 +58,6 @@ RSpec.describe AutoArchiveProcedureWorker, type: :worker do
|
||||||
subject
|
subject
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(procedure_demain.archived?).to eq false }
|
it { expect(procedure_demain.archivee?).to eq false }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue