[fix 363] Dossier: remove next_step! action = comment
This commit is contained in:
parent
4adbb09e9c
commit
629cccbf27
3 changed files with 1 additions and 115 deletions
|
@ -19,11 +19,9 @@ class CommentairesController < ApplicationController
|
||||||
if is_gestionnaire?
|
if is_gestionnaire?
|
||||||
@commentaire.email = current_gestionnaire.email
|
@commentaire.email = current_gestionnaire.email
|
||||||
@commentaire.dossier = current_gestionnaire.dossiers.find_by(id: dossier_id) || current_gestionnaire.avis.find_by!(dossier_id: dossier_id).dossier
|
@commentaire.dossier = current_gestionnaire.dossiers.find_by(id: dossier_id) || current_gestionnaire.avis.find_by!(dossier_id: dossier_id).dossier
|
||||||
@commentaire.dossier.next_step! 'gestionnaire', 'comment'
|
|
||||||
else
|
else
|
||||||
@commentaire.email = current_user.email
|
@commentaire.email = current_user.email
|
||||||
@commentaire.dossier = current_user.dossiers.find_by(id: dossier_id) || current_user.invites.find_by!(dossier_id: dossier_id).dossier
|
@commentaire.dossier = current_user.dossiers.find_by(id: dossier_id) || current_user.invites.find_by!(dossier_id: dossier_id).dossier
|
||||||
@commentaire.dossier.next_step! 'user', 'comment' if current_user.email == @commentaire.dossier.user.email
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@commentaire.file = params["file"]
|
@commentaire.file = params["file"]
|
||||||
|
|
|
@ -145,7 +145,7 @@ class Dossier < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def next_step! role, action, motivation = nil
|
def next_step! role, action, motivation = nil
|
||||||
unless %w(initiate follow update comment receive refuse without_continuation close).include?(action)
|
unless %w(initiate follow update receive refuse without_continuation close).include?(action)
|
||||||
fail 'action is not valid'
|
fail 'action is not valid'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -148,12 +148,6 @@ describe Dossier do
|
||||||
it { is_expected.to eq('brouillon') }
|
it { is_expected.to eq('brouillon') }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when he posts a comment' do
|
|
||||||
let(:action) { 'comment' }
|
|
||||||
|
|
||||||
it { is_expected.to eq('brouillon') }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when he initiate a dossier' do
|
context 'when he initiate a dossier' do
|
||||||
let(:action) { 'initiate' }
|
let(:action) { 'initiate' }
|
||||||
|
|
||||||
|
@ -175,23 +169,11 @@ describe Dossier do
|
||||||
|
|
||||||
it { is_expected.to eq('en_construction') }
|
it { is_expected.to eq('en_construction') }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when is post a comment' do
|
|
||||||
let(:action) { 'comment' }
|
|
||||||
|
|
||||||
it { is_expected.to eq('en_construction') }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when gestionnaire is connect' do
|
context 'when gestionnaire is connect' do
|
||||||
let(:role) { 'gestionnaire' }
|
let(:role) { 'gestionnaire' }
|
||||||
|
|
||||||
context 'when is post a comment' do
|
|
||||||
let(:action) { 'comment' }
|
|
||||||
|
|
||||||
it { is_expected.to eq('en_construction') }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when is follow' do
|
context 'when is follow' do
|
||||||
let(:action) { 'follow' }
|
let(:action) { 'follow' }
|
||||||
|
|
||||||
|
@ -205,25 +187,9 @@ describe Dossier do
|
||||||
dossier.en_instruction!
|
dossier.en_instruction!
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when user is connected' do
|
|
||||||
let(:role) { 'user' }
|
|
||||||
|
|
||||||
context 'when he posts a comment' do
|
|
||||||
let(:action) { 'comment' }
|
|
||||||
|
|
||||||
it { is_expected.to eq('en_instruction') }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when gestionnaire is connect' do
|
context 'when gestionnaire is connect' do
|
||||||
let(:role) { 'gestionnaire' }
|
let(:role) { 'gestionnaire' }
|
||||||
|
|
||||||
context 'when he posts a comment' do
|
|
||||||
let(:action) { 'comment' }
|
|
||||||
|
|
||||||
it { is_expected.to eq('en_instruction') }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when he closes the dossier' do
|
context 'when he closes the dossier' do
|
||||||
let(:action) { 'close' }
|
let(:action) { 'close' }
|
||||||
|
|
||||||
|
@ -231,84 +197,6 @@ describe Dossier do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when dossier is at state refuse' do
|
|
||||||
before do
|
|
||||||
dossier.refuse!
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when user is connected' do
|
|
||||||
let(:role) { 'user' }
|
|
||||||
|
|
||||||
context 'when he posts a comment' do
|
|
||||||
let(:action) { 'comment' }
|
|
||||||
|
|
||||||
it { is_expected.to eq('refuse') }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when gestionnaire is connect' do
|
|
||||||
let(:role) { 'gestionnaire' }
|
|
||||||
|
|
||||||
context 'when he posts a comment' do
|
|
||||||
let(:action) { 'comment' }
|
|
||||||
|
|
||||||
it { is_expected.to eq('refuse') }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when dossier is at state sans_suite' do
|
|
||||||
before do
|
|
||||||
dossier.sans_suite!
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when user is connected' do
|
|
||||||
let(:role) { 'user' }
|
|
||||||
|
|
||||||
context 'when he posts a comment' do
|
|
||||||
let(:action) { 'comment' }
|
|
||||||
|
|
||||||
it { is_expected.to eq('sans_suite') }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when gestionnaire is connect' do
|
|
||||||
let(:role) { 'gestionnaire' }
|
|
||||||
|
|
||||||
context 'when he posts a comment' do
|
|
||||||
let(:action) { 'comment' }
|
|
||||||
|
|
||||||
it { is_expected.to eq('sans_suite') }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when dossier is at state accepte' do
|
|
||||||
before do
|
|
||||||
dossier.accepte!
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when user is connect' do
|
|
||||||
let(:role) { 'user' }
|
|
||||||
|
|
||||||
context 'when is post a comment' do
|
|
||||||
let(:action) { 'comment' }
|
|
||||||
|
|
||||||
it { is_expected.to eq('accepte') }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when gestionnaire is connect' do
|
|
||||||
let(:role) { 'gestionnaire' }
|
|
||||||
|
|
||||||
context 'when is post a comment' do
|
|
||||||
let(:action) { 'comment' }
|
|
||||||
|
|
||||||
it { is_expected.to eq('accepte') }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue