Add mailer Welcome

This commit is contained in:
Xavier J 2015-12-14 16:09:20 +01:00
parent a2a5d63c0d
commit a65f271a60
9 changed files with 57 additions and 0 deletions

View file

@ -67,6 +67,8 @@ gem "font-awesome-rails"
gem 'hashie' gem 'hashie'
gem 'mailjet'
group :test do group :test do
gem 'capybara' gem 'capybara'
gem 'factory_girl' gem 'factory_girl'

View file

@ -194,6 +194,10 @@ GEM
lumberjack (1.0.9) lumberjack (1.0.9)
mail (2.6.3) mail (2.6.3)
mime-types (>= 1.16, < 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) method_source (0.8.2)
mime-types (2.6.1) mime-types (2.6.1)
mini_portile (0.6.2) mini_portile (0.6.2)
@ -446,6 +450,7 @@ DEPENDENCIES
leaflet-markercluster-rails (~> 0.7.0) leaflet-markercluster-rails (~> 0.7.0)
leaflet-rails leaflet-rails
logstasher logstasher
mailjet
mina! mina!
openid_connect openid_connect
pg pg

View file

@ -0,0 +1,4 @@
class ApplicationMailer < ActionMailer::Base
default from: "tps@apientreprise.fr"
layout 'mailer'
end

View 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

View file

@ -0,0 +1,3 @@
%hmtl
%body
= yield

View file

@ -0,0 +1 @@
= yield

View 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

View file

@ -36,6 +36,9 @@ Rails.application.configure do
# Raises helpful error messages. # Raises helpful error messages.
config.assets.raise_runtime_errors = true 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 # Raises error for missing translations
# config.action_view.raise_on_missing_translations = true # config.action_view.raise_on_missing_translations = true

View 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