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/Gemfile.lock b/Gemfile.lock index 3d890c1a4..7924deba3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -714,7 +714,7 @@ GEM activesupport (>= 4.2) spring-commands-rspec (1.0.4) spring (>= 0.9.1) - sprockets (3.7.1) + sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) sprockets-rails (3.2.1) 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/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, 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 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) 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') 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 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. 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