demarches-normaliennes/spec/controllers/commentaires_controller_spec.rb
Tanguy PATTE 3c57643f76 add database cleaner
add factory girl
fix tests
rename dossier_pdf into piece_jointe
rename ref_piece_jointe into content
2015-08-13 15:56:58 +02:00

24 lines
973 B
Ruby

require 'spec_helper'
describe CommentairesController, type: :controller do
let(:dossier) { create(:dossier) }
let (:dossier_id) { dossier.id }
let (:email_commentaire) { 'test@test.com' }
let (:texte_commentaire) { 'Commentaire de test' }
describe '#POST create' do
context 'création correct d\'un commentaire' do
it 'depuis la page récapitulatif' do
request.env["HTTP_REFERER"] = "/recapitulatif"
post :create, :dossier_id => dossier_id, :email_commentaire => email_commentaire, :texte_commentaire => texte_commentaire
expect(response).to redirect_to("/dossiers/#{dossier_id}/recapitulatif")
end
it 'depuis la page admin' do
request.env["HTTP_REFERER"] = "/admin/dossier"
post :create, :dossier_id => dossier_id, :email_commentaire => email_commentaire, :texte_commentaire => texte_commentaire
expect(response).to redirect_to("/admin/dossier/#{dossier_id}")
end
end
end
end