Merge pull request #4452 from betagouv/dev

2019-10-29-01
This commit is contained in:
LeSim 2019-10-29 11:04:43 +01:00 committed by GitHub
commit 28acdfd36a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 205 additions and 103 deletions

View file

@ -4,7 +4,7 @@ gem 'aasm'
gem 'actiontext', git: 'https://github.com/kobaltz/actiontext.git', branch: 'archive', require: 'action_text' # Port of ActionText to Rails 5 gem 'actiontext', git: 'https://github.com/kobaltz/actiontext.git', branch: 'archive', require: 'action_text' # Port of ActionText to Rails 5
gem 'active_link_to' # Automatically set a class on active links gem 'active_link_to' # Automatically set a class on active links
gem 'active_model_serializers' gem 'active_model_serializers'
gem 'activestorage-openstack' gem 'activestorage-openstack', git: 'https://github.com/fredZen/activestorage-openstack.git', branch: 'frederic/fix_upload_signature'
gem 'administrate' gem 'administrate'
gem 'after_party' gem 'after_party'
gem 'anchored' gem 'anchored'

View file

@ -1,3 +1,14 @@
GIT
remote: https://github.com/fredZen/activestorage-openstack.git
revision: c71d5107a51701eab9d9267dd0000e6c1cf3e39a
branch: frederic/fix_upload_signature
specs:
activestorage-openstack (0.5.0)
fog-openstack (~> 1.0)
marcel
mime-types
rails (~> 5.2.0)
GIT GIT
remote: https://github.com/kobaltz/actiontext.git remote: https://github.com/kobaltz/actiontext.git
revision: ef59c4ba99d1b7614dd47f5a294eef553224db88 revision: ef59c4ba99d1b7614dd47f5a294eef553224db88
@ -64,11 +75,6 @@ GEM
actionpack (= 5.2.2.1) actionpack (= 5.2.2.1)
activerecord (= 5.2.2.1) activerecord (= 5.2.2.1)
marcel (~> 0.3.1) marcel (~> 0.3.1)
activestorage-openstack (1.0.0)
fog-openstack (~> 1.0)
marcel
mime-types
rails (<= 6)
activesupport (5.2.2.1) activesupport (5.2.2.1)
concurrent-ruby (~> 1.0, >= 1.0.2) concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2) i18n (>= 0.7, < 2)
@ -711,7 +717,7 @@ DEPENDENCIES
actiontext! actiontext!
active_link_to active_link_to
active_model_serializers active_model_serializers
activestorage-openstack activestorage-openstack!
administrate administrate
after_party after_party
anchored anchored

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="24" height="24"><path d="M18 10.5h-4.5V6a1 1 0 0 0-1-1h-1a1 1 0 0 0-1 1v4.5H6a1 1 0 0 0-1 1v1a1 1 0 0 0 1 1h4.5V18a1 1 0 0 0 1 1h1a1 1 0 0 0 1-1v-4.5H18a1 1 0 0 0 1-1v-1a1 1 0 0 0-1-1z" fill="#333"/></svg>

After

Width:  |  Height:  |  Size: 271 B

View file

@ -79,11 +79,16 @@
background-image: image-url("icons/lock.svg"); background-image: image-url("icons/lock.svg");
} }
&.add {
background-image: image-url("icons/add.svg");
margin-left: -5px;
margin-right: 0px;
}
&.justificatif { &.justificatif {
background-image: image-url("icons/justificatif.svg"); background-image: image-url("icons/justificatif.svg");
} }
&.printer { &.printer {
background-image: image-url("icons/printer.svg"); background-image: image-url("icons/printer.svg");
} }

View file

@ -250,7 +250,7 @@ class ApplicationController < ActionController::Base
payload: { payload: {
DS_SIGN_IN_COUNT: current_user&.sign_in_count, DS_SIGN_IN_COUNT: current_user&.sign_in_count,
DS_CREATED_AT: current_administrateur&.created_at, DS_CREATED_AT: current_administrateur&.created_at,
DS_ACTIVE: current_administrateur&.active, DS_ACTIVE: current_administrateur&.active?,
DS_ID: current_administrateur&.id, DS_ID: current_administrateur&.id,
DS_GESTIONNAIRE_ID: current_instructeur&.id, DS_GESTIONNAIRE_ID: current_instructeur&.id,
DS_ROLES: current_user_roles DS_ROLES: current_user_roles

View file

@ -49,7 +49,7 @@ module Instructeurs
@previous_following_instructeurs_emails = previous_followers.pluck(:email) @previous_following_instructeurs_emails = previous_followers.pluck(:email)
@avis_emails = dossier.avis.includes(:instructeur).map(&:email_to_display) @avis_emails = dossier.avis.includes(:instructeur).map(&:email_to_display)
@invites_emails = dossier.invites.map(&:email) @invites_emails = dossier.invites.map(&:email)
@potential_recipients = procedure.defaut_groupe_instructeur.instructeurs.reject { |g| g == current_instructeur } @potential_recipients = dossier.groupe_instructeur.instructeurs.reject { |g| g == current_instructeur }
end end
def send_to_instructeurs def send_to_instructeurs

View file

@ -17,15 +17,15 @@ class RootController < ApplicationController
end end
def patron def patron
description = 'aller voir le super site : https://demarches-simplifiees.fr' description = 'Aller voir le super site : https://demarches-simplifiees.fr'
all_champs = TypeDeChamp.type_champs all_champs = TypeDeChamp.type_champs
.map { |name, _| TypeDeChamp.new(type_champ: name, private: false, libelle: name, description: description, mandatory: true) } .map { |name, _| TypeDeChamp.new(type_champ: name, private: false, libelle: name.humanize, description: description, mandatory: true) }
.map.with_index { |type_de_champ, i| type_de_champ.champ.build(id: i) } .map.with_index { |type_de_champ, i| type_de_champ.champ.build(id: i) }
all_champs all_champs
.filter { |champ| champ.type_champ == TypeDeChamp.type_champs.fetch(:header_section) } .filter { |champ| champ.type_champ == TypeDeChamp.type_champs.fetch(:header_section) }
.each { |champ| champ.type_de_champ.libelle = 'un super titre de section' } .each { |champ| champ.type_de_champ.libelle = 'Un super titre de section' }
all_champs all_champs
.filter { |champ| [TypeDeChamp.type_champs.fetch(:drop_down_list), TypeDeChamp.type_champs.fetch(:multiple_drop_down_list)].include?(champ.type_champ) } .filter { |champ| [TypeDeChamp.type_champs.fetch(:drop_down_list), TypeDeChamp.type_champs.fetch(:multiple_drop_down_list)].include?(champ.type_champ) }
@ -39,6 +39,16 @@ class RootController < ApplicationController
champ.value = '["option B", "option C"]' champ.value = '["option B", "option C"]'
end end
all_champs
.filter { |champ| champ.type_champ == TypeDeChamp.type_champs.fetch(:repetition) }
.each do |champ_repetition|
libelles = ['Prénom', 'Nom'];
champ_repetition.champs << libelles.map.with_index do |libelle, i|
text_tdc = TypeDeChamp.new(type_champ: :text, private: false, libelle: libelle, description: description, mandatory: true)
text_tdc.champ.build(id: all_champs.length + i)
end
end
type_champ_values = { type_champ_values = {
TypeDeChamp.type_champs.fetch(:date) => '2016-07-26', TypeDeChamp.type_champs.fetch(:date) => '2016-07-26',
TypeDeChamp.type_champs.fetch(:datetime) => '26/07/2016 07:35', TypeDeChamp.type_champs.fetch(:datetime) => '26/07/2016 07:35',

View file

@ -0,0 +1,57 @@
module ActiveStorage
# Wraps an ActiveStorage::Service to route direct upload and direct download URLs through our proxy,
# thus avoiding exposing the storage providers URL to our end-users.
class Service::DsProxyService < SimpleDelegator
attr_reader :wrapped
def self.build(wrapped:, configurator:, **options)
new(wrapped: configurator.build(wrapped))
end
def initialize(wrapped:)
@wrapped = wrapped
super(wrapped)
end
def url(*args)
url = wrapped.url(*args)
publicize(url)
end
def url_for_direct_upload(*args)
url = wrapped.url_for_direct_upload(*args)
publicize(url)
end
private
def object_for(key, &block)
blob_url = url(key)
if block_given?
request = Typhoeus::Request.new(blob_url)
request.on_headers do |response|
if response.code != 200
raise Fog::OpenStack::Storage::NotFound.new
end
end
request.on_body do |chunk|
yield chunk
end
request.run
else
response = Typhoeus.get(blob_url)
if response.success?
response
else
raise Fog::OpenStack::Storage::NotFound.new
end
end
end
def publicize(url)
search = %r{^https://[^/]+/v1/AUTH_[a-f0-9]{32}}
replace = 'https://static.demarches-simplifiees.fr'
url.gsub(search, replace)
end
end
end

View file

@ -56,7 +56,7 @@ class Administrateur < ApplicationRecord
end end
def invitation_expired? def invitation_expired?
!active && !user.reset_password_period_valid? !active? && !user.reset_password_period_valid?
end end
def self.reset_password(reset_password_token, password) def self.reset_password(reset_password_token, password)
@ -66,10 +66,6 @@ class Administrateur < ApplicationRecord
reset_password_token: reset_password_token reset_password_token: reset_password_token
}) })
if administrateur && administrateur.errors.empty?
administrateur.update_column(:active, true)
end
administrateur administrateur
end end
@ -84,4 +80,8 @@ class Administrateur < ApplicationRecord
def can_be_deleted? def can_be_deleted?
dossiers.state_instruction_commencee.none? && procedures.none? dossiers.state_instruction_commencee.none? && procedures.none?
end end
def active?
user.last_sign_in_at.present?
end
end end

View file

@ -110,8 +110,10 @@ class Instructeur < ApplicationRecord
end end
def notifications_for_procedure(procedure, scope) def notifications_for_procedure(procedure, scope)
procedure target_groupes = groupe_instructeurs.where(procedure: procedure)
.defaut_groupe_instructeur.dossiers
Dossier
.where(groupe_instructeur: target_groupes)
.send(scope) # :en_cours or :termine or :not_archived (or any other Dossier scope) .send(scope) # :en_cours or :termine or :not_archived (or any other Dossier scope)
.merge(followed_dossiers) .merge(followed_dossiers)
.with_notifications .with_notifications

View file

@ -29,7 +29,7 @@ class AdministrateurUsageStatisticsService
result = { result = {
ds_sign_in_count: administrateur.user.sign_in_count, ds_sign_in_count: administrateur.user.sign_in_count,
ds_created_at: administrateur.created_at, ds_created_at: administrateur.created_at,
ds_active: administrateur.active, ds_active: administrateur.active?,
ds_id: administrateur.id, ds_id: administrateur.id,
nb_services: nb_services_by_administrateur_id[administrateur.id], nb_services: nb_services_by_administrateur_id[administrateur.id],
nb_instructeurs: nb_instructeurs_by_administrateur_id[administrateur.id], nb_instructeurs: nb_instructeurs_by_administrateur_id[administrateur.id],

View file

@ -1,6 +1,6 @@
.patron .patron
.container .container
%h1 Icones %h1 Icônes
%span.icon.follow %span.icon.follow
%span.icon.unfollow %span.icon.unfollow
@ -16,6 +16,7 @@
%span.icon.bubble %span.icon.bubble
%span.icon.attachment %span.icon.attachment
%span.icon.lock %span.icon.lock
%span.icon.add
%span.icon.justificatif %span.icon.justificatif
%span.icon.printer %span.icon.printer
%span.icon.account %span.icon.account
@ -47,7 +48,9 @@
= render partial: "shared/dossiers/editable_champs/editable_champ", = render partial: "shared/dossiers/editable_champs/editable_champ",
locals: { champ: champ, form: champ_form, seen_at: nil } locals: { champ: champ, form: champ_form, seen_at: nil }
%label Mot de passe
%input{ type: "password", value: "12345678" } %input{ type: "password", value: "12345678" }
.send-wrapper .send-wrapper
= f.submit 'Enregistrer un brouillon (formnovalidate)', formnovalidate: true, class: 'button send' = f.submit 'Enregistrer un brouillon (formnovalidate)', formnovalidate: true, class: 'button send'
= f.submit 'Envoyer', class: 'button send primary' = f.submit 'Envoyer', class: 'button send primary'

View file

@ -14,7 +14,10 @@
Supprimer Supprimer
- if champ.persisted? - if champ.persisted?
= link_to "Ajouter une ligne pour « #{champ.libelle} »", champs_repetition_path(form.index), class: 'button add-row', data: { remote: true, method: 'POST', params: { champ_id: champ&.id }.to_query } = link_to champs_repetition_path(form.index), class: 'button add-row', data: { remote: true, method: 'POST', params: { champ_id: champ&.id }.to_query } do
%span.icon.add
Ajouter une ligne pour « #{champ.libelle} »
- else - else
%button.button{ type: :button } %a.button.add-row
= "Ajouter une ligne pour « #{champ.libelle} »" %span.icon.add
Ajouter une ligne pour « #{champ.libelle} »

View file

@ -93,7 +93,7 @@ Rails.application.configure do
# the I18n.default_locale when a translation cannot be found). # the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true config.i18n.fallbacks = true
config.active_storage.service = :openstack config.active_storage.service = :proxied
# Send deprecation notices to registered listeners. # Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify config.active_support.deprecation = :notify

View file

@ -7,33 +7,3 @@ ActiveStorage::Service.url_expires_in = 1.hour
# cleaner (as it allows to enqueue the virus scan on attachment creation, rather # cleaner (as it allows to enqueue the virus scan on attachment creation, rather
# than on blob creation). # than on blob creation).
ActiveSupport.on_load(:active_storage_blob) { include BlobVirusScanner } ActiveSupport.on_load(:active_storage_blob) { include BlobVirusScanner }
# When an OpenStack service is initialized it makes a request to fetch
# `publicURL` to use for all operations. We intercept the method that reads
# this url and replace the host with DS_Proxy host. This way all the operation
# are performed through DS_Proxy.
#
# https://github.com/fog/fog-openstack/blob/37621bb1d5ca78d037b3c56bd307f93bba022ae1/lib/fog/openstack/auth/catalog/v2.rb#L16
require 'fog/openstack/auth/catalog/v2'
module Fog::OpenStack::Auth::Catalog
class V2
def endpoint_url(endpoint, interface)
url = endpoint["#{interface}URL"]
if interface == 'public'
publicize(url)
else
url
end
end
private
def publicize(url)
search = %r{^https://[^/]+/}
replace = 'https://static.demarches-simplifiees.fr/'
url.gsub(search, replace)
end
end
end

View file

@ -189,14 +189,14 @@ fr:
procedure_archived: "Cette démarche en ligne a été fermée, il n'est plus possible de déposer de dossier." procedure_archived: "Cette démarche en ligne a été fermée, il n'est plus possible de déposer de dossier."
procedure_not_draft: "Cette démarche nest maintenant plus en brouillon." procedure_not_draft: "Cette démarche nest maintenant plus en brouillon."
cadastres_empty: cadastres_empty:
one: "Aucune parcelle cadastrale sur la zone séléctionnée" one: "Aucune parcelle cadastrale sur la zone sélectionnée"
other: "Aucune parcelle cadastrale sur les zones séléctionnées" other: "Aucune parcelle cadastrale sur les zones sélectionnées"
quartiers_prioritaires_empty: quartiers_prioritaires_empty:
one: "Aucun quartier prioritaire sur la zone séléctionnée" one: "Aucun quartier prioritaire sur la zone sélectionnée"
other: "Aucun quartier prioritaire sur les zones séléctionnées" other: "Aucun quartier prioritaire sur les zones sélectionnées"
parcelles_agricoles_empty: parcelles_agricoles_empty:
one: "Aucune parcelle agricole sur la zone séléctionnée" one: "Aucune parcelle agricole sur la zone sélectionnée"
other: "Aucune parcelle agricole sur les zones séléctionnées" other: "Aucune parcelle agricole sur les zones sélectionnées"
date: date:
abbr_day_names: abbr_day_names:

View file

@ -4,6 +4,9 @@ local:
test: test:
service: Disk service: Disk
root: <%= Rails.root.join("tmp/storage") %> root: <%= Rails.root.join("tmp/storage") %>
proxied:
service: DsProxy
wrapped: openstack
openstack: openstack:
service: OpenStack service: OpenStack
container: "<%= ENV['FOG_ACTIVESTORAGE_DIRECTORY'] %>" container: "<%= ENV['FOG_ACTIVESTORAGE_DIRECTORY'] %>"

View file

@ -3,6 +3,7 @@ require 'spec_helper'
feature 'As an administrateur', js: true do feature 'As an administrateur', js: true do
let(:administration) { create(:administration) } let(:administration) { create(:administration) }
let(:admin_email) { 'new_admin@gouv.fr' } let(:admin_email) { 'new_admin@gouv.fr' }
let(:new_admin) { Administrateur.find_by(email: admin_email) }
before do before do
perform_enqueued_jobs do perform_enqueued_jobs do
@ -11,6 +12,8 @@ feature 'As an administrateur', js: true do
end end
scenario 'I can register' do scenario 'I can register' do
expect(new_admin.reload.active?).to be(false)
confirmation_email = open_email(admin_email) confirmation_email = open_email(admin_email)
token_params = confirmation_email.body.match(/token=[^"]+/) token_params = confirmation_email.body.match(/token=[^"]+/)
@ -20,5 +23,7 @@ feature 'As an administrateur', js: true do
click_button 'Continuer' click_button 'Continuer'
expect(page).to have_content 'Mot de passe enregistré' expect(page).to have_content 'Mot de passe enregistré'
expect(new_admin.reload.active?).to be(true)
end end
end end

View file

@ -1,10 +1,11 @@
require 'spec_helper' require 'spec_helper'
feature 'The routing' do feature 'The routing' do
let(:procedure) { create(:procedure, :with_service, :for_individual) } let(:password) { 'a very complicated password' }
let(:procedure) { create(:procedure, :with_type_de_champ, :with_service, :for_individual) }
let(:administrateur) { create(:administrateur, procedures: [procedure]) } let(:administrateur) { create(:administrateur, procedures: [procedure]) }
let(:scientifique_user) { create(:user) } let(:scientifique_user) { create(:user, password: password) }
let(:litteraire_user) { create(:user) } let(:litteraire_user) { create(:user, password: password) }
before { Flipper.enable_actor(:routage, administrateur.user) } before { Flipper.enable_actor(:routage, administrateur.user) }
@ -67,6 +68,9 @@ feature 'The routing' do
click_on litteraire_user.email click_on litteraire_user.email
expect(page).to have_current_path(instructeur_dossier_path(procedure, litteraire_user.dossiers.first)) expect(page).to have_current_path(instructeur_dossier_path(procedure, litteraire_user.dossiers.first))
# follow the dossier
click_on 'Suivre le dossier'
log_out log_out
# the scientifiques instructeurs only manage the scientifiques dossiers # the scientifiques instructeurs only manage the scientifiques dossiers
@ -74,9 +78,50 @@ feature 'The routing' do
click_on procedure.libelle click_on procedure.libelle
expect(page).not_to have_text(litteraire_user.email) expect(page).not_to have_text(litteraire_user.email)
expect(page).to have_text(scientifique_user.email) expect(page).to have_text(scientifique_user.email)
# follow the dossier
click_on scientifique_user.email
click_on 'Suivre le dossier'
log_out log_out
# TODO: notifications tests # litteraire_user change its dossier
visit root_path
click_on 'Connexion'
sign_in_with litteraire_user.email, password
click_on litteraire_user.dossiers.first.id
click_on 'Modifier mon dossier'
fill_in 'dossier_champs_attributes_0_value', with: 'some value'
click_on 'Enregistrer les modifications du dossier'
log_out
# the litteraires instructeurs should have a notification
visit root_path
click_on 'Connexion'
sign_in_with victor.user.email, password
## on the procedures list
visit instructeur_procedures_path
expect(page).to have_css("span.notifications")
## on the dossiers list
click_on procedure.libelle
expect(page).to have_css("span.notifications")
## on the dossier it self
click_on 'suivi'
click_on litteraire_user.email
expect(page).to have_css("span.notifications")
log_out
# the scientifiques instructeurs should not have a notification
login_as marie.user, scope: :user
visit instructeur_procedures_path
expect(page).not_to have_css("span.notifications")
log_out
end end
def publish_procedure(procedure) def publish_procedure(procedure)
@ -113,7 +158,7 @@ feature 'The routing' do
token_params = confirmation_email.body.match(/token=[^"]+/) token_params = confirmation_email.body.match(/token=[^"]+/)
visit "users/activate?#{token_params}" visit "users/activate?#{token_params}"
fill_in :user_password, with: 'démarches-simplifiées-pwd' fill_in :user_password, with: password
click_button 'Définir le mot de passe' click_button 'Définir le mot de passe'

View file

@ -2,7 +2,8 @@ require 'rails_helper'
RSpec.describe Administrateurs::ActivateBeforeExpirationJob, type: :job do RSpec.describe Administrateurs::ActivateBeforeExpirationJob, type: :job do
describe 'perform' do describe 'perform' do
let(:administrateur) { create(:administrateur, active: active) } let(:administrateur) { create(:administrateur) }
let(:user) { administrateur.user }
let(:mailer_double) { double('mailer', deliver_later: true) } let(:mailer_double) { double('mailer', deliver_later: true) }
subject { Administrateurs::ActivateBeforeExpirationJob.perform_now } subject { Administrateurs::ActivateBeforeExpirationJob.perform_now }
@ -16,7 +17,7 @@ RSpec.describe Administrateurs::ActivateBeforeExpirationJob, type: :job do
after { Timecop.return } after { Timecop.return }
context "with an inactive administrateur" do context "with an inactive administrateur" do
let(:active) { false } before { user.update(last_sign_in_at: nil) }
context "created now" do context "created now" do
before { subject } before { subject }
@ -43,7 +44,7 @@ RSpec.describe Administrateurs::ActivateBeforeExpirationJob, type: :job do
end end
context "with an active administrateur" do context "with an active administrateur" do
let(:active) { true } before { user.update(last_sign_in_at: Time.zone.now) }
context "created now" do context "created now" do
before { subject } before { subject }

View file

@ -1,27 +0,0 @@
describe '20191007124230_update_admin_last_sign_in_at.rake' do
let(:rake_task) { Rake::Task['after_party:update_admin_last_sign_in_at'] }
subject { rake_task.invoke }
after { rake_task.reenable }
context 'with 2 administrateurs' do
let!(:admin) { create(:administrateur, active: true) }
let(:user) { admin.user }
let!(:admin2) { create(:administrateur, active: false) }
let(:user2) { admin2.user }
before do
end
it do
expect(admin.active).to be true
expect(user.last_sign_in_at).to be_nil
expect(admin.updated_at).not_to be_nil
subject
expect(user.reload.last_sign_in_at).to eq(admin.reload.updated_at)
expect(user2.reload.last_sign_in_at).to be_nil
end
end
end

View file

@ -50,4 +50,22 @@ describe Administrateur, type: :model do
# it { expect(subject).to eq([]) } # it { expect(subject).to eq([]) }
# end # end
# end # end
describe '#active?' do
let!(:administrateur) { create(:administrateur) }
subject { administrateur.active? }
context 'when the user has never signed in' do
before { administrateur.user.update(last_sign_in_at: nil) }
it { is_expected.to be false }
end
context 'when the user has already signed in' do
before { administrateur.user.update(last_sign_in_at: Time.zone.now) }
it { is_expected.to be true }
end
end
end end

View file

@ -119,8 +119,8 @@ describe TagsSubstitutionConcern, type: :model do
let(:types_de_champ) do let(:types_de_champ) do
[ [
create(:type_de_champ_repetition, libelle: 'Répétition', types_de_champ: [ create(:type_de_champ_repetition, libelle: 'Répétition', types_de_champ: [
create(:type_de_champ_text, libelle: 'Nom'), create(:type_de_champ_text, libelle: 'Nom', order_place: 1),
create(:type_de_champ_text, libelle: 'Prénom') create(:type_de_champ_text, libelle: 'Prénom', order_place: 2)
]) ])
] ]
end end

View file

@ -236,15 +236,16 @@ describe Instructeur, type: :model do
end end
describe '#notifications_for_procedure' do describe '#notifications_for_procedure' do
let!(:dossier) { create(:dossier, :followed, state: Dossier.states.fetch(:en_construction)) } let(:procedure) { create(:simple_procedure, :routee, :with_type_de_champ_private) }
let!(:dossier) { create(:dossier, :followed, groupe_instructeur: procedure.groupe_instructeurs.last, state: Dossier.states.fetch(:en_construction)) }
let(:instructeur) { dossier.follows.first.instructeur } let(:instructeur) { dossier.follows.first.instructeur }
let(:procedure) { dossier.procedure } let!(:instructeur_2) { create(:instructeur, groupe_instructeurs: [procedure.groupe_instructeurs.last]) }
let!(:instructeur_2) { create(:instructeur, groupe_instructeurs: [procedure.defaut_groupe_instructeur]) }
let!(:dossier_on_procedure_2) { create(:dossier, :followed, state: Dossier.states.fetch(:en_construction)) } let!(:dossier_on_procedure_2) { create(:dossier, :followed, state: Dossier.states.fetch(:en_construction)) }
let!(:instructeur_on_procedure_2) { dossier_on_procedure_2.follows.first.instructeur } let!(:instructeur_on_procedure_2) { dossier_on_procedure_2.follows.first.instructeur }
before do before do
procedure.groupe_instructeurs.last.instructeurs << instructeur
instructeur_2.followed_dossiers << dossier instructeur_2.followed_dossiers << dossier
end end

View file

@ -39,7 +39,6 @@ describe AdministrateurUsageStatisticsService do
let(:administrateur) do let(:administrateur) do
create(:administrateur, create(:administrateur,
user: create(:user, sign_in_count: 17, current_sign_in_at: Time.zone.local(2019, 3, 7), last_sign_in_at: Time.zone.local(2019, 2, 27)), user: create(:user, sign_in_count: 17, current_sign_in_at: Time.zone.local(2019, 3, 7), last_sign_in_at: Time.zone.local(2019, 2, 27)),
active: true,
services: [create(:service)], services: [create(:service)],
instructeurs: [create(:instructeur)]) instructeurs: [create(:instructeur)])
end end