Commit graph

25 commits

Author SHA1 Message Date
Pierre de La Morinerie
9fd38cae5e specs: migrate from features to system specs
System specs have been available since Rails 5.1, and are better
integrated with the Rails framework.

- Rename `spec/features` to `spec/system`
- Rename `feature do` to `describe do`
- Configure Capybara for system specs

Steps mostly taken from https://medium.com/table-xi/a-quick-guide-to-rails-system-tests-in-rspec-b6e9e8a8b5f6
2021-10-26 12:24:46 +02:00
Pierre de La Morinerie
b5bde6608c routes: replace the email param in the Avis URLs by a query param 2021-06-17 11:15:51 +02:00
François Vantomme
c9b1095d1e Refactor (Rubocop): replace map{ … }.compact by filter_map
In Ruby 2.7, Enumerable#filter_map has been added.
This cop identifies places where map { … }.compact can be replaced by filter_map.

See: https://docs.rubocop.org/rubocop-performance/cops_performance.html#performancemapcompact
2021-06-11 15:38:09 +02:00
Paul Chavard
9b0dae4cc2 Fix apostrophes ‘ -> ’ 2021-05-26 18:05:14 +02:00
Christophe Robillard
f40d96fbd2 Revert "Revert "Export de tous les dossier d'une démarche""
This reverts commit d9a588b52e.
2021-04-29 17:29:47 +02:00
krichtof
d9a588b52e
Revert "Export de tous les dossier d'une démarche" 2021-04-29 16:07:18 +02:00
Christophe Robillard
fba0d78153 generate pdf export inside pieces_justificatives_service 2021-04-28 11:40:58 +02:00
Pierre de La Morinerie
7ee29b2190 spec: fix flaky expert test
In this test, two Avis are created for each expert:
- one for the original dossier,
- one for the dossier linked to the original dossier.

When we check for a sign-up link, we should do so using the
Avis for the original dossier explicitely.
2021-04-20 12:06:12 +02:00
kara Diaby
8a1cdf31e3 tests 2021-04-06 10:38:46 +02:00
Pierre de La Morinerie
f6f013e87f specs: fix Avis query in specs 2021-03-25 13:24:53 +01:00
Paul Chavard
0b22788d60 experts_procedure should not be optional 2021-03-23 13:46:33 +01:00
kara Diaby
bb47c88c5f fix expert spec feature 2021-03-18 14:36:08 +01:00
kara Diaby
81f5a5254b tests 2021-03-18 11:38:52 +01:00
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
clemkeirua
c91e231347 spec: replace reference to ds in password 2020-07-23 16:20:16 +02:00
Christophe Robillard
63dd71aed4 display all avis for an expert 2020-06-30 09:17:27 +02:00
Christophe Robillard
c565c9c87b refactor sign_up_instructeur_avis_url 2020-06-30 09:17:27 +02:00
Pierre de La Morinerie
4cb747fdb6 specs: always require rails_helper
Test helpers are separated between two files: spec_helper and
rails_helper. This separation is meant to allow tests that do not
require Rails (like testing standalone libs) to boot faster.

The spec_helper file is always loaded, through `--require spec_helper`
in the `.rspec` config file. When needed, the rails_helper file is
expected to be required manually.

This is fine, but:
- Many test files have a redundant `require 'spec_helper'` line;
- Many test files should require `rails_helper`, but don't.

Not requiring `rails_helper` will cause the Rails-concerned section of
the test environment not to be configured–which may cause subtle bugs
(like the test database not being properly initialized).

Moreover, Spring loads all the Rails files on preloading anyway. So the
gains from using only `spec_helper` are thin.

To streamline this process, this commit:
- Configures `.rspec` to require `rails_helper` by default;
- Remove all manual requires to spec_helper or rails_helper.

Reference: https://stackoverflow.com/questions/24145329/how-is-spec-rails-helper-rb-different-from-spec-spec-helper-rb-do-i-need-it
2020-03-31 12:48:32 +02:00
kara Diaby
b32ed88f9b add attachment when instructor asking for a review 2020-03-04 13:35:29 +00:00
Pierre de La Morinerie
6afddd8647 spec: fix a flaky experts feature spec
When "invite linked dossiers" is checked, the invitation will generate
one avis per dossier (including the linked ones).

So when we retrieve the email send to the expert, and try to match it
with the avis record, we need to specify wich avis (the one for the main
dossier, or for the linked dossier).

Otherwise the test is flaky, and sometimes doesn't match the right avis
with the sent email.
2020-02-18 10:44:44 +00:00
Paul Chavard
7afeae1408 remove dossier.linked_dossiers 2020-02-11 17:49:22 +01:00
Paul Chavard
f0ea96772d Only invite experts to dossiers instructeur have access to 2020-02-11 17:38:57 +01:00
Pierre de La Morinerie
1c61f2de58 views: refactor the attachment/edit view
Make it more reusable, by:

- Renaming `attachment/update` to `attachment/edit`
- Refactoring the CSS styles into their own stylesheet
- Allow to specify the 'accept' option
2019-10-31 10:27:19 +01:00
Paul Chavard
86b271997b Invite experts to linked dossiers
closes #3669
2019-10-23 13:10:09 +02:00
Pierre de La Morinerie
f0c2599d18 specs: improve feature spec for experts
- Move the avis feature spec to a separate file
- Add more test cases
2019-10-21 12:57:10 +02:00