mailer_spec.rb 1.9 KB
Newer Older
Alexandre Friquet's avatar
Alexandre Friquet committed
1
2
3
4
#
# OLIGAA - Stands for "Outil en Ligne d'Information et de Gestion des Activités
# des Associations" which is an online tool for associations to manage news,
# actors and activities.
5
# Copyright (C) 2010-2019 Comité Départemental du Sport Adapté de la Gironde (CDSA
Alexandre Friquet's avatar
Alexandre Friquet committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 33) <contact@cdsa33.org>
#
# This file is part of OLIGAA.
#
# OLIGAA is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# OLIGAA is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with OLIGAA.  If not, see <http://www.gnu.org/licenses/>.
#
23
require 'rails_helper'
Alexandre Friquet's avatar
Alexandre Friquet committed
24
25
26

describe Mailer do
  describe "send_info" do
Alexandre Friquet's avatar
Alexandre Friquet committed
27
    before :each do
Alexandre Friquet's avatar
Alexandre Friquet committed
28
29
30
31
      novel_type = create :novel_type, title: "Resultats"
      a1 = create :activity, title: "Athle"
      a2 = create :activity, title: "Football"
      novel = create :novel, title: "Championnats", content: "Voici les...", novel_type: novel_type, activities: [a1, a2]
Alexandre Friquet's avatar
Alexandre Friquet committed
32
      email = create :email, sender: "alex@ip.fr", novel: novel
Alexandre Friquet's avatar
Alexandre Friquet committed
33
      @mail = Mailer.send_info(email, "recipient1@example.com")
Alexandre Friquet's avatar
Alexandre Friquet committed
34
    end
Alexandre Friquet's avatar
Alexandre Friquet committed
35
36

    it "renders the headers" do
37
38
39
      expect(@mail.subject).to eq("Championnats")
      expect(@mail.from).to eq(["alex@ip.fr"])
      expect(@mail.to).to eq(["recipient1@example.com"])
Alexandre Friquet's avatar
Alexandre Friquet committed
40
41
42
    end

    it "renders the body" do
43
44
45
      expect(@mail.body.encoded).to match("Resultats")
      expect(@mail.body.encoded).to match("Athle / Football")
      expect(@mail.body.encoded).to match("Voici les...")
Alexandre Friquet's avatar
Alexandre Friquet committed
46
47
    end
  end
48
49
50

  pending "TODO: contact_us"
  pending "TODO: reset_password"
51
end