aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert2017-07-10 16:19:59 +0200
committerRobert2017-07-10 16:19:59 +0200
commit2da5bd656b9bbd99d9dac3bdd46ea1f75163e459 (patch)
treebe8748128ce20bd1f099d47a600d5e1827780573
parent9041ceafc736982a2bab52cd4c2c5c3581ee711c (diff)
parentd1a055b6a2bbeae4f217fe85660a0612e22dabd1 (diff)
downloadchouette-core-2da5bd656b9bbd99d9dac3bdd46ea1f75163e459.tar.bz2
Merge branch 'master' of github.com:af83/stif-boiv
-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/application.rb2
-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
-rw-r--r--spec/mailers/previews/calendar_mailer_preview.rb9
10 files changed, 21 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/application.rb b/config/application.rb
index 02d2b4fc2..910ddd983 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -33,6 +33,8 @@ module ChouetteIhm
config.active_record.observers = [:route_observer, :calendar_observer]
config.active_record.raise_in_transactional_callbacks = true
+ config.active_job.queue_adapter = :sidekiq
+
unless Rails.env.production?
# Work around sprockets+teaspoon mismatch:
Rails.application.config.assets.precompile += %w(spec_helper.js)
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
diff --git a/spec/mailers/previews/calendar_mailer_preview.rb b/spec/mailers/previews/calendar_mailer_preview.rb
index 572c6c667..5fa108924 100644
--- a/spec/mailers/previews/calendar_mailer_preview.rb
+++ b/spec/mailers/previews/calendar_mailer_preview.rb
@@ -1,4 +1,13 @@
# Preview all emails at http://localhost:3000/rails/mailers/calendar_mailer
class CalendarMailerPreview < ActionMailer::Preview
+ def created
+ cal = Calendar.new(name: 'test calendar', shared: true)
+ CalendarMailer.created(cal, User.take)
+ end
+
+ def updated
+ cal = Calendar.new(name: 'test calendar', shared: true)
+ CalendarMailer.updated(cal, User.take)
+ end
end