Merge branch 'develop' of github.com:sgmap/tps into develop
This commit is contained in:
commit
789ea308ee
25 changed files with 211 additions and 8 deletions
|
@ -31,6 +31,13 @@ describe Backoffice::CommentairesController, type: :controller do
|
|||
subject { dossier.state }
|
||||
|
||||
it {is_expected.to eq('replied')}
|
||||
|
||||
it 'Notification email is send' do
|
||||
expect(NotificationMailer).to receive(:new_answer).and_return(NotificationMailer)
|
||||
expect(NotificationMailer).to receive(:deliver_now!)
|
||||
|
||||
post :create, dossier_id: dossier_id, texte_commentaire: texte_commentaire
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -98,12 +98,21 @@ describe Backoffice::DossiersController, type: :controller do
|
|||
sign_in gestionnaire
|
||||
end
|
||||
|
||||
subject { post :valid, dossier_id: dossier_id }
|
||||
|
||||
it 'change state to validated' do
|
||||
post :valid, dossier_id: dossier_id
|
||||
subject
|
||||
|
||||
dossier.reload
|
||||
expect(dossier.state).to eq('validated')
|
||||
end
|
||||
|
||||
it 'Notification email is send' do
|
||||
expect(NotificationMailer).to receive(:dossier_validated).and_return(NotificationMailer)
|
||||
expect(NotificationMailer).to receive(:deliver_now!)
|
||||
|
||||
subject
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #close' do
|
||||
|
|
|
@ -8,11 +8,22 @@ describe Users::CommentairesController, type: :controller do
|
|||
|
||||
describe '#POST create' do
|
||||
context 'création correct d\'un commentaire' do
|
||||
it 'depuis la page récapitulatif' do
|
||||
subject do
|
||||
sign_in dossier.user
|
||||
post :create, dossier_id: dossier_id, texte_commentaire: texte_commentaire
|
||||
end
|
||||
|
||||
it 'depuis la page récapitulatif' do
|
||||
subject
|
||||
expect(response).to redirect_to("/users/dossiers/#{dossier_id}/recapitulatif")
|
||||
end
|
||||
|
||||
it 'Notification email is not send' do
|
||||
expect(NotificationMailer).not_to receive(:new_answer)
|
||||
expect(WelcomeMailer).not_to receive(:deliver_now!)
|
||||
|
||||
subject
|
||||
end
|
||||
end
|
||||
|
||||
describe 'change dossier state after post a comment' do
|
||||
|
|
26
spec/controllers/users/registrations_controller_spec.rb
Normal file
26
spec/controllers/users/registrations_controller_spec.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Users::RegistrationsController, type: :controller do
|
||||
|
||||
let(:email) { 'test@octo.com' }
|
||||
let(:password) { 'password' }
|
||||
|
||||
let(:user) { { email: email, password: password, password_confirmation: password } }
|
||||
|
||||
before do
|
||||
@request.env["devise.mapping"] = Devise.mappings[:user]
|
||||
end
|
||||
|
||||
describe '.create' do
|
||||
subject { post :create, user: user }
|
||||
|
||||
it { expect(described_class).to be < Devise::RegistrationsController }
|
||||
|
||||
it 'welcome email is send' do
|
||||
expect(WelcomeMailer).to receive(:welcome_email).and_return(WelcomeMailer)
|
||||
expect(WelcomeMailer).to receive(:deliver_now!)
|
||||
|
||||
subject
|
||||
end
|
||||
end
|
||||
end
|
25
spec/mailers/notification_mailer_spec.rb
Normal file
25
spec/mailers/notification_mailer_spec.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe NotificationMailer, type: :mailer do
|
||||
describe ".new_answer" do
|
||||
let(:user) { create(:user) }
|
||||
let(:dossier) { create(:dossier, :with_procedure, user: user) }
|
||||
|
||||
subject(:subject) { described_class.new_answer(dossier) }
|
||||
|
||||
it { expect(subject.body).to match('Un nouveau commentaire est disponible dans votre espace TPS.') }
|
||||
it { expect(subject.body).to include("Pour le consulter, merci de vous rendre sur #{users_dossier_recapitulatif_url(dossier_id: dossier.id)}") }
|
||||
it { expect(subject.subject).to eq("Nouveau commentaire pour votre dossier TPS N°#{dossier.id}") }
|
||||
end
|
||||
|
||||
describe ".dossier_validated" do
|
||||
let(:user) { create(:user) }
|
||||
let(:dossier) { create(:dossier, :with_procedure, user: user) }
|
||||
|
||||
subject(:subject) { described_class.dossier_validated(dossier) }
|
||||
|
||||
it { expect(subject.body).to match("Votre dossier N°#{dossier.id} a été validé par votre gestionnaire.") }
|
||||
it { expect(subject.body).to include("Afin de finaliser son dépot, merci de vous rendre sur #{users_dossier_recapitulatif_url(dossier_id: dossier.id)}") }
|
||||
it { expect(subject.subject).to eq("Votre dossier TPS N°#{dossier.id} a été validé") }
|
||||
end
|
||||
end
|
15
spec/mailers/welcome_mailer_spec.rb
Normal file
15
spec/mailers/welcome_mailer_spec.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe WelcomeMailer, type: :mailer do
|
||||
describe ".welcome_email" do
|
||||
let(:user) { create(:user) }
|
||||
subject(:subject) { described_class.welcome_email(user) }
|
||||
it { expect(subject.body).to match('https://tps.apientreprise.fr') }
|
||||
it { expect(subject.body).to match('https://tps.apientreprise.fr/users/password/new') }
|
||||
it { expect(subject.body).to match(user.email) }
|
||||
it { expect(subject.body).to match('Bienvenue sur la plateforme TPS') }
|
||||
it { expect(subject.body).to match('Nous vous remercions de vous être inscrit sur TPS. Pour mémoire, voici quelques informations utiles :')}
|
||||
|
||||
it { expect(subject.subject).to eq("Création de votre compte TPS") }
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue