NotificationMailer : new answer
This commit is contained in:
parent
1652a747a1
commit
25937b2635
5 changed files with 38 additions and 1 deletions
10
app/mailers/notification_mailer.rb
Normal file
10
app/mailers/notification_mailer.rb
Normal file
|
@ -0,0 +1,10 @@
|
|||
class NotificationMailer < ApplicationMailer
|
||||
def new_answer dossier
|
||||
@user = dossier.user
|
||||
@dossier = dossier
|
||||
# @url = users_dossier_url id: dossier.id
|
||||
|
||||
mail(from: "tps@apientreprise.fr", to: dossier.user.email,
|
||||
subject: "Nouveau commentaire pour votre dossier TPS N°#{dossier.id}")
|
||||
end
|
||||
end
|
10
app/views/notification_mailer/new_answer.text.erb
Normal file
10
app/views/notification_mailer/new_answer.text.erb
Normal file
|
@ -0,0 +1,10 @@
|
|||
Bonjour <%= @user.email %>!
|
||||
|
||||
Un nouveau commentaire est disponible dans votre espace TPS.
|
||||
|
||||
Pour le consulter, merci de vous rendre sur <%=users_dossiers_url(id: @dossier.id)%>
|
||||
|
||||
Bonne journée
|
||||
|
||||
---
|
||||
L'équide TPS - tps@apientreprise.fr
|
|
@ -37,7 +37,7 @@ Rails.application.configure do
|
|||
config.assets.raise_runtime_errors = true
|
||||
|
||||
config.action_mailer.delivery_method = :mailjet
|
||||
config.action_mailer.default_url_options = { :host => '{{ environment_mailer_host}}' }
|
||||
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
|
||||
|
||||
# Raises error for missing translations
|
||||
# config.action_view.raise_on_missing_translations = true
|
||||
|
|
|
@ -37,6 +37,9 @@ Rails.application.configure do
|
|||
# Print deprecation notices to the stderr.
|
||||
config.active_support.deprecation = :stderr
|
||||
|
||||
config.action_mailer.delivery_method = :mailjet
|
||||
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
|
||||
|
||||
# Raises error for missing translations
|
||||
# config.action_view.raise_on_missing_translations = true
|
||||
end
|
||||
|
|
14
spec/mailers/notification_mailer_spec.rb
Normal file
14
spec/mailers/notification_mailer_spec.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
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_dossiers_url(id: dossier.id)}") }
|
||||
it { expect(subject.subject).to eq("Nouveau commentaire pour votre dossier TPS N°#{dossier.id}") }
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue