demarches-normaliennes/spec/controllers/commentaires_controller_spec.rb

48 lines
1.3 KiB
Ruby
Raw Normal View History

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
subject do
2015-09-24 10:34:01 +02:00
sign_in dossier.user
post :create, dossier_id: dossier_id, texte_commentaire: texte_commentaire
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
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
describe 'change dossier state after post a comment' do
context 'when user is connected' do
context 'when dossier is at state replied' do
before do
sign_in dossier.user
dossier.replied!
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