Merge pull request #5364 from betagouv/dev

2020-07-12-01
This commit is contained in:
Paul Chavard 2020-07-12 11:33:45 +02:00 committed by GitHub
commit 66fbc6cfda
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 223 additions and 470 deletions

View file

@ -97,7 +97,7 @@ GEM
aes_key_wrap (1.0.1)
after_party (1.11.2)
anchored (1.1.0)
ast (2.4.1)
ast (2.4.0)
attr_required (1.0.1)
autoprefixer-rails (9.7.6)
execjs
@ -342,7 +342,7 @@ GEM
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json-jwt (1.13.0)
json-jwt (1.11.0)
activesupport (>= 4.2)
aes_key_wrap
bindata
@ -407,7 +407,7 @@ GEM
nenv (0.3.0)
netrc (0.11.0)
nio4r (2.5.2)
nokogiri (1.10.10)
nokogiri (1.10.9)
mini_portile2 (~> 2.4.0)
notiffany (0.1.3)
nenv (~> 0.1)
@ -442,9 +442,9 @@ GEM
validate_url
webfinger (>= 1.0.1)
orm_adapter (0.5.0)
parallel (1.19.2)
parser (2.7.1.4)
ast (~> 2.4.1)
parallel (1.19.1)
parser (2.7.1.0)
ast (~> 2.4.0)
pdf-core (0.7.0)
pg (1.2.3)
phonelib (0.6.43)
@ -480,17 +480,17 @@ GEM
pundit (2.1.0)
activesupport (>= 3.0.0)
raabro (1.1.6)
rack (2.2.3)
rack (2.0.9)
rack-attack (6.2.2)
rack (>= 1.0, < 3)
rack-mini-profiler (2.0.1)
rack (>= 1.2.0)
rack-oauth2 (1.15.0)
rack-oauth2 (1.12.0)
activesupport
attr_required
httpclient
json-jwt (>= 1.11.0)
rack (>= 2.1.0)
rack (< 2.1)
rack-protection (2.0.8.1)
rack
rack-proxy (0.6.5)

View file

@ -11,6 +11,10 @@
background-color: rgba(0, 0, 0, 0.08);
vertical-align: top;
&.baseline {
vertical-align: baseline;
}
&.warning {
background-color: $orange;
color: #FFFFFF;

View file

@ -317,3 +317,14 @@
.link {
color: $blue;
}
.card-admin-action-btn {
width: 90px;
height: 36px;
border-radius: 30px;
border: solid 1px #BBBBBB;
background: #FFFFFF;
cursor: pointer;
padding-left: 10px;
padding-right: 10px;
}

View file

@ -62,3 +62,46 @@
margin-bottom: $default-spacer;
}
}
.card-admin-list {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(236px, 1fr));
grid-gap: 20px;
margin: auto;
margin-bottom: 20px;
}
.card-admin {
padding-top: 10px;
padding-bottom: 10px;
width: 236px;
height: 200px;
border-radius: 4px;
border: solid 1px $border-grey;
text-align: center;
margin: auto;
display: flex;
flex-direction: column;
.card-admin-status-accept {
color: #50AA75;
}
.card-admin-status-todo {
color: #246AC5;
}
.card-admin-title {
font-weight: bold;
font-size: 18px;
margin-bottom: $default-spacer;
}
.card-admin-subtitle {
font-size: 14px;
}
.card-admin-action {
margin-top: auto;
}
}

View file

@ -12,6 +12,10 @@ module NewAdministrateur
@procedure ||= Procedure.new(for_individual: true)
end
def show
@procedure = current_administrateur.procedures.find(params[:id])
end
def edit
end

View file

@ -1,7 +1,7 @@
= render partial: 'new_administrateur/breadcrumbs',
locals: { steps: [link_to('Démarches', admin_procedures_path),
link_to(@procedure.libelle, admin_procedure_path(@procedure)),
link_to('MonAvis', admin_procedures_path)] }
'MonAvis'] }
.container
%h1.page-title

View file

@ -0,0 +1,136 @@
= render partial: 'new_administrateur/breadcrumbs',
locals: { steps: [link_to('Démarches', admin_procedures_path),
"#{@procedure.libelle} (crée le #{@procedure.created_at.strftime('%d/%m/%Y')})"] }
.container{ style: "text-align:right; margin-bottom: 20px" }
= button_to 'Publier la démarche', admin_procedure_publication_path(@procedure), method: :get, class: 'button primary',id: 'publish-procedure-link', disabled: @procedure.publiee? ? true : false
.container
%h2.explication-libelle{ style: "font-weight: bold; font-size: 20px; margin-bottom: 20px;" } Indispensable avant publication
.card-admin-list
.card-admin
%div
%span.icon.accept
%p.card-admin-status-accept Validé
%div
%p.card-admin-title Présentation
%p.card-admin-subtitle Logo, nom, description
.card-admin-action
= button_to 'Modifier', edit_admin_procedure_path(@procedure), method: :get, class: 'card-admin-action-btn', id: "presentation"
- if !@procedure.locked?
.card-admin
%div
%span.icon.clock
%p.card-admin-status-todo À faire
%div
%p.card-admin-title Formulaire
%p.card-admin-subtitle Champs à remplir par les usagers
.card-admin-action
= button_to 'Modifier', champs_admin_procedure_path(@procedure), method: :get, class: 'card-admin-action-btn'
.card-admin
- if @procedure.service_id.present?
%div
%span.icon.accept
%p.card-admin-status-accept Validé
- else
%div
%span.icon.clock
%p.card-admin-status-todo À faire
%div
%p.card-admin-title Service
%p.card-admin-subtitle Choix du service de la démarche
.card-admin-action
= button_to 'Modifier', new_admin_service_path, params: { procedure_id: @procedure.id }, method: :get, class: 'card-admin-action-btn'
.card-admin
%div
%span.icon.accept
%p.card-admin-status-accept Validé
%div
%p.card-admin-title
Administrateurs
%span.badge.baseline
= @procedure.administrateurs.count
%p.card-admin-subtitle Gestion de la démarche
.card-admin-action
= button_to 'Modifier', admin_procedure_administrateurs_path(@procedure), method: :get, class: 'card-admin-action-btn', id: "administrateurs"
.card-admin
- if @procedure.instructeurs.count > 1
%div
%span.icon.accept
%p.card-admin-status-accept Validé
- else
%div
%span.icon.clock
%p.card-admin-status-todo À faire
%div
%p.card-admin-title
= feature_enabled?(:administrateur_routage) ? "Groupe Instructeurs" : "Instructeurs"
%span.badge.baseline
= @procedure.instructeurs.count
%p.card-admin-subtitle Suivi des dossiers
.card-admin-action
- if feature_enabled?(:administrateur_routage)
= button_to 'Modifier', admin_procedure_groupe_instructeurs_path(@procedure), method: :get, class: 'card-admin-action-btn', id: "groupe-instructeurs"
- else
= button_to 'Modifier', admin_procedure_groupe_instructeur_path(@procedure, @procedure.defaut_groupe_instructeur), method: :get, class: 'card-admin-action-btn', id: "instructeurs"
%h2.explication-libelle{ style: "font-weight: bold; font-size: 20px; margin-bottom: 20px;" } Pour aller plus loin
.card-admin-list
.card-admin
- if @procedure.attestation_template.present?
%div
%span.icon.accept
%p.card-admin-status-accept Activée
- else
%div
%span.icon.clock
%p.card-admin-status-todo À activer
%div
%p.card-admin-title Attestation
%p.card-admin-subtitle Délivrance automatique pour les dossiers acceptés
.card-admin-action
= button_to 'Modifier', edit_admin_procedure_attestation_template_path(@procedure), method: :get, class: 'card-admin-action-btn'
.card-admin
%div
%span.icon.clock
%p.card-admin-status-todo À configurer
%div
%p.card-admin-title Configuration des emails
%p.card-admin-subtitle Notifications automatiques
.card-admin-action
= button_to 'Modifier', admin_procedure_mail_templates_path(@procedure), method: :get, class: 'card-admin-action-btn'
.card-admin
- if @procedure.api_entreprise_token.present?
%div
%span.icon.accept
%p.card-admin-status-accept Validé
- else
%div
%span.icon.clock
%p.card-admin-status-todo À configurer
%div
%p.card-admin-title Jeton
%p.card-admin-subtitle Configurer le jeton API entreprise
.card-admin-action
= button_to 'Modifier', jeton_admin_procedure_path(@procedure), method: :get, class: 'card-admin-action-btn'
.card-admin
- if @procedure.monavis_embed.present?
%div
%span.icon.accept
%p.card-admin-status-accept Validé
- else
%div
%span.icon.clock
%p.card-admin-status-todo À configurer
%div
%p.card-admin-title MonAvis
%p.card-admin-subtitle Avis des usagers sur votre démarche
.card-admin-action
= button_to 'Modifier', monavis_admin_procedure_path(@procedure), method: :get, class: 'card-admin-action-btn'

View file

@ -176,8 +176,9 @@ Rails.application.routes.draw do
patch 'activate' => '/administrateurs/activate#create'
get 'procedures/archived' => 'procedures#archived'
get 'procedures/draft' => 'procedures#draft'
get 'procedures/:id/publication' => 'procedures#show', as: :procedure_publication
resources :procedures, only: [:index, :show, :destroy] do
resources :procedures, only: [:index, :destroy] do
collection do
get 'new_from_existing' => 'procedures#new_from_existing', as: :new_from_existing
end
@ -370,7 +371,7 @@ Rails.application.routes.draw do
#
namespace :admin, module: 'new_administrateur' do
resources :procedures, except: [:index, :show, :destroy] do
resources :procedures, except: [:index, :destroy] do
member do
get 'apercu'
get 'champs'

View file

@ -1,14 +0,0 @@
namespace :after_party do
desc 'Deployment task: fix_macedonia'
task fix_macedonia: :environment do
rake_puts "Running deploy task 'fix_macedonia'"
# Put your task implementation HERE.
Champ.where(type: "Champs::PaysChamp", value: "EX-REPUBLIQUE YOUGOSLAVE DE MACEDOINE").update_all(value: "MACEDOINE DU NORD (REPUBLIQUE DE)")
# Update task as completed. If you remove the line below, the task will
# run with every deploy (or every time you call after_party:run).
AfterParty::TaskRecord.create version: '20190212164238'
end # task :fix_macedonia
end # namespace :after_party

View file

@ -1,17 +0,0 @@
namespace :after_party do
desc 'Deployment task: create_default_path_for_brouillons'
task create_default_path_for_brouillons: :environment do
rake_puts "Running deploy task 'create_default_path_for_brouillons'"
# Put your task implementation HERE.
Procedure.brouillons.where(path: nil).each do |p|
p.path = SecureRandom.uuid
p.save
end
# Update task as completed. If you remove the line below, the task will
# run with every deploy (or every time you call after_party:run).
AfterParty::TaskRecord.create version: '20190306172842'
end # task :create_default_path_for_brouillons
end # namespace :after_party

View file

@ -1,26 +0,0 @@
namespace :after_party do
desc 'Deployment task: migrate_mail_body_to_actiontext'
task migrate_mail_body_to_actiontext: :environment do
rake_puts "Running deploy task 'migrate_mail_body_to_actiontext'"
# Put your task implementation HERE.
[Mails::InitiatedMail, Mails::ReceivedMail, Mails::ClosedMail, Mails::WithoutContinuationMail, Mails::RefusedMail].each do |mt_class|
progress = ProgressReport.new(mt_class.all.count)
mt_class.all.each do |mt|
if mt.body.present?
mt.rich_body = mt.body
mt.save
end
progress.inc
end
progress.finish
end
# Update task as completed. If you remove the line below, the task will
# run with every deploy (or every time you call after_party:run).
AfterParty::TaskRecord.create version: '20190410131747'
end # task :migrate_mail_body_to_actiontext
end # namespace :after_party

View file

@ -1,18 +0,0 @@
namespace :after_party do
desc 'Deployment task: add_missing_dossier_id_to_repetitions'
task add_missing_dossier_id_to_repetitions: :environment do
rake_puts "Running deploy task 'add_missing_dossier_id_to_repetitions'"
champs = Champ.where(dossier_id: nil)
progress = ProgressReport.new(champs.count)
champs.find_each do |champ|
champ.update_column(:dossier_id, champ.parent.dossier_id)
progress.inc
end
progress.finish
# Update task as completed. If you remove the line below, the task will
# run with every deploy (or every time you call after_party:run).
AfterParty::TaskRecord.create version: '20190418144354'
end
end

View file

@ -1,22 +0,0 @@
namespace :after_party do
desc 'Deployment task: set_declarative_procedures'
task set_declarative_procedures: :environment do
rake_puts "Running deploy task 'set_declarative_procedures'"
Delayed::Job.where.not(cron: nil).find_each do |job|
job_data = YAML.load_dj(job.handler).job_data
if job_data['job_class'] == 'AutoReceiveDossiersForProcedureJob'
procedure_id, state = job_data['arguments']
procedure = Procedure.find(procedure_id)
procedure.declarative_with_state = state
procedure.save!
job.delete
end
end
# Update task as completed. If you remove the line below, the task will
# run with every deploy (or every time you call after_party:run).
AfterParty::TaskRecord.create version: '20190523122639'
end
end

View file

@ -1,10 +0,0 @@
namespace :after_party do
desc 'Deployment task: populate_user_instructeur_ids'
task populate_user_instructeur_ids: :environment do
Instructeur.find_each do |instructeur|
User.where(email: instructeur.email).update(instructeur_id: instructeur.id)
end
AfterParty::TaskRecord.create version: '20190808145006'
end
end

View file

@ -1,10 +0,0 @@
namespace :after_party do
desc 'Deployment task: populate_user_administrateur_ids'
task populate_user_administrateur_ids: :environment do
Administrateur.find_each do |administrateur|
User.where(email: administrateur.email).update(administrateur_id: administrateur.id)
end
AfterParty::TaskRecord.create version: '20190809074534'
end
end

View file

@ -1,30 +0,0 @@
namespace :after_party do
desc 'Deployment task: clean_procedure_presentation_from_followers_gestionnaires'
task clean_procedure_presentation_from_followers_gestionnaires: :environment do
ProcedurePresentation.find_each do |pp|
if pp.sort["table"] == "followers_gestionnaires"
pp.sort["table"] = "followers_instructeurs"
end
pp.displayed_fields.each do |df|
if df["table"] == "followers_gestionnaires"
df["table"] = "followers_instructeurs"
end
end
pp.filters.each do |(_name, values)|
values.each do |value|
if value["table"] == "followers_gestionnaires"
value["table"] = "followers_instructeurs"
end
end
end
begin
pp.save!
rescue StandardError
end
end
AfterParty::TaskRecord.create version: '20190819100424'
end
end

View file

@ -1,16 +0,0 @@
namespace :after_party do
desc 'Deployment task: create_default_groupe_instructeur'
task create_default_groupe_instructeur: :environment do
Procedure
.with_discarded
.left_outer_joins(:groupe_instructeurs)
.where('groupe_instructeurs.id is null')
.find_each do |procedure|
procedure.groupe_instructeurs.create(label: GroupeInstructeur::DEFAULT_LABEL)
end
# Update task as completed. If you remove the line below, the task will
# run with every deploy (or every time you call after_party:run).
AfterParty::TaskRecord.create version: '20190819142551'
end
end

View file

@ -1,15 +0,0 @@
namespace :after_party do
desc 'Deployment task: link_assign_and_groupe_instructeur'
task link_assign_and_groupe_instructeur: :environment do
AssignTo.find_each do |at|
GroupeInstructeur
.find_by(procedure_id: at.procedure_id)
&.assign_tos
&.push(at)
end
# Update task as completed. If you remove the line below, the task will
# run with every deploy (or every time you call after_party:run).
AfterParty::TaskRecord.create version: '20190819145528'
end
end

View file

@ -1,14 +0,0 @@
namespace :after_party do
desc 'Deployment task: rename_active_storage_attachments'
task rename_active_storage_attachments: :environment do
rake_puts "Running deploy task 'rename_active_storage_attachments'"
ActiveStorage::Attachment.where(name: 'logo_active_storage').update_all(name: 'logo')
ActiveStorage::Attachment.where(name: 'signature_active_storage').update_all(name: 'signature')
ActiveStorage::Attachment.where(name: 'pdf_active_storage').update_all(name: 'pdf')
# Update task as completed. If you remove the line below, the task will
# run with every deploy (or every time you call after_party:run).
AfterParty::TaskRecord.create version: '20190828130014'
end
end

View file

@ -1,17 +0,0 @@
namespace :after_party do
desc 'Deployment task: update_admin_last_sign_in_at'
task update_admin_last_sign_in_at: :environment do
sql = <<-SQL
UPDATE users
SET last_sign_in_at = administrateurs.updated_at
FROM administrateurs
WHERE administrateur_id = administrateurs.id
AND users.last_sign_in_at IS NULL
AND administrateurs.active = true
SQL
ActiveRecord::Base.connection.execute(sql)
AfterParty::TaskRecord.create version: '20191007124230'
end
end

View file

@ -1,15 +0,0 @@
namespace :after_party do
desc 'Deployment task: archivee_to_close'
task archivee_to_close: :environment do
puts "Running deploy task 'archivee_to_close'"
Procedure.where(aasm_state: :archivee).update_all(aasm_state: :close)
Procedure.where(aasm_state: :close, closed_at: nil).find_each do |procedure|
procedure.update_column(:closed_at, procedure.archived_at)
end
# Update task as completed. If you remove the line below, the task will
# run with every deploy (or every time you call after_party:run).
AfterParty::TaskRecord.create version: '20191114084623'
end
end

View file

@ -1,8 +0,0 @@
namespace :after_party do
desc 'Deployment task: enable_export_purge'
task enable_export_purge: :environment do
PurgeStaleExportsJob.set(cron: "*/5 * * * *").perform_later
AfterParty::TaskRecord.create version: '20191127135401'
end
end

View file

@ -1,7 +0,0 @@
namespace :after_party do
desc 'Deployment task: enable_seek_and_destroy_job'
task enable_seek_and_destroy_job: :environment do
SeekAndDestroyExpiredDossiersJob.set(cron: "0 7 * * *").perform_later
AfterParty::TaskRecord.create version: '20191203142402'
end
end

View file

@ -24,6 +24,7 @@ feature 'As an administrateur I wanna clone a procedure', js: true do
click_on Procedure.last.libelle
expect(page).to have_current_path(admin_procedure_path(Procedure.last))
find('#publish-procedure-link').click
find('#publish-procedure').click
within '#publish-modal' do

View file

@ -77,6 +77,7 @@ feature 'As an administrateur I wanna create a new procedure', js: true do
expect(page).to have_selector('#champ-1-libelle')
click_on Procedure.last.libelle
find('#publish-procedure-link').click
preview_window = window_opened_by { click_on 'onglet-preview' }
within_window(preview_window) do
@ -95,7 +96,7 @@ feature 'As an administrateur I wanna create a new procedure', js: true do
click_on Procedure.last.libelle
expect(page).to have_current_path(admin_procedure_path(Procedure.last))
find('#publish-procedure-link').click
expect(page).to have_content('en test')
# Only check the path even though the link is the complete URL
# (Capybara runs the app on an arbitrary host/port.)

View file

@ -3,7 +3,7 @@ feature 'procedure locked' do
before do
login_as administrateur.user, scope: :user
visit admin_procedure_path(procedure)
visit admin_procedure_publication_path(procedure)
end
context 'when procedure is not published' do

View file

@ -22,6 +22,7 @@ feature 'Publication de démarches', js: true do
scenario 'un administrateur peut la publier' do
visit admin_procedures_draft_path
click_on procedure.libelle
find('#publish-procedure-link').click
within "#procedure_show" do
click_on "Publier"
end
@ -51,6 +52,7 @@ feature 'Publication de démarches', js: true do
scenario 'un administrateur peut la publier' do
visit admin_procedures_archived_path
click_on procedure.libelle
find('#publish-procedure-link').click
within "#procedure_show" do
click_on "Réactiver"
end
@ -80,6 +82,7 @@ feature 'Publication de démarches', js: true do
scenario 'un administrateur peut la publier' do
visit admin_procedures_archived_path
click_on procedure.libelle
find('#publish-procedure-link').click
within "#procedure_show" do
click_on "Réactiver"
end

View file

@ -27,7 +27,7 @@ feature 'Administrateurs can edit procedures', js: true do
scenario 'the administrator can edit the libelle' do
visit admin_procedures_draft_path
click_on procedure.libelle
click_on 'Description'
find('#presentation').click
expect(page).to have_field('procedure_libelle', with: procedure.libelle)
@ -46,7 +46,7 @@ feature 'Administrateurs can edit procedures', js: true do
scenario 'the administrator can edit the libellé, but cant change the path' do
visit root_path
click_on procedure.libelle
click_on 'Description'
find('#presentation').click
expect(page).to have_field('procedure_libelle', with: procedure.libelle)
expect(page).not_to have_field('procedure_path')
@ -62,7 +62,7 @@ feature 'Administrateurs can edit procedures', js: true do
scenario 'the administrator can add another administrator' do
another_administrateur = create(:administrateur)
visit admin_procedure_path(procedure)
click_on 'Administrateurs'
find('#administrateurs').click
fill_in('administrateur_email', with: another_administrateur.email)

View file

@ -14,7 +14,7 @@ feature 'The routing', js: true do
login_as administrateur.user, scope: :user
visit admin_procedure_path(procedure.id)
click_on "Groupe d'instructeurs"
find('#groupe-instructeurs').click
# rename routing criteria to spécialité
fill_in 'Libellé du routage', with: 'spécialité'
@ -173,6 +173,7 @@ feature 'The routing', js: true do
def publish_procedure(procedure)
click_on procedure.libelle
find('#publish-procedure-link').click
find('#publish-procedure').click
within '#publish-modal' do
fill_in 'lien_site_web', with: 'http://some.website'

View file

View file

@ -1,24 +0,0 @@
describe '20190306172842_create_default_path_for_brouillons.rake' do
let(:rake_task) { Rake::Task['after_party:create_default_path_for_brouillons'] }
let(:administrateur) { create(:administrateur) }
let!(:procedure) { create(:procedure, administrateur: administrateur) }
let!(:procedure2) { create(:simple_procedure, administrateur: administrateur) }
before do
rake_task.invoke
administrateur.reload
end
after { rake_task.reenable }
it 'create a path for his brouillon procedure' do
expect(administrateur.procedures.brouillon.count).to eq(1)
expect(administrateur.procedures.brouillon.first.path).not_to eq(nil)
end
it 'does not change the path of his published procedure' do
expect(administrateur.procedures.publiee.count).to eq(1)
expect(administrateur.procedures.publiee.first.path).to eq(procedure2.path)
end
end

View file

@ -1,24 +0,0 @@
describe '20190410131747_migrate_mail_body_to_actiontext.rake' do
let(:rake_task) { Rake::Task['after_party:migrate_mail_body_to_actiontext'] }
let!(:closed_mail) { create(:closed_mail, body: body) }
before do
rake_task.invoke
closed_mail.reload
end
after { rake_task.reenable }
context 'with a plain text body' do
let(:body) { "Test de body" }
it { expect(closed_mail.rich_body.to_plain_text).to eq(closed_mail.body) }
end
context 'with a html text body' do
let(:body) { "Test de body<br>" }
it { expect(closed_mail.rich_body.to_s.squish).to eq("<div class=\"trix-content\"> #{closed_mail.body} </div>".squish) }
end
end

View file

@ -1,84 +0,0 @@
describe '20190819100424_clean_procedure_presentation_from_followers_gestionnaires.rake' do
let(:rake_task) { Rake::Task['after_party:clean_procedure_presentation_from_followers_gestionnaires'] }
let(:procedure) { create(:procedure, :with_type_de_champ, :with_type_de_champ_private) }
let(:assign_to) { create(:assign_to, procedure: procedure) }
let!(:procedure_presentation) do
pp = ProcedurePresentation.new(
assign_to: assign_to,
sort: {
"order" => "asc",
"table" => "followers_gestionnaires",
"column" => "email"
},
filters: {
"tous" => [],
"suivis" => [],
"traites" => [{
"label" => "Email instructeur",
"table" => "followers_gestionnaires",
"value" => "mail@simon.lehericey.net",
"column" => "email"
}
],
"a-suivre" => [],
"archives" => []
},
displayed_fields: [
{
"column" => "email",
"label" => "Demandeur",
"table" => "user"
},
{
"column" => "email",
"label" => "Email instructeur",
"table" => "followers_gestionnaires"
}
]
)
pp.save(validate: false)
pp
end
before do
rake_task.invoke
procedure_presentation.reload
end
after { rake_task.reenable }
it do
expect(procedure_presentation.displayed_fields[1]["table"]).to eq("followers_instructeurs")
expect(procedure_presentation.sort["table"]).to eq("followers_instructeurs")
expect(procedure_presentation.filters["traites"][0]["table"]).to eq("followers_instructeurs")
end
context 'with an invalid procedure_presentation' do
let!(:procedure_presentation) do
pp = ProcedurePresentation.new(
assign_to: assign_to,
filters: {
"tous" => [],
"suivis" => [],
"traites" => [{
"label" => "Email instructeur",
"table" => "invalid table",
"value" => "mail@simon.lehericey.net",
"column" => "email"
}
],
"a-suivre" => [],
"archives" => []
},
displayed_fields: []
)
pp.save(validate: false)
pp
end
it 'does not stop the script' do
end
end
end

View file

@ -1,45 +0,0 @@
describe '20190819142551_create_default_groupe_instructeur.rake' do
let(:rake_task) { Rake::Task['after_party:create_default_groupe_instructeur'] }
subject { rake_task.invoke }
after { rake_task.reenable }
context 'with a procedure without gi' do
let!(:procedure_without_gi) { create(:procedure) }
before do
procedure_without_gi.groupe_instructeurs.destroy_all
end
it do
expect(procedure_without_gi.groupe_instructeurs).to be_empty
subject
expect(procedure_without_gi.reload.groupe_instructeurs.pluck(:label)).to eq(['défaut'])
end
end
context 'with a procedure discarded without gi' do
let!(:procedure_discarded_without_gi) { create(:procedure, :discarded) }
before do
procedure_discarded_without_gi.groupe_instructeurs.destroy_all
end
it do
expect(procedure_discarded_without_gi.groupe_instructeurs).to be_empty
subject
expect(procedure_discarded_without_gi.reload.groupe_instructeurs.pluck(:label)).to eq(['défaut'])
end
end
context 'with a procedure with a gi' do
let!(:procedure_with_gi) { create(:procedure) }
it do
gi = procedure_with_gi.groupe_instructeurs.first
expect(gi).to be_present
subject
expect(procedure_with_gi.reload.groupe_instructeurs).to eq([gi])
end
end
end

View file

@ -1,36 +0,0 @@
describe '20190819145528_link_assign_and_groupe_instructeur.rake' do
let(:rake_task) { Rake::Task['after_party:link_assign_and_groupe_instructeur'] }
subject { rake_task.invoke }
after { rake_task.reenable }
context 'with an assign_to without groupe_instructeur' do
let!(:procedure) { create(:procedure) }
let!(:instructeur) { create(:instructeur) }
let!(:assign_to) do
at = AssignTo.create!(instructeur: instructeur)
at.update_column(:procedure_id, procedure.id)
at
end
it 'assigns its defaut groupe instructeur' do
expect(assign_to.groupe_instructeur).to be_nil
subject
expect(assign_to.reload.groupe_instructeur).to eq(procedure.defaut_groupe_instructeur)
end
end
context 'with an assign_to with groupe_instructeur' do
let!(:procedure) { create(:procedure) }
let!(:instructeur) { create(:instructeur, groupe_instructeurs: [procedure.defaut_groupe_instructeur]) }
let!(:assign_to) { instructeur.assign_to.first }
it 'assigns its defaut groupe instructeur' do
expect(assign_to.groupe_instructeur).to eq(procedure.defaut_groupe_instructeur)
expect(procedure.reload.defaut_groupe_instructeur.assign_tos.count).to eq(1)
subject
expect(instructeur.assign_to).to eq([assign_to])
expect(procedure.reload.defaut_groupe_instructeur.assign_tos.count).to eq(1)
end
end
end