Add mailer Welcome
This commit is contained in:
parent
a2a5d63c0d
commit
a65f271a60
9 changed files with 57 additions and 0 deletions
2
Gemfile
2
Gemfile
|
@ -67,6 +67,8 @@ gem "font-awesome-rails"
|
|||
|
||||
gem 'hashie'
|
||||
|
||||
gem 'mailjet'
|
||||
|
||||
group :test do
|
||||
gem 'capybara'
|
||||
gem 'factory_girl'
|
||||
|
|
|
@ -194,6 +194,10 @@ GEM
|
|||
lumberjack (1.0.9)
|
||||
mail (2.6.3)
|
||||
mime-types (>= 1.16, < 3)
|
||||
mailjet (1.1.0)
|
||||
activesupport (>= 3.1.0)
|
||||
rack (>= 1.4.0)
|
||||
rest-client
|
||||
method_source (0.8.2)
|
||||
mime-types (2.6.1)
|
||||
mini_portile (0.6.2)
|
||||
|
@ -446,6 +450,7 @@ DEPENDENCIES
|
|||
leaflet-markercluster-rails (~> 0.7.0)
|
||||
leaflet-rails
|
||||
logstasher
|
||||
mailjet
|
||||
mina!
|
||||
openid_connect
|
||||
pg
|
||||
|
|
4
app/mailers/application_mailer.rb
Normal file
4
app/mailers/application_mailer.rb
Normal file
|
@ -0,0 +1,4 @@
|
|||
class ApplicationMailer < ActionMailer::Base
|
||||
default from: "tps@apientreprise.fr"
|
||||
layout 'mailer'
|
||||
end
|
9
app/mailers/welcome_mailer.rb
Normal file
9
app/mailers/welcome_mailer.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
class WelcomeMailer < ApplicationMailer
|
||||
def welcome_email user
|
||||
|
||||
@user = user
|
||||
|
||||
mail(from: "tps@apientreprise.fr", to: user.email,
|
||||
subject: "Création de votre compte TPS")
|
||||
end
|
||||
end
|
3
app/views/layouts/mailer.html.haml
Normal file
3
app/views/layouts/mailer.html.haml
Normal file
|
@ -0,0 +1,3 @@
|
|||
%hmtl
|
||||
%body
|
||||
= yield
|
1
app/views/layouts/mailer.text.haml
Normal file
1
app/views/layouts/mailer.text.haml
Normal file
|
@ -0,0 +1 @@
|
|||
= yield
|
15
app/views/welcome_mailer/welcome_email.text.erb
Normal file
15
app/views/welcome_mailer/welcome_email.text.erb
Normal file
|
@ -0,0 +1,15 @@
|
|||
Bienvenue sur la plateforme TPS
|
||||
|
||||
Nous vous remercions de vous être inscrit sur TPS. Pour mémoire, voici quelques informations utiles :
|
||||
|
||||
URL : https://tps.apientreprise.fr
|
||||
Login : <%= @user.email %>
|
||||
|
||||
Oubli de mot de passe, pas de problème :
|
||||
|
||||
https://tps.apientreprise.fr/users/password/new
|
||||
|
||||
Bonne journée,
|
||||
|
||||
---
|
||||
L'équipe TPS - tps@apientreprise.fr
|
|
@ -36,6 +36,9 @@ Rails.application.configure do
|
|||
# Raises helpful error messages.
|
||||
config.assets.raise_runtime_errors = true
|
||||
|
||||
config.action_mailer.delivery_method = :mailjet
|
||||
config.action_mailer.default_url_options = { :host => '{{ environment_mailer_host}}' }
|
||||
|
||||
# Raises error for missing translations
|
||||
# config.action_view.raise_on_missing_translations = true
|
||||
|
||||
|
|
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
Reference in a new issue