demarches-normaliennes/spec/controllers/commentaires_controller_spec.rb

37 lines
1.1 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
it 'depuis la page récapitulatif' do
2015-09-24 10:34:01 +02:00
sign_in dossier.user
post :create, dossier_id: dossier_id, texte_commentaire: texte_commentaire
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
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