demarches-normaliennes/spec/controllers/users/dossiers/commentaires_controller_spec.rb

45 lines
1.1 KiB
Ruby
Raw Normal View History

2016-02-22 15:22:06 +01:00
require 'spec_helper'
describe Users::Dossiers::CommentairesController, type: :controller do
let(:dossier) { create(:dossier) }
let(:texte_commentaire) { 'Commentaire de test' }
describe '#POST create' do
subject {
post :create, params: { dossier_id: dossier.id, texte_commentaire: texte_commentaire }
dossier.reload
}
2016-02-22 15:22:06 +01:00
context 'when invite is connected' do
let!(:invite) { create(:invite, :with_user, dossier: dossier) }
before do
sign_in invite.user
end
it do
subject
is_expected.to redirect_to users_dossiers_invite_path(invite.id)
end
it 'should notify user' do
expect(NotificationMailer).to receive(:new_answer).and_return(NotificationMailer)
expect(NotificationMailer).to receive(:deliver_later)
subject
end
end
context 'when user is connected' do
before do
sign_in dossier.user
end
2016-02-22 15:22:06 +01:00
it 'do not send a mail to notify user' do
expect(NotificationMailer).to_not receive(:new_answer)
subject
2016-02-22 15:22:06 +01:00
end
end
end
2016-02-22 15:22:06 +01:00
end