Commit graph

1340 commits

Author SHA1 Message Date
Pierre de La Morinerie
75a1046315 active_storage: refactor concerns
Follow-up of #5953.

Refactor the concerns with two goals:

- Getting closer from the way ActiveStorage adds its own hooks.
  Usually ActiveStorage does this using an `Attachment#after_create`
  hook, which then delegates to the blob to enqueue the job.
- Enqueuing each job only once. By hooking on `Attachment#after_create`,
  we guarantee each job will be added only once.

We then let the jobs themselves check if they are relevant or not, and
retry or discard themselves if necessary.

We also need to update the tests a bit, because Rails'
`perform_enqueued_jobs(&block)` test helper doesn't honor the `retry_on`
clause of jobs. Instead it forwards the exception to the caller – which
makes the test fail.

Instead we use the inline version of `perform_enqueued_jobs()`, without
a block, which properly ignores errors catched by retry_on.
2021-03-16 11:49:14 +01:00
Pierre de La Morinerie
70104d7059 config: avoid blocking legitimate requests from mobile ISPs 2021-03-11 18:28:10 +01:00
Paul Chavard
1644c9d44b Another attempt at fixing IE 2021-03-09 11:29:20 +01:00
Pierre de La Morinerie
b0735aafe0 config: fix DynamicSmtpSettingsInterceptor warning again
This warning re-appeared when running mailer tests:

```
DISABLE_SPRING=1 bin/rspec spec/mailers/administration_mailer_spec.rb
```

It is now fixed properly, in a way recommanded by the documentation.
2021-03-04 22:52:19 +01:00
Paul Chavard
d4a34edab5 fix mapbox-gl transpilation 2021-03-04 19:04:39 +01:00
Paul Chavard
600f49a0ff Hide groupe instructeur selector when routage is done via API 2021-03-04 11:06:04 +01:00
Paul Chavard
1c811083c0 Cleanup feature flags usage 2021-03-04 11:06:04 +01:00
Pierre de La Morinerie
d36a684315 config: fix zeitwekr warning when reloading the app
Turns out we need not only to load the Job constants later, but also
not to do the same work twice – otherwise we'll get a 

> ApiEntreprise::Job constant is already defined

when attempting to re-define the constant.
2021-02-24 19:01:27 +01:00
Pierre de La Morinerie
9f676c76e1 config: fix zeitwerk warning about DynamicSmtpSettingsInterceptor
Fix a warning when running tests:

> DEPRECATION WARNING: Initialization autoloaded the constant DynamicSmtpSettingsInterceptor.
>
> Being able to do this is deprecated. Autoloading during initialization is going
to be an error condition in future versions of Rails.
> 
> Reloading does not reboot the application, and therefore code executed during
> initialization does not run again. So, if you reload DynamicSmtpSettingsInterceptor, for example,
> the expected changes won't be reflected in that stale Class object.
> 
> This autoloaded constant has been unloaded.
> 
> Please, check the "Autoloading and Reloading Constants" guide for solutions.

However if we fix as recommanded, the interceptor will get added
each time the classes are reloaded. And as the actual class instance
changed after the reloading, they won't be de-duplicated – *and*
there's no way to remove the old interceptor without having a reference
to the (now-deleted) class.

Instead we load the interceptor once, and add a message about the class
not being auto-reloaded.
2021-02-24 19:00:29 +01:00
Pierre de La Morinerie
68425929c6 config: disable Sentry sampling when not enabled
This removes spam in the debug console when running locally.

Removed messages look like a swarm of:

> [Tracing] Discarding <rails.request> transaction </assets/marianne.png> because it's not included in the random sample (sampling rate = 0.001)
2021-02-24 17:45:18 +01:00
Pierre de La Morinerie
e51948ab5c stylesheets: merge print rules with the application stylesheet
- Having a separate stylesheet for print rules is not a best practice
  (it makes an extra network request)
- It makes migrating to Sprockets 4 easier
2021-02-24 17:09:51 +01:00
Pierre de La Morinerie
fb305e31c4 config: move application_name to an initializer
It seems cleaner not to require a file before the Rails configuration
runs.
2021-02-24 15:06:55 +01:00
Pierre de La Morinerie
a2175ed6e3 config: reload compatibility aliases on classes reload
Fixes zeitwerk complaining that the compatibility aliases loaded in an
initializer will never be reloaded.

In our case it doesn't matter that much, but it will reduce the console
spam.
2021-02-23 09:24:13 +00:00
Paul Chavard
228a83f8a5 Add api address external data fetch 2021-02-17 19:10:16 +01:00
Paul Chavard
7223d77058 Remove unused paths from assets pipeline 2021-02-17 10:16:54 +01:00
Paul Chavard
1c164c4376 Use jsx extension 2021-02-16 18:14:10 +01:00
Pierre de La Morinerie
2ce3149d92 test: don't cache classes during tests
When running several individual tests in succession using Spring,
we get an error message:

> zeitwerk error: reloading is disabled because config.cache_classes is true

Caching classes during tests used to be recommended – but Rails 6
now recommands to reload them:

- Spring takes care of the caching for us,
- It makes zeitwerk happy.

See discussion in 65344f254c

A potential downside used to be that when running system tests using
Capybara, each web request would reload the classes, which invalidated
the model objects of the test case. But it seems to be fixed now.
2021-02-16 15:59:35 +01:00
kara Diaby
9492b09f85 make and expert notifiable (controller and routes) 2021-02-16 09:46:18 +00:00
Paul Chavard
cfa80578a7 Adjust sentry sample rate 2021-02-12 11:35:58 +01:00
Pierre de La Morinerie
211ddeda45 config: enable zeitwerk
Check that everything works using
bin/rails zeitwerk:check
2021-02-11 12:30:43 +01:00
Pierre de La Morinerie
819325c761 zeitwerk: move our Array extension to initializers/core_ext 2021-02-11 12:30:43 +01:00
Christophe Robillard
a288a13805 disable france connect authentication for admin and instructeurs 2021-02-10 18:13:47 +01:00
Paul Chavard
0697e50b7c lower sentry sampling to 1% 2021-02-10 17:52:18 +01:00
Paul Chavard
eac967f84e Add sentry traces (20% for now) 2021-02-10 15:35:21 +01:00
Pierre de La Morinerie
0af7188d8c zeitwerk: add inflections 2021-02-09 13:09:10 +01:00
Pierre de La Morinerie
7d1c79bf4b zeitwerk: Url -> URL 2021-02-09 13:07:30 +01:00
Pierre de La Morinerie
150ddab660 zeitwerk: Api -> API 2021-02-09 13:07:30 +01:00
Fabrice Gangler
229f495753 allow email footer logo to be configured in .env file
Refs: #5873
2021-02-09 09:39:02 +01:00
Fabrice Gangler
3034716963 allow mailers/_bizdev_signature to be configured in .env file
Refs: #5871
2021-02-04 13:09:40 +01:00
Fabrice Gangler
d039798ac8 allow logo in PDF export to be configured in .env file
Refs: #5869
2021-02-04 12:24:31 +01:00
Pierre de La Morinerie
3b5617b123 mailers: remove dead AdministrationMailer code 2021-02-04 12:15:13 +01:00
Judith
6d89a83d14 unused locales clean-up 2021-02-04 12:15:13 +01:00
Judith
ed10a9dd62 gem i18n-tasks added to Gemfile 2021-02-04 12:15:13 +01:00
Paul Chavard
c46ab38055 Add sentry-rails 2021-01-28 15:31:27 +01:00
simon lehericey
d72f0c6dd2 Add authorized content type for pj 2021-01-18 17:23:08 +01:00
Paul Chavard
91be115c70 Add annuaire_education champ ui 2021-01-14 17:57:48 +01:00
Paul Chavard
54f2084aef Add annuaire_education champ 2021-01-14 17:57:48 +01:00
Paul Chavard
5c9f2e8783 Add api education adapter and job 2021-01-14 17:57:48 +01:00
kara Diaby
8f6440f615 Admins can see the list of invited experts 2020-12-21 14:55:51 +01:00
simon lehericey
9848dc2295 update brakeman 2020-12-17 10:51:09 +01:00
simon lehericey
d760402393 fix typo 2020-12-16 15:00:26 +01:00
simon lehericey
57bff8ca70 improve deletion mail 2020-12-16 15:00:26 +01:00
kara Diaby
c7643154d1 final optims after sim review 2020-12-16 15:00:26 +01:00
kara Diaby
00b5ad7a10 EQT instructeur, je peux supprimer un dossier terminé 2020-12-16 15:00:26 +01:00
Fabrice Gangler
a8081d4b83 allow configuration of the URLs of FAQ and documentation websites in an .env file
Refs: #5801
2020-12-15 16:40:10 +01:00
Christophe Robillard
15a395fbc7 superadmin: check complexity password server side 2020-12-15 16:26:09 +01:00
Christophe Robillard
94b3ec942b super_admin: check password complexity client side 2020-12-15 16:26:09 +01:00
Fabrice Gangler
3a9f82bd6f Fix(form /contact-admin): use APPLICATION_NAME
Refs: #5799
2020-12-15 16:14:51 +01:00
Fabrice Gangler
064ea776c7 allow default logo of a procedure to be configured in .env file
Refs: #5795
2020-12-14 13:41:10 +01:00
simon lehericey
b19dc34cc1 fix deploy i_am_a_worker_test 2020-12-11 09:50:17 +01:00