Merge branch 'develop' of ssh://37.187.249.111:2200/opt/git/tps into develop
This commit is contained in:
commit
7f91778027
4 changed files with 47 additions and 4 deletions
|
@ -1,10 +1,17 @@
|
||||||
class CommentairesController < ApplicationController
|
class CommentairesController < ApplicationController
|
||||||
def create
|
def create
|
||||||
@commentaire = Commentaire.new
|
@commentaire = Commentaire.new
|
||||||
@commentaire.email = params['email_commentaire']
|
|
||||||
@commentaire.body = params['texte_commentaire']
|
|
||||||
@commentaire.dossier = Dossier.find(params['dossier_id'])
|
@commentaire.dossier = Dossier.find(params['dossier_id'])
|
||||||
|
|
||||||
|
if is_gestionnaire?
|
||||||
|
@commentaire.email = current_gestionnaire.email
|
||||||
|
@commentaire.dossier.next_step! 'gestionnaire', 'comment'
|
||||||
|
else #is_user
|
||||||
|
@commentaire.email = current_user.email
|
||||||
|
@commentaire.dossier.next_step! 'user', 'comment'
|
||||||
|
end
|
||||||
|
|
||||||
|
@commentaire.body = params['texte_commentaire']
|
||||||
@commentaire.save
|
@commentaire.save
|
||||||
|
|
||||||
if is_gestionnaire?
|
if is_gestionnaire?
|
||||||
|
|
|
@ -76,7 +76,7 @@ set :rbenv_path, "/usr/local/rbenv/bin/rbenv"
|
||||||
# Optional settings:
|
# Optional settings:
|
||||||
# set :user, 'foobar' # Username in the server to SSH to.
|
# set :user, 'foobar' # Username in the server to SSH to.
|
||||||
# set :port, '30000' # SSH port number.
|
# set :port, '30000' # SSH port number.
|
||||||
# set :forward_agent, true # SSH forward_agent.
|
set :forward_agent, true # SSH forward_agent.
|
||||||
|
|
||||||
# This task is the environment that is loaded for most commands, such as
|
# This task is the environment that is loaded for most commands, such as
|
||||||
# `mina deploy` or `mina rake`.
|
# `mina deploy` or `mina rake`.
|
||||||
|
|
|
@ -16,5 +16,23 @@ describe Backoffice::CommentairesController, type: :controller do
|
||||||
expect(response).to redirect_to("/backoffice/dossiers/#{dossier_id}")
|
expect(response).to redirect_to("/backoffice/dossiers/#{dossier_id}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'change dossier state after post a comment' do
|
||||||
|
context 'gestionnaire is connected' do
|
||||||
|
context 'when dossier is at state updated' do
|
||||||
|
before do
|
||||||
|
sign_in create(:gestionnaire)
|
||||||
|
dossier.updated!
|
||||||
|
|
||||||
|
post :create, dossier_id: dossier_id, texte_commentaire: texte_commentaire
|
||||||
|
dossier.reload
|
||||||
|
end
|
||||||
|
|
||||||
|
subject { dossier.state }
|
||||||
|
|
||||||
|
it {is_expected.to eq('reply')}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,9 +10,27 @@ describe Users::CommentairesController, type: :controller do
|
||||||
context 'création correct d\'un commentaire' do
|
context 'création correct d\'un commentaire' do
|
||||||
it 'depuis la page récapitulatif' do
|
it 'depuis la page récapitulatif' do
|
||||||
sign_in dossier.user
|
sign_in dossier.user
|
||||||
post :create, dossier_id: dossier_id, email_commentaire: email_commentaire, texte_commentaire: texte_commentaire
|
post :create, dossier_id: dossier_id, texte_commentaire: texte_commentaire
|
||||||
expect(response).to redirect_to("/users/dossiers/#{dossier_id}/recapitulatif")
|
expect(response).to redirect_to("/users/dossiers/#{dossier_id}/recapitulatif")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'change dossier state after post a comment' do
|
||||||
|
context 'when user is connected' do
|
||||||
|
context 'when dossier is at state reply' do
|
||||||
|
before do
|
||||||
|
sign_in dossier.user
|
||||||
|
dossier.reply!
|
||||||
|
|
||||||
|
post :create, dossier_id: dossier_id, texte_commentaire: texte_commentaire
|
||||||
|
dossier.reload
|
||||||
|
end
|
||||||
|
|
||||||
|
subject { dossier.state }
|
||||||
|
|
||||||
|
it {is_expected.to eq('updated')}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue