Merge branch 'develop' into staging

This commit is contained in:
Xavier J 2015-09-25 11:17:00 +02:00
commit 3dfac3d6f2
7 changed files with 56 additions and 5 deletions

View file

@ -1,10 +1,17 @@
class CommentairesController < ApplicationController
def create
@commentaire = Commentaire.new
@commentaire.email = params['email_commentaire']
@commentaire.body = params['texte_commentaire']
@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
if is_gestionnaire?

View file

@ -1,7 +1,7 @@
class Users::DossiersController < UsersController
before_action :authenticate_user!
def index
@dossiers = current_user.dossiers.decorate
@dossiers = current_user.dossiers.order(updated_at: 'DESC').decorate
end
def show

View file

@ -76,7 +76,7 @@ set :rbenv_path, "/usr/local/rbenv/bin/rbenv"
# Optional settings:
# set :user, 'foobar' # Username in the server to SSH to.
# 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
# `mina deploy` or `mina rake`.

View file

@ -16,5 +16,23 @@ describe Backoffice::CommentairesController, type: :controller do
expect(response).to redirect_to("/backoffice/dossiers/#{dossier_id}")
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

View file

@ -10,9 +10,27 @@ describe Users::CommentairesController, type: :controller do
context 'création correct d\'un commentaire' do
it 'depuis la page récapitulatif' do
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")
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

View file

@ -3,6 +3,7 @@ require 'spec_helper'
describe Users::DossiersController, type: :controller do
let(:user) { create(:user) }
describe '.index' do
let!(:dossier) { create(:dossier, :with_entreprise, :with_procedure, user: user) }
subject { get :index }
context 'when user is not logged in' do
it { is_expected.to redirect_to('/users/sign_in') }

View file

@ -3,9 +3,11 @@ require 'spec_helper'
feature 'user access to the list of his dossier' do
let(:user) { create(:user) }
let!(:last_updated_dossier) { create(:dossier, :with_procedure, user: user)}
let!(:dossier1) { create(:dossier, :with_procedure, user: user, nom_projet: 'mon permier dossier') }
let!(:dossier2) { create(:dossier, :with_user, nom_projet: 'mon deuxième dossier') }
before do
last_updated_dossier.update_attributes(nom_projet: 'salut la compagnie')
visit root_path
page.find_by_id('user_email').set user.email
page.find_by_id('user_password').set user.password
@ -15,6 +17,11 @@ feature 'user access to the list of his dossier' do
expect(page).to have_content(dossier1.nom_projet)
expect(page).not_to have_content(dossier2.nom_projet)
end
scenario 'the list must be order by last updated' do
expect(page.body).to match(/#{last_updated_dossier.nom_projet}.*#{dossier1.nom_projet}/m)
end
context 'when user clicks on a projet in list' do
before do
page.click_on dossier1.nom_projet