First step to remove :validated and :submitted states

This commit is contained in:
Mathieu Magnin 2017-02-21 18:05:48 +01:00
parent b2198663d1
commit cae5b37e38
10 changed files with 28 additions and 161 deletions

View file

@ -85,21 +85,10 @@ class Backoffice::DossiersController < Backoffice::DossiersListController
default_sort: dossiers_list_facade.service.default_sort default_sort: dossiers_list_facade.service.default_sort
end end
def valid
create_dossier_facade params[:dossier_id]
@facade.dossier.next_step! 'gestionnaire', 'valid'
flash.notice = 'Dossier confirmé avec succès.'
NotificationMailer.dossier_validated(@facade.dossier).deliver_now!
redirect_to backoffice_dossier_path(id: @facade.dossier.id)
end
def receive def receive
create_dossier_facade params[:dossier_id] create_dossier_facade params[:dossier_id]
@facade.dossier.next_step! 'gestionnaire', 'receive' @facade.dossier.received!
flash.notice = 'Dossier considéré comme reçu.' flash.notice = 'Dossier considéré comme reçu.'
NotificationMailer.dossier_received(@facade.dossier).deliver_now! NotificationMailer.dossier_received(@facade.dossier).deliver_now!

View file

@ -5,8 +5,8 @@ class Dossier < ActiveRecord::Base
initiated: 'initiated', initiated: 'initiated',
replied: 'replied', #action utilisateur demandé replied: 'replied', #action utilisateur demandé
updated: 'updated', #etude par l'administration en cours updated: 'updated', #etude par l'administration en cours
validated: 'validated', # validated: 'validated',
submitted: 'submitted', # submitted: 'submitted',
received: 'received', received: 'received',
closed: 'closed', closed: 'closed',
refused: 'refused', refused: 'refused',
@ -122,10 +122,6 @@ class Dossier < ActiveRecord::Base
if draft? if draft?
initiated! initiated!
end end
when 'submit'
if validated?
submitted!
end
when 'update' when 'update'
if replied? if replied?
updated! updated!
@ -147,18 +143,6 @@ class Dossier < ActiveRecord::Base
if initiated? if initiated?
updated! updated!
end end
when 'valid'
if updated?
validated!
elsif replied?
validated!
elsif initiated?
validated!
end
when 'receive'
if submitted?
received!
end
when 'close' when 'close'
if received? if received?
closed! closed!
@ -332,7 +316,7 @@ class Dossier < ActiveRecord::Base
end end
def read_only? def read_only?
validated? || received? || submitted? || closed? || refused? || without_continuation? received? || closed? || refused? || without_continuation?
end end
def owner? email def owner? email

View file

@ -22,7 +22,6 @@
- MailTemplate::TAGS.each do |balise| - MailTemplate::TAGS.each do |balise|
%tr %tr
%td.center %td.center
%b.text-success = "--#{balise.first}--"
= "--#{balise.first}--"
%td %td
=balise.second[:description] =balise.second[:description]

View file

@ -4,14 +4,9 @@
%div#action-block %div#action-block
- if gestionnaire_signed_in? - if gestionnaire_signed_in?
- if !@facade.dossier.read_only? - if !@facade.dossier.read_only? || @facade.dossier.initiated?
= form_tag(url_for({controller: 'backoffice/dossiers', action: :valid, dossier_id: @facade.dossier.id}), class: 'form-inline', method: 'POST') do = link_to 'Accuser réception', backoffice_dossier_receive_path(@facade.dossier), method: :post, class: 'btn btn-danger btn-block'
%button.action{'data-toggle' => :tooltip, title: 'En cliquant ici, vous figez le dossier et autorisez le dépôt du dossier pour instruction.'}
= 'Déclarer complet'.upcase
- elsif @facade.dossier.submitted?
= form_tag(url_for({controller: 'backoffice/dossiers', action: :receive, dossier_id: @facade.dossier.id}), class: 'form-inline', method: 'POST') do
%button.action
= 'Accuser réception'.upcase
- elsif @facade.dossier.received? - elsif @facade.dossier.received?
= form_tag(url_for({controller: 'backoffice/dossiers', action: :close, dossier_id: @facade.dossier.id}), class: 'form-inline action_button', method: 'POST', style: 'display:inline', 'data-toggle' => :tooltip, title: 'Accepter') do = form_tag(url_for({controller: 'backoffice/dossiers', action: :close, dossier_id: @facade.dossier.id}), class: 'form-inline action_button', method: 'POST', style: 'display:inline', 'data-toggle' => :tooltip, title: 'Accepter') do
%button.action.close-dossier %button.action.close-dossier

View file

@ -23,11 +23,11 @@
.badge.progress-bar-danger .badge.progress-bar-danger
= @dossiers_list_facade.en_construction_total = @dossiers_list_facade.en_construction_total
%a{:href => "#{url_for users_dossiers_path(liste: 'valides')}", 'data-toggle' => :tooltip, title: 'Les dossiers relus par votre accompagnateur pouvant être déposés pour examen.'} -# %a{:href => "#{url_for users_dossiers_path(liste: 'valides')}", 'data-toggle' => :tooltip, title: 'Les dossiers relus par votre accompagnateur pouvant être déposés pour examen.'}
%div.procedure_list_element{ class: @dossiers_list_facade.valides_class, id: 'valides' } -# %div.procedure_list_element{ class: @dossiers_list_facade.valides_class, id: 'valides' }
="À déposer" -# ="À déposer"
.badge.progress-bar-purple -# .badge.progress-bar-purple
= @dossiers_list_facade.valides_total -# = @dossiers_list_facade.valides_total
%a{:href => "#{url_for users_dossiers_path(liste: 'en_instruction')}", 'data-toggle' => :tooltip, title: 'Les dossiers en cours d\'examen par l\'administration compétante.'} %a{:href => "#{url_for users_dossiers_path(liste: 'en_instruction')}", 'data-toggle' => :tooltip, title: 'Les dossiers en cours d\'examen par l\'administration compétante.'}
%div.procedure_list_element{ class: @dossiers_list_facade.en_instruction_class, id: 'en_instruction' } %div.procedure_list_element{ class: @dossiers_list_facade.en_instruction_class, id: 'en_instruction' }

View file

@ -0,0 +1,5 @@
class RemoveUselessDossierStates < ActiveRecord::Migration[5.0]
def change
Dossier.where(state: [:validated, :submitted]).update_all(state: :initiated)
end
end

View file

@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170215142944) do ActiveRecord::Schema.define(version: 20170221143909) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"

View file

@ -39,7 +39,7 @@ describe MailTemplate do
end end
end end
xdescribe '.replace_tags' do describe '.replace_tags' do
let(:dossier) { create :dossier } let(:dossier) { create :dossier }
let(:procedure) { dossier.procedure } let(:procedure) { dossier.procedure }
let(:mail_received) { procedure.mail_received } let(:mail_received) { procedure.mail_received }

View file

@ -23,6 +23,11 @@ describe 'layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.htm
end end
context 'button dossier state changements' do context 'button dossier state changements' do
shared_examples 'button Accuser réception is present' do
it { expect(rendered).to have_link('Accuser réception') }
end
context 'when dossier have state initiated' do context 'when dossier have state initiated' do
let(:state) { 'initiated' } let(:state) { 'initiated' }
@ -32,10 +37,7 @@ describe 'layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.htm
it { expect(rendered).to have_content('Nouveau') } it { expect(rendered).to have_content('Nouveau') }
it 'button Déclarer complet is present' do include_examples 'button Accuser réception is present'
expect(rendered).to have_css('.action')
expect(rendered).to have_content('DÉCLARER COMPLET')
end
end end
context 'when dossier have state replied' do context 'when dossier have state replied' do
@ -47,10 +49,7 @@ describe 'layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.htm
it { expect(rendered).to have_content('En construction') } it { expect(rendered).to have_content('En construction') }
it 'button Déclarer complet is present' do include_examples 'button Accuser réception is present'
expect(rendered).to have_css('.action')
expect(rendered).to have_content('DÉCLARER COMPLET')
end
end end
context 'when dossier have state update' do context 'when dossier have state update' do
@ -62,44 +61,7 @@ describe 'layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.htm
it { expect(rendered).to have_content('En construction') } it { expect(rendered).to have_content('En construction') }
it 'button Déclarer complet is present' do include_examples 'button Accuser réception is present'
expect(rendered).to have_css('.action')
expect(rendered).to have_content('DÉCLARER COMPLET')
end
end
context 'when dossier have state validated' do
let(:state) { 'validated' }
before do
render
end
it { expect(rendered).to have_content('Figé') }
it 'button Déclarer complet is not present' do
expect(rendered).not_to have_css('.action')
expect(rendered).not_to have_content('Déclarer complet')
end
end
context 'when dossier have state submitted' do
let(:state) { 'submitted' }
before do
render
end
it { expect(rendered).to have_content('Déposé / À réceptionner') }
it 'button Accuser réception is present' do
expect(rendered).to have_css('.action')
expect(rendered).to have_content('ACCUSER RÉCEPTION')
end
it 'button Déclarer complet is not present' do
expect(rendered).not_to have_content('Accepter le dossier')
end
end end
context 'when dossier have state received' do context 'when dossier have state received' do

View file

@ -1,67 +0,0 @@
require 'spec_helper'
describe 'layouts/left_panels/_left_panel_users_dossierscontroller_index.html.haml', type: :view do
shared_examples 'active_tab' do
let(:user) { create :user }
before do
sign_in user
create :dossier, user: user
assign :dossiers_list_facade, (DossiersListFacades.new user, param_list)
render
end
subject { rendered }
let(:active_class) { 'div.procedure_list_element.active '+active_klass }
let(:param_list) { liste }
it { is_expected.to have_selector(active_class) }
end
describe 'list brouillon' do
let(:active_klass) { '.progress-bar-default' }
let(:liste) { 'brouillon' }
it_behaves_like 'active_tab'
end
describe 'list en construction' do
let(:active_klass) { '.progress-bar-danger' }
let(:liste) { 'a_traiter' }
it_behaves_like 'active_tab'
end
describe 'list a depose' do
let(:active_klass) { '.progress-bar-purple' }
let(:liste) { 'valides' }
it_behaves_like 'active_tab'
end
describe 'list en examen' do
let(:active_klass) { '.progress-bar-default' }
let(:liste) { 'en_instruction' }
it_behaves_like 'active_tab'
end
describe 'list cloture' do
let(:active_klass) { '.progress-bar-success' }
let(:liste) { 'termine' }
it_behaves_like 'active_tab'
end
describe 'list invite' do
let(:active_klass) { '.progress-bar-warning' }
let(:liste) { 'invite' }
it_behaves_like 'active_tab'
end
end