2015-08-10 11:05:06 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2015-09-23 19:20:03 +02:00
|
|
|
describe Users::CommentairesController, type: :controller do
|
2015-09-24 10:34:01 +02:00
|
|
|
let(:dossier) { create(:dossier, :with_user) }
|
2015-08-20 16:29:06 +02:00
|
|
|
let(:dossier_id) { dossier.id }
|
|
|
|
let(:email_commentaire) { 'test@test.com' }
|
|
|
|
let(:texte_commentaire) { 'Commentaire de test' }
|
2015-08-10 11:05:06 +02:00
|
|
|
|
|
|
|
describe '#POST create' do
|
|
|
|
context 'création correct d\'un commentaire' do
|
2015-12-15 15:33:21 +01:00
|
|
|
subject do
|
2015-09-24 10:34:01 +02:00
|
|
|
sign_in dossier.user
|
2015-09-25 10:46:09 +02:00
|
|
|
post :create, dossier_id: dossier_id, texte_commentaire: texte_commentaire
|
2015-12-15 15:33:21 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'depuis la page récapitulatif' do
|
|
|
|
subject
|
2015-09-23 19:20:03 +02:00
|
|
|
expect(response).to redirect_to("/users/dossiers/#{dossier_id}/recapitulatif")
|
2015-08-10 11:05:06 +02:00
|
|
|
end
|
2015-12-15 15:33:21 +01:00
|
|
|
|
|
|
|
it 'Notification email is not send' do
|
|
|
|
expect(NotificationMailer).not_to receive(:new_answer)
|
|
|
|
expect(WelcomeMailer).not_to receive(:deliver_now!)
|
|
|
|
|
|
|
|
subject
|
|
|
|
end
|
2015-08-10 11:05:06 +02:00
|
|
|
end
|
2015-09-25 10:46:09 +02:00
|
|
|
|
|
|
|
describe 'change dossier state after post a comment' do
|
|
|
|
context 'when user is connected' do
|
2015-11-02 11:33:00 +01:00
|
|
|
context 'when dossier is at state replied' do
|
2015-09-25 10:46:09 +02:00
|
|
|
before do
|
|
|
|
sign_in dossier.user
|
2015-11-02 11:33:00 +01:00
|
|
|
dossier.replied!
|
2015-09-25 10:46:09 +02:00
|
|
|
|
|
|
|
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
|
2015-08-10 11:05:06 +02:00
|
|
|
end
|
|
|
|
end
|