From 482ca2a31745cf7742640027d3cf290c79dee772 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 24 Jan 2017 11:58:09 +0100 Subject: [PATCH] Add a mail_template decorator --- app/decorators/mail_template_decorator.rb | 12 ++++++++++++ .../mail_template_decorator_spec.rb | 19 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 app/decorators/mail_template_decorator.rb create mode 100644 spec/decorators/mail_template_decorator_spec.rb diff --git a/app/decorators/mail_template_decorator.rb b/app/decorators/mail_template_decorator.rb new file mode 100644 index 000000000..b6f1e64dc --- /dev/null +++ b/app/decorators/mail_template_decorator.rb @@ -0,0 +1,12 @@ +class MailTemplateDecorator < Draper::Decorator + delegate_all + + def name + case object.type + when "MailReceived" + "Email d'accusé de réception" + else + object.type + end + end +end diff --git a/spec/decorators/mail_template_decorator_spec.rb b/spec/decorators/mail_template_decorator_spec.rb new file mode 100644 index 000000000..a47d17dfc --- /dev/null +++ b/spec/decorators/mail_template_decorator_spec.rb @@ -0,0 +1,19 @@ +require 'spec_helper' + +describe MailTemplateDecorator do + let(:mail_template) {create :mail_template} + let(:decorator) { mail_template.decorate } + + context '#name' do + subject { decorator.name } + + it { is_expected.to eq decorator.type} + + context 'when mail_template is a MailReceived' do + let(:mail_template) {create :mail_template, :dossier_received} + it { is_expected.to eq "Email d'accusé de réception" } + end + + end + +end