diff --git a/app/controllers/admin/mail_templates_controller.rb b/app/controllers/admin/mail_templates_controller.rb
index a0696fd49..7ec106986 100644
--- a/app/controllers/admin/mail_templates_controller.rb
+++ b/app/controllers/admin/mail_templates_controller.rb
@@ -34,7 +34,7 @@ class Admin::MailTemplatesController < AdminController
def update_params
{
procedure_id: params[:procedure_id],
- object: params[:mail_template][:object],
+ subject: params[:mail_template][:subject],
body: params[:mail_template][:body],
}
end
diff --git a/app/mailers/notification_mailer.rb b/app/mailers/notification_mailer.rb
index a509fe762..b890b994f 100644
--- a/app/mailers/notification_mailer.rb
+++ b/app/mailers/notification_mailer.rb
@@ -11,22 +11,22 @@ class NotificationMailer < ApplicationMailer
def send_notification(dossier, mail_template, attestation = nil)
vars_mailer(dossier)
- @object = mail_template.object_for_dossier dossier
+ @subject = mail_template.subject_for_dossier dossier
@body = mail_template.body_for_dossier dossier
if attestation.present?
attachments['attestation.pdf'] = attestation
end
- mail(subject: @object) { |format| format.html { @body } }
+ mail(subject: @subject) { |format| format.html { @body } }
end
def send_draft_notification(dossier)
vars_mailer(dossier)
- @object = "Retrouvez votre brouillon pour la démarche : #{dossier.procedure.libelle}"
+ @subject = "Retrouvez votre brouillon pour la démarche : #{dossier.procedure.libelle}"
- mail(subject: @object)
+ mail(subject: @subject)
end
def new_answer(dossier)
@@ -39,7 +39,7 @@ class NotificationMailer < ApplicationMailer
Commentaire.create(
dossier: @dossier,
email: I18n.t("dynamics.contact_email"),
- body: ["[#{@object}]", @body].join("
")
+ body: ["[#{@subject}]", @body].join("
")
)
end
diff --git a/app/models/concerns/mail_template_concern.rb b/app/models/concerns/mail_template_concern.rb
index 55f5fc8e7..17fdd5246 100644
--- a/app/models/concerns/mail_template_concern.rb
+++ b/app/models/concerns/mail_template_concern.rb
@@ -5,8 +5,8 @@ module MailTemplateConcern
include ActionView::Helpers::UrlHelper
include TagsSubstitutionConcern
- def object_for_dossier(dossier)
- replace_tags(object, dossier)
+ def subject_for_dossier(dossier)
+ replace_tags(subject, dossier)
end
def body_for_dossier(dossier)
@@ -20,7 +20,7 @@ module MailTemplateConcern
module ClassMethods
def default_for_procedure(procedure)
body = ActionController::Base.new.render_to_string(template: self.const_get(:TEMPLATE_NAME))
- self.new(object: self.const_get(:DEFAULT_OBJECT), body: body, procedure: procedure)
+ self.new(subject: self.const_get(:DEFAULT_SUBJECT), body: body, procedure: procedure)
end
end
diff --git a/app/models/mails/closed_mail.rb b/app/models/mails/closed_mail.rb
index eabd86a79..cf7231836 100644
--- a/app/models/mails/closed_mail.rb
+++ b/app/models/mails/closed_mail.rb
@@ -7,7 +7,7 @@ module Mails
SLUG = "closed_mail"
TEMPLATE_NAME = "mails/closed_mail"
DISPLAYED_NAME = "Accusé d'acceptation"
- DEFAULT_OBJECT = 'Votre dossier TPS nº --numéro du dossier-- a été accepté'
+ DEFAULT_SUBJECT = 'Votre dossier TPS nº --numéro du dossier-- a été accepté'
IS_DOSSIER_TERMINE = true
end
end
diff --git a/app/models/mails/initiated_mail.rb b/app/models/mails/initiated_mail.rb
index f892a6ea3..c9ca384ac 100644
--- a/app/models/mails/initiated_mail.rb
+++ b/app/models/mails/initiated_mail.rb
@@ -7,7 +7,7 @@ module Mails
SLUG = "initiated_mail"
TEMPLATE_NAME = "mails/initiated_mail"
DISPLAYED_NAME = 'Accusé de réception'
- DEFAULT_OBJECT = 'Votre dossier TPS nº --numéro du dossier-- a bien été reçu'
+ DEFAULT_SUBJECT = 'Votre dossier TPS nº --numéro du dossier-- a bien été reçu'
IS_DOSSIER_TERMINE = false
end
end
diff --git a/app/models/mails/received_mail.rb b/app/models/mails/received_mail.rb
index e2e7ade1d..30f58de9a 100644
--- a/app/models/mails/received_mail.rb
+++ b/app/models/mails/received_mail.rb
@@ -7,7 +7,7 @@ module Mails
SLUG = "received_mail"
TEMPLATE_NAME = "mails/received_mail"
DISPLAYED_NAME = 'Accusé de passage en instruction'
- DEFAULT_OBJECT = 'Votre dossier TPS nº --numéro du dossier-- va être instruit'
+ DEFAULT_SUBJECT = 'Votre dossier TPS nº --numéro du dossier-- va être instruit'
IS_DOSSIER_TERMINE = false
end
end
diff --git a/app/models/mails/refused_mail.rb b/app/models/mails/refused_mail.rb
index 5044f420f..4e0d818c6 100644
--- a/app/models/mails/refused_mail.rb
+++ b/app/models/mails/refused_mail.rb
@@ -7,7 +7,7 @@ module Mails
SLUG = "refused_mail"
TEMPLATE_NAME = "mails/refused_mail"
DISPLAYED_NAME = 'Accusé de rejet du dossier'
- DEFAULT_OBJECT = 'Votre dossier TPS nº --numéro du dossier-- a été refusé'
+ DEFAULT_SUBJECT = 'Votre dossier TPS nº --numéro du dossier-- a été refusé'
IS_DOSSIER_TERMINE = true
end
end
diff --git a/app/models/mails/without_continuation_mail.rb b/app/models/mails/without_continuation_mail.rb
index 8dff84ef4..2c1e2f8b2 100644
--- a/app/models/mails/without_continuation_mail.rb
+++ b/app/models/mails/without_continuation_mail.rb
@@ -7,7 +7,7 @@ module Mails
SLUG = "without_continuation"
TEMPLATE_NAME = "mails/without_continuation_mail"
DISPLAYED_NAME = 'Accusé de classement sans suite'
- DEFAULT_OBJECT = 'Votre dossier TPS nº --numéro du dossier-- a été classé sans suite'
+ DEFAULT_SUBJECT = 'Votre dossier TPS nº --numéro du dossier-- a été classé sans suite'
IS_DOSSIER_TERMINE = true
end
end
diff --git a/app/views/admin/mail_templates/edit.html.haml b/app/views/admin/mail_templates/edit.html.haml
index 0e5718ce9..083139147 100644
--- a/app/views/admin/mail_templates/edit.html.haml
+++ b/app/views/admin/mail_templates/edit.html.haml
@@ -8,7 +8,7 @@
method: :put do |f|
.row
.col-md-6
- = f.input :object, label: "Objet de l'email"
+ = f.input :subject, label: "Objet de l'email"
= f.input :body, label: "Corps de l'email", input_html: { class: 'wysihtml5' }
.text-right
= link_to "Annuler", admin_procedure_mail_templates_path(@procedure), class: "btn btn-default"
diff --git a/db/migrate/20180108152958_rename_object_to_subject_in_mails.rb b/db/migrate/20180108152958_rename_object_to_subject_in_mails.rb
new file mode 100644
index 000000000..6bf91beee
--- /dev/null
+++ b/db/migrate/20180108152958_rename_object_to_subject_in_mails.rb
@@ -0,0 +1,9 @@
+class RenameObjectToSubjectInMails < ActiveRecord::Migration[5.0]
+ def change
+ rename_column :closed_mails, :object, :subject
+ rename_column :initiated_mails, :object, :subject
+ rename_column :received_mails, :object, :subject
+ rename_column :refused_mails, :object, :subject
+ rename_column :without_continuation_mails, :object, :subject
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 2eefdabd4..1b15e08d0 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20180108144114) do
+ActiveRecord::Schema.define(version: 20180108152958) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -149,7 +149,7 @@ ActiveRecord::Schema.define(version: 20180108144114) do
create_table "closed_mails", force: :cascade do |t|
t.text "body"
- t.string "object"
+ t.string "subject"
t.integer "procedure_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
@@ -307,7 +307,7 @@ ActiveRecord::Schema.define(version: 20180108144114) do
end
create_table "initiated_mails", force: :cascade do |t|
- t.string "object"
+ t.string "subject"
t.text "body"
t.integer "procedure_id"
t.datetime "created_at", null: false
@@ -430,7 +430,7 @@ ActiveRecord::Schema.define(version: 20180108144114) do
create_table "received_mails", force: :cascade do |t|
t.text "body"
- t.string "object"
+ t.string "subject"
t.integer "procedure_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
@@ -439,7 +439,7 @@ ActiveRecord::Schema.define(version: 20180108144114) do
create_table "refused_mails", force: :cascade do |t|
t.text "body"
- t.string "object"
+ t.string "subject"
t.integer "procedure_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
@@ -500,7 +500,7 @@ ActiveRecord::Schema.define(version: 20180108144114) do
create_table "without_continuation_mails", force: :cascade do |t|
t.text "body"
- t.string "object"
+ t.string "subject"
t.integer "procedure_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
diff --git a/spec/controllers/admin/mail_templates_controller_spec.rb b/spec/controllers/admin/mail_templates_controller_spec.rb
index 6368da749..faffe624d 100644
--- a/spec/controllers/admin/mail_templates_controller_spec.rb
+++ b/spec/controllers/admin/mail_templates_controller_spec.rb
@@ -19,14 +19,14 @@ describe Admin::MailTemplatesController, type: :controller do
end
describe 'PATCH update' do
- let(:object) { 'plop modif' }
- let(:body) { 'plip modif' }
+ let(:mail_subject) { 'plop modif' }
+ let(:mail_body) { 'plip modif' }
before :each do
patch :update,
params: { procedure_id: procedure.id,
id: initiated_mail.class.const_get(:SLUG),
- mail_template: { object: object, body: body }
+ mail_template: { subject: mail_subject, body: mail_body }
}
end
@@ -35,8 +35,8 @@ describe Admin::MailTemplatesController, type: :controller do
context 'the mail template' do
subject { procedure.reload ; procedure.initiated_mail_template }
- it { expect(subject.object).to eq(object) }
- it { expect(subject.body).to eq(body) }
+ it { expect(subject.subject).to eq(mail_subject) }
+ it { expect(subject.body).to eq(mail_body) }
end
end
end
diff --git a/spec/factories/mail_templates.rb b/spec/factories/mail_templates.rb
index 3a1f2f434..619ca6eea 100644
--- a/spec/factories/mail_templates.rb
+++ b/spec/factories/mail_templates.rb
@@ -1,6 +1,6 @@
FactoryGirl.define do
factory :mail_template, class: Mails::ClosedMail do
- object "Object, voila voila"
+ subject "Subject, voila voila"
body "Blabla ceci est mon body"
factory :dossier_submitted_mail_template, class: Mails::ReceivedMail
@@ -8,7 +8,7 @@ FactoryGirl.define do
factory :dossier_refused_mail_template, class: Mails::RefusedMail
factory :dossier_en_instruction_mail_template, class: Mails::InitiatedMail do
- object "[TPS] Accusé de réception pour votre dossier nº --numéro du dossier--"
+ subject "[TPS] Accusé de réception pour votre dossier nº --numéro du dossier--"
body "Votre administration vous confirme la bonne réception de votre dossier nº --numéro du dossier--"
end
end
diff --git a/spec/factories/received_mail.rb b/spec/factories/received_mail.rb
index d97effd96..4a001bde9 100644
--- a/spec/factories/received_mail.rb
+++ b/spec/factories/received_mail.rb
@@ -1,6 +1,6 @@
FactoryGirl.define do
factory :received_mail, class: Mails::ReceivedMail do
- object "Mail d'accusé de bonne reception de votre dossier"
+ subject "Mail d'accusé de bonne reception de votre dossier"
body "Votre dossier est correctement reçu"
end
end
diff --git a/spec/mailers/notification_mailer_spec.rb b/spec/mailers/notification_mailer_spec.rb
index 88f430497..627ae33eb 100644
--- a/spec/mailers/notification_mailer_spec.rb
+++ b/spec/mailers/notification_mailer_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe NotificationMailer, type: :mailer do
subject.deliver_now
commentaire = Commentaire.last
- expect(commentaire.body).to include(email_template.object_for_dossier(dossier), email_template.body_for_dossier(dossier))
+ expect(commentaire.body).to include(email_template.subject_for_dossier(dossier), email_template.body_for_dossier(dossier))
expect(commentaire.dossier).to eq(dossier)
end
end
@@ -17,13 +17,13 @@ RSpec.describe NotificationMailer, type: :mailer do
let(:dossier) { create(:dossier, user: user) }
describe '.send_notification' do
- let(:email_template) { instance_double('email_template', object_for_dossier: 'object', body_for_dossier: 'body') }
+ let(:email_template) { instance_double('email_template', subject_for_dossier: 'subject', body_for_dossier: 'body') }
let(:attestation) { nil }
let(:notifications_count_before) { Notification.count }
subject { described_class.send_notification(dossier, email_template, attestation) }
- it { expect(subject.subject).to eq(email_template.object_for_dossier) }
+ it { expect(subject.subject).to eq(email_template.subject_for_dossier) }
it { expect(subject.body).to eq(email_template.body_for_dossier) }
it { expect(subject.attachments['attestation.pdf']).to eq(nil) }
@@ -50,7 +50,7 @@ RSpec.describe NotificationMailer, type: :mailer do
end
it do
- expect(subject.subject).to eq(email_template.object)
+ expect(subject.subject).to eq(email_template.subject)
expect(subject.body).to eq(email_template.body)
end
diff --git a/spec/models/concern/mail_template_concern_spec.rb b/spec/models/concern/mail_template_concern_spec.rb
index 03b987be5..84c36d2a1 100644
--- a/spec/models/concern/mail_template_concern_spec.rb
+++ b/spec/models/concern/mail_template_concern_spec.rb
@@ -33,9 +33,9 @@ describe MailTemplateConcern do
end
end
- describe '.object_for_dossier' do
- before { initiated_mail.object = template }
- subject { initiated_mail.object_for_dossier(dossier) }
+ describe '.subject_for_dossier' do
+ before { initiated_mail.subject = template }
+ subject { initiated_mail.subject_for_dossier(dossier) }
it_behaves_like "can replace tokens in template"
end