demarches-normaliennes/spec/controllers/commentaires_controller_spec.rb

25 lines
973 B
Ruby
Raw Normal View History

2015-08-10 11:05:06 +02:00
require 'spec_helper'
2015-08-11 15:22:07 +02:00
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' }
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
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