From fa46f7f0d781b482102e0c322249a6a415bac589 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Tue, 19 Jun 2018 16:34:26 +0200 Subject: [PATCH 1/9] config: make assets compilation faster in development --- config/environments/development.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/environments/development.rb b/config/environments/development.rb index acf2838a6..1875e144e 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -30,7 +30,7 @@ Rails.application.configure do # Debug mode disables concatenation and preprocessing of assets. # This option may cause significant delays in view rendering with a large # number of complex assets. - config.assets.debug = true + config.assets.debug = false # Asset digests allow you to set far-future HTTP expiration dates on all assets, # yet still be able to expire them through the digest params. From c2bc151803bc0449eb3dbd40bad031f2f7ede17d Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 11 Jun 2018 17:21:49 +0200 Subject: [PATCH 2/9] spring: add generated spring binstub File generated with `bundle exec spring binstub`. Use it with `bin/spring rails`, or `bin/spring rspec`. --- bin/spring | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 bin/spring diff --git a/bin/spring b/bin/spring new file mode 100755 index 000000000..fb2ec2ebb --- /dev/null +++ b/bin/spring @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +# This file loads spring without using Bundler, in order to be fast. +# It gets overwritten when you run the `spring binstub` command. + +unless defined?(Spring) + require 'rubygems' + require 'bundler' + + lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) + spring = lockfile.specs.detect { |spec| spec.name == "spring" } + if spring + Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path + gem 'spring', spring.version + require 'spring/binstub' + end +end From ae5754e6c63f6ffaa4dabec6536895161b31f8c3 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 18 Jun 2018 11:14:46 +0000 Subject: [PATCH 3/9] spring: add Spring to binstubs of default commands Binstubs generated with `bundle exec spring binstub --all`. This allows to type `bin/rails`, `bin/rake` or `bin/rspec` and have it using Spring (rather than `bin/spring rails`). On my machine it produces a nice speedup: - `rake -T`: 5.6s - `bin/rake -T`: 0.25s The startup speedup for `rails` and `rspec` is similar. --- .rubocop.yml | 1 + bin/rails | 5 +++++ bin/rake | 5 +++++ bin/rspec | 5 +++++ 4 files changed, 16 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index 853e107d7..8007fd868 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -4,6 +4,7 @@ require: AllCops: Exclude: - "db/schema.rb" + - "bin/*" Bundler/DuplicatedGem: Enabled: true diff --git a/bin/rails b/bin/rails index 073966023..5badb2fde 100755 --- a/bin/rails +++ b/bin/rails @@ -1,4 +1,9 @@ #!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end APP_PATH = File.expand_path('../config/application', __dir__) require_relative '../config/boot' require 'rails/commands' diff --git a/bin/rake b/bin/rake index 17240489f..d87d5f578 100755 --- a/bin/rake +++ b/bin/rake @@ -1,4 +1,9 @@ #!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end require_relative '../config/boot' require 'rake' Rake.application.run diff --git a/bin/rspec b/bin/rspec index cf3d49c41..2952f41a2 100755 --- a/bin/rspec +++ b/bin/rspec @@ -1,3 +1,8 @@ #!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) load Gem.bin_path('rspec-core', 'rspec') From 9f502c536b49f9ab5fdb30f81ec2481c715f5d88 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 20 Jun 2018 09:29:02 +0000 Subject: [PATCH 4/9] spec: only load tasks once When a task is loaded several times, a single call of `task.invoke` will run the task several times too. This made `add_annotion_privee_to_procedure_spec` fail when it wasn't the first task being tested. --- spec/lib/rake/2018_03_06_clean_html_textareas_spec.rb | 1 - .../2018_03_29_remove_code_tags_from_mail_templates_spec.rb | 1 - .../rake/2018_05_14_add_annotation_privee_to_procedure_spec.rb | 2 -- spec/spec_helper.rb | 2 ++ 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/spec/lib/rake/2018_03_06_clean_html_textareas_spec.rb b/spec/lib/rake/2018_03_06_clean_html_textareas_spec.rb index e1790f6f4..cff7056d0 100644 --- a/spec/lib/rake/2018_03_06_clean_html_textareas_spec.rb +++ b/spec/lib/rake/2018_03_06_clean_html_textareas_spec.rb @@ -10,7 +10,6 @@ describe '2018_03_06_clean_html_textareas#clean' do before do Timecop.freeze(champ_date) { champ } - TPS::Application.load_tasks Timecop.freeze(rake_date) { rake_task.invoke } champ.reload end diff --git a/spec/lib/rake/2018_03_29_remove_code_tags_from_mail_templates_spec.rb b/spec/lib/rake/2018_03_29_remove_code_tags_from_mail_templates_spec.rb index 402d6c8fa..20667b06d 100644 --- a/spec/lib/rake/2018_03_29_remove_code_tags_from_mail_templates_spec.rb +++ b/spec/lib/rake/2018_03_29_remove_code_tags_from_mail_templates_spec.rb @@ -10,7 +10,6 @@ describe '2018_03_29_remove_code_tags_from_mail_templates#clean' do let!(:dirty_without_continuation_mail) { create(:without_continuation_mail, body: "

Salut


Voici ton email avec une balise --balise--") } before do - TPS::Application.load_tasks rake_task.invoke dirty_closed_mail.reload dirty_initiated_mail.reload diff --git a/spec/lib/rake/2018_05_14_add_annotation_privee_to_procedure_spec.rb b/spec/lib/rake/2018_05_14_add_annotation_privee_to_procedure_spec.rb index 70d377cf6..2817c4797 100644 --- a/spec/lib/rake/2018_05_14_add_annotation_privee_to_procedure_spec.rb +++ b/spec/lib/rake/2018_05_14_add_annotation_privee_to_procedure_spec.rb @@ -24,8 +24,6 @@ describe '2018_05_14_add_annotation_privee_to_procedure' do let!(:dossier) { Dossier.create(procedure: procedure, user: user, state: 'brouillon') } let(:rake_task) { Rake::Task['2018_05_14_add_annotation_privee_to_procedure:add'] } - before(:all) { TPS::Application.load_tasks } - before do ENV['PROCEDURE_ID'] = procedure.id.to_s rake_task.invoke diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 4b8773121..f532af613 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -69,6 +69,8 @@ end DatabaseCleaner.strategy = :transaction +TPS::Application.load_tasks + SIADETOKEN = :valid_token if !defined? SIADETOKEN include Warden::Test::Helpers From c3610fc96e1110de0554bb7e8f4d0dc220f5b91a Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Wed, 20 Jun 2018 13:30:32 +0200 Subject: [PATCH 5/9] [fix #2067] Resend confirmation mail if the user is not confirmed --- .../users/registrations_controller.rb | 6 +++- .../users/registrations_controller_spec.rb | 28 +++++++++++++++---- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/app/controllers/users/registrations_controller.rb b/app/controllers/users/registrations_controller.rb index 95be35e5b..6bbcbdf4a 100644 --- a/app/controllers/users/registrations_controller.rb +++ b/app/controllers/users/registrations_controller.rb @@ -17,7 +17,11 @@ class Users::RegistrationsController < Devise::RegistrationsController def create user = User.find_by(email: params[:user][:email]) if user.present? - UserMailer.new_account_warning(user).deliver_later + if user.confirmed? + UserMailer.new_account_warning(user).deliver_later + else + user.resend_confirmation_instructions + end flash.notice = t('devise.registrations.signed_up_but_unconfirmed') redirect_to root_path else diff --git a/spec/controllers/users/registrations_controller_spec.rb b/spec/controllers/users/registrations_controller_spec.rb index baebdd389..1c9a5793b 100644 --- a/spec/controllers/users/registrations_controller_spec.rb +++ b/spec/controllers/users/registrations_controller_spec.rb @@ -34,16 +34,34 @@ describe Users::RegistrationsController, type: :controller do end context 'when the user already exists' do - let!(:existing_user) { create(:user, email: email, password: password) } + let!(:existing_user) { create(:user, email: email, password: password, confirmed_at: confirmed_at) } before do allow(UserMailer).to receive(:new_account_warning).and_return(double(deliver_later: 'deliver')) - subject end - it { expect(response).to redirect_to(root_path) } - it { expect(flash.notice).to eq(I18n.t('devise.registrations.signed_up_but_unconfirmed')) } - it { expect(UserMailer).to have_received(:new_account_warning) } + context 'and the user is confirmed' do + let(:confirmed_at) { DateTime.now } + + before { subject } + + it { expect(response).to redirect_to(root_path) } + it { expect(flash.notice).to eq(I18n.t('devise.registrations.signed_up_but_unconfirmed')) } + it { expect(UserMailer).to have_received(:new_account_warning) } + end + + context 'and the user is not confirmed' do + let(:confirmed_at) { nil } + + before do + expect_any_instance_of(User).to receive(:resend_confirmation_instructions) + subject + end + + it { expect(response).to redirect_to(root_path) } + it { expect(flash.notice).to eq(I18n.t('devise.registrations.signed_up_but_unconfirmed')) } + it { expect(UserMailer).not_to have_received(:new_account_warning) } + end end end end From 99b9f42b21a9436dc9b690bce720fef820e055cc Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 20 Jun 2018 17:33:59 +0200 Subject: [PATCH 6/9] manager: display gestionnaires on the procedure page --- app/dashboards/procedure_dashboard.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/dashboards/procedure_dashboard.rb b/app/dashboards/procedure_dashboard.rb index af16cfc04..0d18c8635 100644 --- a/app/dashboards/procedure_dashboard.rb +++ b/app/dashboards/procedure_dashboard.rb @@ -12,6 +12,7 @@ class ProcedureDashboard < Administrate::BaseDashboard types_de_champ: TypesDeChampCollectionField, path: ProcedureLinkField, dossiers: Field::HasMany, + gestionnaires: Field::HasMany, administrateur: Field::BelongsTo, id: Field::Number, libelle: Field::String, @@ -64,6 +65,7 @@ class ProcedureDashboard < Administrate::BaseDashboard :for_individual, :individual_with_siret, :auto_archive_on, + :gestionnaires ].freeze # FORM_ATTRIBUTES From e953481fd0894c63aab8cd0d1ccd16895ec6c437 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 20 Jun 2018 17:34:11 +0200 Subject: [PATCH 7/9] manager: display procedures on the gestionnaires page --- app/dashboards/gestionnaire_dashboard.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/dashboards/gestionnaire_dashboard.rb b/app/dashboards/gestionnaire_dashboard.rb index db1d6727b..02b8ad37e 100644 --- a/app/dashboards/gestionnaire_dashboard.rb +++ b/app/dashboards/gestionnaire_dashboard.rb @@ -14,6 +14,7 @@ class GestionnaireDashboard < Administrate::BaseDashboard updated_at: Field::DateTime, current_sign_in_at: Field::DateTime, dossiers: Field::HasMany, + procedures: Field::HasMany }.freeze # COLLECTION_ATTRIBUTES @@ -29,6 +30,7 @@ class GestionnaireDashboard < Administrate::BaseDashboard # SHOW_PAGE_ATTRIBUTES # an array of attributes that will be displayed on the model's show page. SHOW_PAGE_ATTRIBUTES = [ + :procedures, :dossiers, :id, :email, From 3c331b65a53078e7444d7429aa73d90b5cfae0f3 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Wed, 20 Jun 2018 18:30:41 +0200 Subject: [PATCH 8/9] Remove an unused method --- app/models/gestionnaire.rb | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/app/models/gestionnaire.rb b/app/models/gestionnaire.rb index e7fef8d10..033f3df54 100644 --- a/app/models/gestionnaire.rb +++ b/app/models/gestionnaire.rb @@ -152,33 +152,6 @@ class Gestionnaire < ApplicationRecord private - def valid_couple_table_attr?(table, column) - couples = [ - { - table: :dossier, - column: :dossier_id - }, - { - table: :procedure, - column: :libelle - }, - { - table: :etablissement, - column: :siret - }, - { - table: :entreprise, - column: :raison_sociale - }, - { - table: :dossier, - column: :state - } - ] - - couples.include?({ table: table, column: column }) - end - def annotations_hash(demande, annotations_privees, avis, messagerie) { demande: demande, From 901748c5aa2c33a574659ef70369b4c46ec2c190 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Wed, 20 Jun 2018 18:35:19 +0200 Subject: [PATCH 9/9] Show the etablissement SIRET, not the siege social SIRET --- .../new_gestionnaire/dossiers/_identite_entreprise.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/new_gestionnaire/dossiers/_identite_entreprise.html.haml b/app/views/new_gestionnaire/dossiers/_identite_entreprise.html.haml index 64d63f581..ae149afc2 100644 --- a/app/views/new_gestionnaire/dossiers/_identite_entreprise.html.haml +++ b/app/views/new_gestionnaire/dossiers/_identite_entreprise.html.haml @@ -5,7 +5,7 @@ %td= raison_sociale_or_name(etablissement) %tr %th.libelle SIRET : - %td= etablissement.entreprise.siret_siege_social + %td= etablissement.siret %tr %th.libelle Forme juridique : %td= sanitize(etablissement.entreprise.forme_juridique)