aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXinhui2017-07-10 13:41:03 +0200
committerXinhui2017-07-10 13:41:09 +0200
commit9559d8297d5d49145b866367c0e8c3d69e045adf (patch)
tree93989edf9ca99225f4a15dcf88f68fd3bed3953a
parent2aa97e30b4971aa06ba4d5ae16d5ce66d2b10e9e (diff)
downloadchouette-core-9559d8297d5d49145b866367c0e8c3d69e045adf.tar.bz2
Templating CalendarMailer
Refs #2263
-rw-r--r--app/jobs/mailer_job.rb2
-rw-r--r--app/mailers/calendar_mailer.rb2
-rw-r--r--app/views/calendar_mailer/created.html.slim3
-rw-r--r--app/views/calendar_mailer/updated.html.slim2
-rw-r--r--config/locales/mailers.en.yml4
-rw-r--r--config/locales/mailers.fr.yml4
-rw-r--r--spec/jobs/mailer_job_spec.rb5
-rw-r--r--spec/mailers/calendar_mailer_spec.rb2
8 files changed, 10 insertions, 14 deletions
diff --git a/app/jobs/mailer_job.rb b/app/jobs/mailer_job.rb
index 6d3dc642d..761a29cd6 100644
--- a/app/jobs/mailer_job.rb
+++ b/app/jobs/mailer_job.rb
@@ -2,6 +2,6 @@ class MailerJob < ActiveJob::Base
queue_as :mail
def perform klass, action, params
- klass.constantize.public_send(action, *params).deliver
+ klass.constantize.public_send(action, *params).deliver_later
end
end
diff --git a/app/mailers/calendar_mailer.rb b/app/mailers/calendar_mailer.rb
index 44dcaea88..cc8175a07 100644
--- a/app/mailers/calendar_mailer.rb
+++ b/app/mailers/calendar_mailer.rb
@@ -1,9 +1,11 @@
class CalendarMailer < ApplicationMailer
def updated calendar, user
+ @calendar = calendar
mail to: user.email, subject: t('mailers.calendar_mailer.updated.subject')
end
def created calendar, user
+ @calendar = calendar
mail to: user.email, subject: t('mailers.calendar_mailer.created.subject')
end
end
diff --git a/app/views/calendar_mailer/created.html.slim b/app/views/calendar_mailer/created.html.slim
index 621796d34..da15b7189 100644
--- a/app/views/calendar_mailer/created.html.slim
+++ b/app/views/calendar_mailer/created.html.slim
@@ -1,2 +1 @@
-div = t('mailers.calendar_mailer.created.body')
-
+div = t('mailers.calendar_mailer.created.body', cal_name: @calendar.name, cal_index_url: calendars_url)
diff --git a/app/views/calendar_mailer/updated.html.slim b/app/views/calendar_mailer/updated.html.slim
index 7f6deda07..f70480107 100644
--- a/app/views/calendar_mailer/updated.html.slim
+++ b/app/views/calendar_mailer/updated.html.slim
@@ -1,2 +1,2 @@
-div = t('mailers.calendar_mailer.updated.body')
+div = t('mailers.calendar_mailer.updated.body', cal_name: @calendar.name, cal_index_url: calendars_url)
diff --git a/config/locales/mailers.en.yml b/config/locales/mailers.en.yml
index 72fd0d725..d4bd45129 100644
--- a/config/locales/mailers.en.yml
+++ b/config/locales/mailers.en.yml
@@ -3,7 +3,7 @@ en:
calendar_mailer:
created:
subject: A new shared calendar has been created
- body: body created
+ body: A new shared calendar% {cal_name} has been added by STIF. You can now view it in the list of shared calendars %{cal_index_url}
created:
subject: A shared calendar has been updated
- body: body updated
+ body: A new shared calendar% {cal_name} has been updated by STIF. You can now view it in the list of shared calendars %{cal_index_url}
diff --git a/config/locales/mailers.fr.yml b/config/locales/mailers.fr.yml
index 8c399b6e0..a448f13d9 100644
--- a/config/locales/mailers.fr.yml
+++ b/config/locales/mailers.fr.yml
@@ -3,7 +3,7 @@ fr:
calendar_mailer:
created:
subject: Un nouveau calendrier partagé à été ajouté
- body: body created
+ body: 'Un calendrier partagé %{cal_name} a été ajouté par le STIF. Vous pouvez maintenant le consulter dans la liste des calendriers partagés : %{cal_index_url}'
updated:
subject: Un nouveau calendrier partagé à été mise à jour
- body: body updated
+ body: 'Un calendrier partagé %{cal_name} a été mis à jour par le STIF. Vous pouvez maintenant le consulter dans la liste des calendriers partagés : %{cal_index_url}'
diff --git a/spec/jobs/mailer_job_spec.rb b/spec/jobs/mailer_job_spec.rb
deleted file mode 100644
index 363b8724a..000000000
--- a/spec/jobs/mailer_job_spec.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-require 'rails_helper'
-
-RSpec.describe MailerJob, type: :job do
- pending "add some examples to (or delete) #{__FILE__}"
-end
diff --git a/spec/mailers/calendar_mailer_spec.rb b/spec/mailers/calendar_mailer_spec.rb
index d41092461..49cc3cce8 100644
--- a/spec/mailers/calendar_mailer_spec.rb
+++ b/spec/mailers/calendar_mailer_spec.rb
@@ -20,7 +20,7 @@ RSpec.describe CalendarMailer, type: :mailer do
end
it 'should have correct body' do
- key = I18n.t("mailers.calendar_mailer.#{type}.body")
+ key = I18n.t("mailers.calendar_mailer.#{type}.body", cal_name: calendar.name, cal_index_url: calendars_url)
expect(email).to have_body_text /#{key}/
end
end