Merge branch 'dev'
This commit is contained in:
commit
513a38371d
18 changed files with 158 additions and 67 deletions
|
@ -1,7 +1,7 @@
|
||||||
version: 2
|
version: 2
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
parallelism: 2
|
parallelism: 3
|
||||||
docker:
|
docker:
|
||||||
- image: ruby:2.3.1
|
- image: ruby:2.3.1
|
||||||
- image: postgres:9.4.1
|
- image: postgres:9.4.1
|
||||||
|
|
2
Gemfile
2
Gemfile
|
@ -109,6 +109,8 @@ gem 'prawn_rails', '~> 0.0.11'
|
||||||
gem 'chunky_png'
|
gem 'chunky_png'
|
||||||
gem 'sentry-raven'
|
gem 'sentry-raven'
|
||||||
|
|
||||||
|
gem 'rack-mini-profiler'
|
||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
gem 'capybara'
|
gem 'capybara'
|
||||||
gem 'launchy'
|
gem 'launchy'
|
||||||
|
|
|
@ -448,6 +448,8 @@ GEM
|
||||||
rack (2.0.1)
|
rack (2.0.1)
|
||||||
rack-handlers (0.7.3)
|
rack-handlers (0.7.3)
|
||||||
rack
|
rack
|
||||||
|
rack-mini-profiler (0.10.5)
|
||||||
|
rack (>= 1.2.0)
|
||||||
rack-oauth2 (1.4.0)
|
rack-oauth2 (1.4.0)
|
||||||
activesupport (>= 2.3)
|
activesupport (>= 2.3)
|
||||||
attr_required (>= 0.0.5)
|
attr_required (>= 0.0.5)
|
||||||
|
@ -725,6 +727,7 @@ DEPENDENCIES
|
||||||
prawn_rails (~> 0.0.11)
|
prawn_rails (~> 0.0.11)
|
||||||
pry-byebug
|
pry-byebug
|
||||||
rack-handlers
|
rack-handlers
|
||||||
|
rack-mini-profiler
|
||||||
rails (= 5.0.0.1)
|
rails (= 5.0.0.1)
|
||||||
rails-controller-testing
|
rails-controller-testing
|
||||||
redis
|
redis
|
||||||
|
|
|
@ -16,12 +16,3 @@ html {
|
||||||
a {
|
a {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove dotted outline on firefox
|
|
||||||
:focus {
|
|
||||||
outline: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
::-moz-focus-inner {
|
|
||||||
border: none;
|
|
||||||
}
|
|
||||||
|
|
|
@ -5,6 +5,13 @@ class ApplicationController < ActionController::Base
|
||||||
before_action :check_browser
|
before_action :check_browser
|
||||||
before_action :load_navbar_left_pannel_partial_url
|
before_action :load_navbar_left_pannel_partial_url
|
||||||
before_action :set_raven_context
|
before_action :set_raven_context
|
||||||
|
before_action :authorize_request_for_profiler
|
||||||
|
|
||||||
|
def authorize_request_for_profiler
|
||||||
|
if Rails.env.production? && administration_signed_in?
|
||||||
|
Rack::MiniProfiler.authorize_request
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def default_url_options
|
def default_url_options
|
||||||
return {protocol: 'https'} if Rails.env.staging? || Rails.env.production?
|
return {protocol: 'https'} if Rails.env.staging? || Rails.env.production?
|
||||||
|
|
|
@ -4,18 +4,10 @@ class Backoffice::AvisController < ApplicationController
|
||||||
before_action :check_avis_exists_and_email_belongs_to_avis, only: [:sign_up, :create_gestionnaire]
|
before_action :check_avis_exists_and_email_belongs_to_avis, only: [:sign_up, :create_gestionnaire]
|
||||||
|
|
||||||
def create
|
def create
|
||||||
avis = Avis.new(create_params.merge(claimant: current_gestionnaire))
|
avis = Avis.new(create_params.merge(claimant: current_gestionnaire, dossier: dossier))
|
||||||
avis.dossier = dossier
|
|
||||||
|
|
||||||
email = create_params[:email]
|
|
||||||
gestionnaire = Gestionnaire.find_by(email: email)
|
|
||||||
if gestionnaire
|
|
||||||
avis.gestionnaire = gestionnaire
|
|
||||||
avis.email = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
if avis.save
|
if avis.save
|
||||||
flash[:notice] = "Votre demande d'avis a bien été envoyée à #{email}"
|
flash[:notice] = "Votre demande d'avis a bien été envoyée à #{create_params[:email]}"
|
||||||
end
|
end
|
||||||
|
|
||||||
redirect_to backoffice_dossier_path(dossier)
|
redirect_to backoffice_dossier_path(dossier)
|
||||||
|
|
|
@ -82,7 +82,7 @@ class Users::DossiersController < UsersController
|
||||||
individual.update_column :gender, @facade.dossier.france_connect_information.gender
|
individual.update_column :gender, @facade.dossier.france_connect_information.gender
|
||||||
individual.update_column :nom, @facade.dossier.france_connect_information.family_name
|
individual.update_column :nom, @facade.dossier.france_connect_information.family_name
|
||||||
individual.update_column :prenom, @facade.dossier.france_connect_information.given_name
|
individual.update_column :prenom, @facade.dossier.france_connect_information.given_name
|
||||||
individual.update_column :birthdate, @facade.dossier.france_connect_information.birthdate.strftime("%d/%m/%Y")
|
individual.update_column :birthdate, @facade.dossier.france_connect_information.birthdate.iso8601
|
||||||
end
|
end
|
||||||
|
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
@ -131,7 +131,10 @@ class Users::DossiersController < UsersController
|
||||||
def update
|
def update
|
||||||
@facade = facade params[:dossier][:id]
|
@facade = facade params[:dossier][:id]
|
||||||
|
|
||||||
if checked_autorisation_donnees?
|
if individual_errors.any?
|
||||||
|
flash.alert = individual_errors
|
||||||
|
redirect_to users_dossier_path(id: @facade.dossier.id)
|
||||||
|
else
|
||||||
unless Dossier.find(@facade.dossier.id).update_attributes update_params_with_formatted_birthdate
|
unless Dossier.find(@facade.dossier.id).update_attributes update_params_with_formatted_birthdate
|
||||||
flash.alert = @facade.dossier.errors.full_messages
|
flash.alert = @facade.dossier.errors.full_messages
|
||||||
|
|
||||||
|
@ -143,9 +146,6 @@ class Users::DossiersController < UsersController
|
||||||
else
|
else
|
||||||
redirect_to url_for(controller: :description, action: :show, dossier_id: @facade.dossier.id)
|
redirect_to url_for(controller: :description, action: :show, dossier_id: @facade.dossier.id)
|
||||||
end
|
end
|
||||||
else
|
|
||||||
flash.alert = 'Les conditions sont obligatoires.'
|
|
||||||
redirect_to users_dossier_path(id: @facade.dossier.id)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -191,24 +191,35 @@ class Users::DossiersController < UsersController
|
||||||
def update_params_with_formatted_birthdate
|
def update_params_with_formatted_birthdate
|
||||||
editable_params = update_params
|
editable_params = update_params
|
||||||
|
|
||||||
# If the user was shown a date input field (if its browser supports it),
|
|
||||||
# the returned param will follow the YYYY-MM-DD pattern, which we need
|
|
||||||
# do convert to the DD/MM/YYYY pattern we use
|
|
||||||
if editable_params &&
|
if editable_params &&
|
||||||
editable_params[:individual_attributes] &&
|
editable_params[:individual_attributes] &&
|
||||||
editable_params[:individual_attributes][:birthdate] &&
|
editable_params[:individual_attributes][:birthdate]
|
||||||
editable_params[:individual_attributes][:birthdate] =~ /^[0-9]{4}-[0-9]{2}-[0-9]{2}$/
|
|
||||||
|
|
||||||
original_birthdate = editable_params[:individual_attributes][:birthdate]
|
iso_date = begin
|
||||||
formatted_birthdate = I18n.l(original_birthdate.to_date, format: '%d/%m/%Y')
|
Date.parse(editable_params[:individual_attributes][:birthdate]).iso8601
|
||||||
editable_params[:individual_attributes][:birthdate] = formatted_birthdate
|
rescue
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
editable_params[:individual_attributes][:birthdate] = iso_date
|
||||||
end
|
end
|
||||||
|
|
||||||
editable_params
|
editable_params
|
||||||
end
|
end
|
||||||
|
|
||||||
def checked_autorisation_donnees?
|
def individual_errors
|
||||||
update_params[:autorisation_donnees] == '1'
|
errors = []
|
||||||
|
|
||||||
|
if update_params[:autorisation_donnees] != "1"
|
||||||
|
errors << "La validation des conditions d'utilisation est obligatoire"
|
||||||
|
end
|
||||||
|
|
||||||
|
if update_params[:individual_attributes].present? &&
|
||||||
|
!/^\d{4}\-\d{2}\-\d{2}$/.match(update_params[:individual_attributes][:birthdate]) &&
|
||||||
|
!/^\d{2}\/\d{2}\/\d{4}$/.match(update_params[:individual_attributes][:birthdate])
|
||||||
|
errors << "Le format de la date de naissance doit être JJ/MM/AAAA"
|
||||||
|
end
|
||||||
|
|
||||||
|
errors
|
||||||
end
|
end
|
||||||
|
|
||||||
def siret
|
def siret
|
||||||
|
|
|
@ -3,6 +3,7 @@ class Avis < ApplicationRecord
|
||||||
belongs_to :gestionnaire
|
belongs_to :gestionnaire
|
||||||
belongs_to :claimant, class_name: 'Gestionnaire'
|
belongs_to :claimant, class_name: 'Gestionnaire'
|
||||||
|
|
||||||
|
before_create :try_to_assign_gestionnaire
|
||||||
after_create :notify_gestionnaire
|
after_create :notify_gestionnaire
|
||||||
|
|
||||||
scope :with_answer, -> { where.not(answer: nil) }
|
scope :with_answer, -> { where.not(answer: nil) }
|
||||||
|
@ -14,10 +15,6 @@ class Avis < ApplicationRecord
|
||||||
gestionnaire.try(:email) || email
|
gestionnaire.try(:email) || email
|
||||||
end
|
end
|
||||||
|
|
||||||
def notify_gestionnaire
|
|
||||||
AvisMailer.avis_invitation(self).deliver_now
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.link_avis_to_gestionnaire(gestionnaire)
|
def self.link_avis_to_gestionnaire(gestionnaire)
|
||||||
Avis.where(email: gestionnaire.email).update_all(email: nil, gestionnaire_id: gestionnaire.id)
|
Avis.where(email: gestionnaire.email).update_all(email: nil, gestionnaire_id: gestionnaire.id)
|
||||||
end
|
end
|
||||||
|
@ -26,4 +23,18 @@ class Avis < ApplicationRecord
|
||||||
avis = Avis.find_by(id: avis_id)
|
avis = Avis.find_by(id: avis_id)
|
||||||
avis.present? && avis.email == email
|
avis.present? && avis.email == email
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def notify_gestionnaire
|
||||||
|
AvisMailer.avis_invitation(self).deliver_now
|
||||||
|
end
|
||||||
|
|
||||||
|
def try_to_assign_gestionnaire
|
||||||
|
gestionnaire = Gestionnaire.find_by(email: email)
|
||||||
|
if gestionnaire
|
||||||
|
self.gestionnaire = gestionnaire
|
||||||
|
self.email = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -58,7 +58,7 @@ class Champ < ActiveRecord::Base
|
||||||
|
|
||||||
def format_date_to_iso
|
def format_date_to_iso
|
||||||
date = begin
|
date = begin
|
||||||
Date.parse(value).strftime("%F")
|
Date.parse(value).iso8601
|
||||||
rescue
|
rescue
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,4 +2,5 @@ class Individual < ActiveRecord::Base
|
||||||
belongs_to :dossier
|
belongs_to :dossier
|
||||||
|
|
||||||
validates_uniqueness_of :dossier_id
|
validates_uniqueness_of :dossier_id
|
||||||
|
validates :birthdate, format: { with: /\A\d{4}\-\d{2}\-\d{2}\z/, message: "La date n'est pas au format AAAA-MM-JJ" }, allow_nil: true
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
%label
|
%label
|
||||||
%h4
|
%h4
|
||||||
Date de naissance *
|
Date de naissance *
|
||||||
= ff.date_field :birthdate, { class: 'form-control', placeholder: 'jj/mm/aaaa', required: true }
|
= ff.date_field :birthdate, { value: @facade.individual.birthdate, class: 'form-control', placeholder: 'jj/mm/aaaa', required: true }
|
||||||
|
|
||||||
%p
|
%p
|
||||||
%label{ style: 'font-weight: normal;' }
|
%label{ style: 'font-weight: normal;' }
|
||||||
|
|
27
lib/tasks/2017_07_26_clean_birthdate_on_individual.rake
Normal file
27
lib/tasks/2017_07_26_clean_birthdate_on_individual.rake
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
namespace :'2017_07_26_clean_birthdate_on_individual' do
|
||||||
|
task clean: :environment do
|
||||||
|
# remove duplicates
|
||||||
|
duplicate_individuals = Individual.group("dossier_id").count.select{ |_dossier_id, count| count > 1 }.keys
|
||||||
|
duplicate_individuals.each { |dossier_id| Individual.where(dossier_id: dossier_id, nom: nil).delete_all }
|
||||||
|
|
||||||
|
# Match "" => nil
|
||||||
|
Individual.where(birthdate: "").update_all(birthdate: nil)
|
||||||
|
|
||||||
|
individuals_with_date = Individual.where.not(birthdate: nil)
|
||||||
|
# Match 31/12/2017 => 2017-12-31
|
||||||
|
individuals_with_date.select { |i| /^\d{2}\/\d{2}\/\d{4}$/.match(i.birthdate) }.each do |i|
|
||||||
|
puts "cleaning #{i.birthdate}"
|
||||||
|
i.update(birthdate: Date.parse(i.birthdate).iso8601) rescue nil
|
||||||
|
end
|
||||||
|
|
||||||
|
# Match 31/12/17 => 2017-12-31
|
||||||
|
individuals_with_date.select { |i| /^\d{2}\/\d{2}\/\d{2}$/.match(i.birthdate) }.each do |i|
|
||||||
|
puts "cleaning #{i.birthdate}"
|
||||||
|
new_date = Date.strptime(i.birthdate, "%d/%m/%y")
|
||||||
|
if new_date.year > 2017
|
||||||
|
new_date = new_date - 100.year
|
||||||
|
end
|
||||||
|
i.update(birthdate: new_date.iso8601)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -2,32 +2,38 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe Backoffice::AvisController, type: :controller do
|
describe Backoffice::AvisController, type: :controller do
|
||||||
describe '#POST create' do
|
describe '#POST create' do
|
||||||
|
let(:claimant){ create(:gestionnaire) }
|
||||||
let(:gestionnaire){ create(:gestionnaire) }
|
let(:gestionnaire){ create(:gestionnaire) }
|
||||||
let!(:dossier){ create(:dossier, state: 'received') }
|
let!(:dossier) do
|
||||||
let!(:assign_to){ create(:assign_to, gestionnaire: gestionnaire, procedure: dossier.procedure )}
|
dossier = create(:dossier, state: 'received')
|
||||||
|
claimant.procedures << [dossier.procedure]
|
||||||
|
dossier
|
||||||
|
end
|
||||||
|
|
||||||
subject { post :create, params: { dossier_id: dossier.id, avis: { email: gestionnaire.email, introduction: "Bonjour, regardez ce joli dossier." } } }
|
subject do
|
||||||
|
post :create, params: { dossier_id: dossier.id, avis: { email: gestionnaire.email, introduction: "Bonjour, regardez ce joli dossier." } }
|
||||||
|
end
|
||||||
|
|
||||||
context 'when gestionnaire is not authenticated' do
|
context 'when gestionnaire is not authenticated' do
|
||||||
it { is_expected.to redirect_to new_user_session_path }
|
before { subject }
|
||||||
it { expect{ subject }.to_not change(Avis, :count) }
|
|
||||||
|
it { expect(response).to redirect_to new_user_session_path }
|
||||||
|
it { expect(Avis.count).to eq(0) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when gestionnaire is authenticated' do
|
context 'when gestionnaire is authenticated' do
|
||||||
|
let(:created_avis) { Avis.last }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
sign_in gestionnaire
|
sign_in claimant
|
||||||
|
subject
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'When gestionnaire is known' do
|
it { expect(response).to redirect_to backoffice_dossier_path(dossier.id) }
|
||||||
it { is_expected.to redirect_to backoffice_dossier_path(dossier.id) }
|
it { expect(Avis.count).to eq(1) }
|
||||||
it { expect{ subject }.to change(Avis, :count).by(1) }
|
it { expect(created_avis.dossier_id).to eq(dossier.id) }
|
||||||
it do
|
it { expect(created_avis.gestionnaire).to eq(gestionnaire) }
|
||||||
subject
|
it { expect(created_avis.claimant).to eq(claimant) }
|
||||||
expect(gestionnaire.avis.last).to_not eq(nil)
|
|
||||||
expect(gestionnaire.avis.last.email).to eq(nil)
|
|
||||||
expect(gestionnaire.avis.last.dossier_id).to eq(dossier.id)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ describe StatsController, type: :controller do
|
||||||
FactoryGirl.create(:procedure, :created_at => 2.months.ago, :updated_at => 62.days.ago)
|
FactoryGirl.create(:procedure, :created_at => 2.months.ago, :updated_at => 62.days.ago)
|
||||||
FactoryGirl.create(:procedure, :created_at => 2.months.ago, :updated_at => 62.days.ago)
|
FactoryGirl.create(:procedure, :created_at => 2.months.ago, :updated_at => 62.days.ago)
|
||||||
FactoryGirl.create(:procedure, :created_at => 2.months.ago, :updated_at => 31.days.ago)
|
FactoryGirl.create(:procedure, :created_at => 2.months.ago, :updated_at => 31.days.ago)
|
||||||
FactoryGirl.create(:procedure, :created_at => 2.months.ago, :updated_at => 1.day.ago)
|
FactoryGirl.create(:procedure, :created_at => 2.months.ago, :updated_at => Time.now)
|
||||||
@controller = StatsController.new
|
@controller = StatsController.new
|
||||||
|
|
||||||
allow(@controller).to receive(:administration_signed_in?).and_return(false)
|
allow(@controller).to receive(:administration_signed_in?).and_return(false)
|
||||||
|
@ -18,7 +18,7 @@ describe StatsController, type: :controller do
|
||||||
|
|
||||||
subject { @controller.send(:last_four_months_hash, association, :updated_at) }
|
subject { @controller.send(:last_four_months_hash, association, :updated_at) }
|
||||||
|
|
||||||
it { expect(subject).to eq([
|
it { expect(subject).to match_array([
|
||||||
[I18n.l(62.days.ago.beginning_of_month, format: "%B %Y"), 2],
|
[I18n.l(62.days.ago.beginning_of_month, format: "%B %Y"), 2],
|
||||||
[I18n.l(31.days.ago.beginning_of_month, format: "%B %Y"), 1]
|
[I18n.l(31.days.ago.beginning_of_month, format: "%B %Y"), 1]
|
||||||
])
|
])
|
||||||
|
|
|
@ -358,7 +358,9 @@ describe Users::DossiersController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'PUT #update' do
|
describe 'PUT #update' do
|
||||||
let(:params) { {id: dossier_id, dossier: {id: dossier_id, autorisation_donnees: autorisation_donnees}} }
|
let(:params) { { id: dossier_id, dossier: { id: dossier_id, autorisation_donnees: autorisation_donnees, individual_attributes: individual_params } } }
|
||||||
|
let(:individual_params) { { gender: 'M.', nom: 'Julien', prenom: 'Xavier', birthdate: birthdate } }
|
||||||
|
let(:birthdate) { '20/01/1991' }
|
||||||
subject { put :update, params: params }
|
subject { put :update, params: params }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
@ -367,8 +369,7 @@ describe Users::DossiersController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when procedure is for individual' do
|
context 'when procedure is for individual' do
|
||||||
let(:params) { {id: dossier_id, dossier: {id: dossier_id, autorisation_donnees: '1', individual_attributes: individual_params}} }
|
let(:autorisation_donnees) { "1" }
|
||||||
let(:individual_params) { {gender: 'M.', nom: 'Julien', prenom: 'Xavier', birthdate: '20/01/1991'} }
|
|
||||||
let(:procedure) { create(:procedure, :published, for_individual: true) }
|
let(:procedure) { create(:procedure, :published, for_individual: true) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
@ -378,8 +379,16 @@ describe Users::DossiersController, type: :controller do
|
||||||
it { expect(dossier.individual.gender).to eq 'M.' }
|
it { expect(dossier.individual.gender).to eq 'M.' }
|
||||||
it { expect(dossier.individual.nom).to eq 'Julien' }
|
it { expect(dossier.individual.nom).to eq 'Julien' }
|
||||||
it { expect(dossier.individual.prenom).to eq 'Xavier' }
|
it { expect(dossier.individual.prenom).to eq 'Xavier' }
|
||||||
it { expect(dossier.individual.birthdate).to eq '20/01/1991' }
|
it { expect(dossier.individual.birthdate).to eq '1991-01-20' }
|
||||||
it { expect(dossier.procedure.for_individual).to eq true }
|
it { expect(dossier.procedure.for_individual).to eq true }
|
||||||
|
|
||||||
|
context "and birthdate is ISO (YYYY-MM-DD) formatted" do
|
||||||
|
let(:birthdate) { "1991-11-01" }
|
||||||
|
before do
|
||||||
|
dossier.reload
|
||||||
|
end
|
||||||
|
it { expect(dossier.individual.birthdate).to eq '1991-11-01' }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when Checkbox is checked' do
|
context 'when Checkbox is checked' do
|
||||||
|
@ -411,7 +420,7 @@ describe Users::DossiersController, type: :controller do
|
||||||
context 'when Checkbox is not checked' do
|
context 'when Checkbox is not checked' do
|
||||||
let(:autorisation_donnees) { '0' }
|
let(:autorisation_donnees) { '0' }
|
||||||
it 'uses flash alert to display message' do
|
it 'uses flash alert to display message' do
|
||||||
expect(flash[:alert]).to have_content('Les conditions sont obligatoires.')
|
expect(flash[:alert]).to have_content('La validation des conditions d\'utilisation est obligatoire')
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't update dossier autorisation_donnees" do
|
it "doesn't update dossier autorisation_donnees" do
|
||||||
|
|
|
@ -3,6 +3,6 @@ FactoryGirl.define do
|
||||||
gender 'M.'
|
gender 'M.'
|
||||||
nom 'Julien'
|
nom 'Julien'
|
||||||
prenom 'Xavier'
|
prenom 'Xavier'
|
||||||
birthdate '20/01/1991'
|
birthdate '1991-11-01'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -25,7 +25,7 @@ feature 'As a User I wanna create a dossier' do
|
||||||
page.find_by_id('etape_suivante').click
|
page.find_by_id('etape_suivante').click
|
||||||
fill_in "champs_#{procedure_for_individual.dossiers.last.champs.first.id}", with: 'contenu du champ 1'
|
fill_in "champs_#{procedure_for_individual.dossiers.last.champs.first.id}", with: 'contenu du champ 1'
|
||||||
page.find_by_id('suivant').click
|
page.find_by_id('suivant').click
|
||||||
expect(user.dossiers.first.individual.birthdate).to eq("14/10/1987")
|
expect(user.dossiers.first.individual.birthdate).to eq("1987-10-14")
|
||||||
expect(page).to have_current_path(users_dossier_recapitulatif_path(procedure_for_individual.dossiers.last.id.to_s), only_path: true)
|
expect(page).to have_current_path(users_dossier_recapitulatif_path(procedure_for_individual.dossiers.last.id.to_s), only_path: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ feature 'As a User I wanna create a dossier' do
|
||||||
page.find_by_id('etape_suivante').click
|
page.find_by_id('etape_suivante').click
|
||||||
fill_in "champs_#{procedure_for_individual.dossiers.last.champs.first.id}", with: 'contenu du champ 1'
|
fill_in "champs_#{procedure_for_individual.dossiers.last.champs.first.id}", with: 'contenu du champ 1'
|
||||||
page.find_by_id('suivant').click
|
page.find_by_id('suivant').click
|
||||||
expect(user.dossiers.first.individual.birthdate).to eq("14/10/1987")
|
expect(user.dossiers.first.individual.birthdate).to eq("1987-10-14")
|
||||||
expect(page).to have_current_path(users_dossier_recapitulatif_path(procedure_for_individual.dossiers.last.id.to_s), only_path: true)
|
expect(page).to have_current_path(users_dossier_recapitulatif_path(procedure_for_individual.dossiers.last.id.to_s), only_path: true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -86,4 +86,35 @@ RSpec.describe Avis, type: :model do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#notify_gestionnaire' do
|
||||||
|
context 'when an avis is created' do
|
||||||
|
before do
|
||||||
|
avis_invitation_double = double('avis_invitation', deliver_now: true)
|
||||||
|
allow(AvisMailer).to receive(:avis_invitation).and_return(avis_invitation_double)
|
||||||
|
Avis.create(claimant: claimant, email: 'email@l.com')
|
||||||
|
end
|
||||||
|
|
||||||
|
it { expect(AvisMailer).to have_received(:avis_invitation) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '#try_to_assign_gestionnaire' do
|
||||||
|
let!(:gestionnaire) { create(:gestionnaire) }
|
||||||
|
let(:avis) { Avis.create(claimant: claimant, email: email, dossier: create(:dossier)) }
|
||||||
|
|
||||||
|
context 'when the email belongs to a gestionnaire' do
|
||||||
|
let(:email) { gestionnaire.email }
|
||||||
|
|
||||||
|
it { expect(avis.gestionnaire).to eq(gestionnaire) }
|
||||||
|
it { expect(avis.email).to be_nil }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when the email does not belongs to a gestionnaire' do
|
||||||
|
let(:email) { 'unknown@email' }
|
||||||
|
|
||||||
|
it { expect(avis.gestionnaire).to be_nil }
|
||||||
|
it { expect(avis.email).to eq(email) }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue