Fix tests after workflow simplication
This commit is contained in:
parent
10add61bd1
commit
4cc6aedfb9
15 changed files with 9 additions and 76 deletions
|
@ -5,9 +5,6 @@ class MailTemplateDecorator < Draper::Decorator
|
||||||
case object.type
|
case object.type
|
||||||
when "MailReceived"
|
when "MailReceived"
|
||||||
"E-mail d'accusé de réception"
|
"E-mail d'accusé de réception"
|
||||||
when "MailValidated"
|
|
||||||
"E-mail de validation"
|
|
||||||
else
|
|
||||||
object.type
|
object.type
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,10 +7,6 @@ class NotificationMailer < ApplicationMailer
|
||||||
send_mail dossier, dossier.procedure.mail_received.object_for_dossier(dossier)
|
send_mail dossier, dossier.procedure.mail_received.object_for_dossier(dossier)
|
||||||
end
|
end
|
||||||
|
|
||||||
def dossier_validated dossier
|
|
||||||
send_mail dossier, dossier.procedure.mail_validated.object_for_dossier(dossier)
|
|
||||||
end
|
|
||||||
|
|
||||||
def dossier_submitted dossier
|
def dossier_submitted dossier
|
||||||
send_mail dossier, "Votre dossier TPS N°#{dossier.id} a été déposé"
|
send_mail dossier, "Votre dossier TPS N°#{dossier.id} a été déposé"
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
class MailValidated < MailTemplate
|
|
||||||
before_save :default_values
|
|
||||||
|
|
||||||
def default_values
|
|
||||||
self.object ||= "[TPS] Votre dossier TPS N°--numero_dossier-- a été validé"
|
|
||||||
self.body ||= "Bonjour,<br>
|
|
||||||
<br>
|
|
||||||
Votre dossier N°--numero_dossier-- est prêt à être déposé pour instruction.<br>
|
|
||||||
<br>
|
|
||||||
Afin de finaliser son dépôt, merci de vous rendre sur --lien_dossier--.,<br>
|
|
||||||
<br>
|
|
||||||
Bonne journée,<br>
|
|
||||||
---<br>
|
|
||||||
Merci de ne pas répondre à ce mail. Postez directement vos questions dans votre dossier sur la plateforme.<br>
|
|
||||||
---<br>
|
|
||||||
L'équipe TPS"
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -34,7 +34,6 @@ class Procedure < ActiveRecord::Base
|
||||||
|
|
||||||
def build_default_mails
|
def build_default_mails
|
||||||
MailReceived.create(procedure: self) unless mail_received
|
MailReceived.create(procedure: self) unless mail_received
|
||||||
MailValidated.create(procedure: self) unless mail_validated
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def path
|
def path
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
<%= @dossier.procedure.mail_validated.body_for_dossier(@dossier).html_safe %>
|
|
|
@ -1,9 +0,0 @@
|
||||||
class InitMailValidatedForAllProcedure < ActiveRecord::Migration[5.0]
|
|
||||||
def change
|
|
||||||
Procedure.all.each do |p|
|
|
||||||
unless p.mail_validated
|
|
||||||
p.mail_templates << MailValidated.create
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class DeleteAllMailValidatedInDb < ActiveRecord::Migration[5.0]
|
||||||
|
def change
|
||||||
|
MailTemplate.where(type: "MailValidated").delete_all
|
||||||
|
end
|
||||||
|
end
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20170221143909) do
|
ActiveRecord::Schema.define(version: 20170223170808) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
|
|
@ -7,10 +7,6 @@ describe MailTemplateDecorator do
|
||||||
context '#name' do
|
context '#name' do
|
||||||
subject { decorator.name }
|
subject { decorator.name }
|
||||||
|
|
||||||
context 'when mail_template is a MailValidated' do
|
|
||||||
it { is_expected.to eq "E-mail de validation" }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when mail_template is a MailReceived' do
|
context 'when mail_template is a MailReceived' do
|
||||||
let(:mail_template) {create :mail_template, :dossier_received}
|
let(:mail_template) {create :mail_template, :dossier_received}
|
||||||
it { is_expected.to eq "E-mail d'accusé de réception" }
|
it { is_expected.to eq "E-mail d'accusé de réception" }
|
||||||
|
|
|
@ -10,10 +10,10 @@ feature 'As an Accompagnateur I can navigate and use each functionnality around
|
||||||
create :assign_to, gestionnaire: gestionnaire, procedure: procedure_1
|
create :assign_to, gestionnaire: gestionnaire, procedure: procedure_1
|
||||||
create :assign_to, gestionnaire: gestionnaire, procedure: procedure_2
|
create :assign_to, gestionnaire: gestionnaire, procedure: procedure_2
|
||||||
30.times do
|
30.times do
|
||||||
Dossier.create(procedure_id: procedure_1.id.to_s, user: user, state: 'validated')
|
Dossier.create(procedure_id: procedure_1.id.to_s, user: user, state: 'initiated')
|
||||||
end
|
end
|
||||||
22.times do
|
22.times do
|
||||||
Dossier.create(procedure_id: procedure_2.id.to_s, user: user, state: 'validated')
|
Dossier.create(procedure_id: procedure_2.id.to_s, user: user, state: 'received')
|
||||||
end
|
end
|
||||||
login_as gestionnaire, scope: :gestionnaire
|
login_as gestionnaire, scope: :gestionnaire
|
||||||
visit backoffice_path
|
visit backoffice_path
|
||||||
|
|
|
@ -17,7 +17,6 @@ feature 'As a User I want to edit a dossier I own' do
|
||||||
expect(page.find('#a_traiter')['class'] ).to eq('active procedure_list_element')
|
expect(page.find('#a_traiter')['class'] ).to eq('active procedure_list_element')
|
||||||
page.find_by_id('brouillon').click
|
page.find_by_id('brouillon').click
|
||||||
page.find_by_id('a_traiter').click
|
page.find_by_id('a_traiter').click
|
||||||
page.find_by_id('valides').click
|
|
||||||
page.find_by_id('en_instruction').click
|
page.find_by_id('en_instruction').click
|
||||||
page.find_by_id('termine').click
|
page.find_by_id('termine').click
|
||||||
page.find_by_id('invite').click
|
page.find_by_id('invite').click
|
||||||
|
|
|
@ -9,8 +9,6 @@ feature 'on click on tabs button' do
|
||||||
create(:dossier, :with_entreprise, user: user, state: 'initiated')
|
create(:dossier, :with_entreprise, user: user, state: 'initiated')
|
||||||
create(:dossier, :with_entreprise, user: user, state: 'replied')
|
create(:dossier, :with_entreprise, user: user, state: 'replied')
|
||||||
create(:dossier, :with_entreprise, user: user, state: 'updated')
|
create(:dossier, :with_entreprise, user: user, state: 'updated')
|
||||||
create(:dossier, :with_entreprise, user: user, state: 'validated')
|
|
||||||
create(:dossier, :with_entreprise, user: user, state: 'submitted')
|
|
||||||
create(:dossier, :with_entreprise, user: user, state: 'received')
|
create(:dossier, :with_entreprise, user: user, state: 'received')
|
||||||
create(:dossier, :with_entreprise, user: user, state: 'closed')
|
create(:dossier, :with_entreprise, user: user, state: 'closed')
|
||||||
create(:dossier, :with_entreprise, user: user, state: 'refused')
|
create(:dossier, :with_entreprise, user: user, state: 'refused')
|
||||||
|
@ -33,21 +31,10 @@ feature 'on click on tabs button' do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when he click on tabs a deposes' do
|
|
||||||
before do
|
|
||||||
visit users_dossiers_url(liste: :valides)
|
|
||||||
page.click_on 'À déposer 1'
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'it redirect to users dossier deposes' do
|
|
||||||
expect(page).to have_css('#users_index')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when he click on tabs en examen' do
|
context 'when he click on tabs en examen' do
|
||||||
before do
|
before do
|
||||||
visit users_dossiers_url(liste: :en_instruction)
|
visit users_dossiers_url(liste: :en_instruction)
|
||||||
page.click_on 'En examen 2'
|
page.click_on 'En examen 1'
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'it redirect to users dossier termine' do
|
scenario 'it redirect to users dossier termine' do
|
||||||
|
|
|
@ -12,19 +12,6 @@ RSpec.describe NotificationMailer, type: :mailer do
|
||||||
it { expect(subject.subject).to eq("Nouveau message pour votre dossier TPS N°#{dossier.id}") }
|
it { expect(subject.subject).to eq("Nouveau message pour votre dossier TPS N°#{dossier.id}") }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe ".dossier_validated" do
|
|
||||||
let(:user) { create(:user) }
|
|
||||||
let(:dossier) { create(:dossier, user: user) }
|
|
||||||
|
|
||||||
subject(:subject) { described_class.dossier_validated(dossier) }
|
|
||||||
|
|
||||||
before { dossier.reload }
|
|
||||||
|
|
||||||
it { expect(subject.body).to match("Votre dossier N°#{dossier.id} est prêt à être déposé pour instruction.") }
|
|
||||||
it { expect(subject.body).to include("Afin de finaliser son dépôt, merci de vous rendre sur", users_dossier_recapitulatif_url(dossier_id: dossier.id)) }
|
|
||||||
it { expect(subject.subject).to eq("[TPS] Votre dossier TPS N°#{dossier.id} a été validé") }
|
|
||||||
end
|
|
||||||
|
|
||||||
describe ".dossier_submitted" do
|
describe ".dossier_submitted" do
|
||||||
let(:user) { create(:user) }
|
let(:user) { create(:user) }
|
||||||
let(:dossier) { create(:dossier, user: user) }
|
let(:dossier) { create(:dossier, user: user) }
|
||||||
|
|
|
@ -4,8 +4,4 @@ class NotificationMailerPreview < ActionMailer::Preview
|
||||||
NotificationMailer.dossier_received(Dossier.last)
|
NotificationMailer.dossier_received(Dossier.last)
|
||||||
end
|
end
|
||||||
|
|
||||||
def dossier_validated
|
|
||||||
NotificationMailer.dossier_validated(Dossier.last)
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -52,7 +52,6 @@ describe Procedure do
|
||||||
it { expect(subject.mail_templates.size).to eq 2 }
|
it { expect(subject.mail_templates.size).to eq 2 }
|
||||||
|
|
||||||
it { expect(subject.mail_received).not_to be_nil }
|
it { expect(subject.mail_received).not_to be_nil }
|
||||||
it { expect(subject.mail_validated).not_to be_nil }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue