By default, `has_and_belongs_to_many` properly deletes the record in
the join table.
However, as the association is declared manually with a
`has_many / through`, it doesn't delete the joined record automatically.
As we also lack a foreign-key contraint on the join table, that means
a dangling record remains in the join table.
To fix this, let's declare it a proper `has_and_belongs_to_many`
association, which will let the join record be deleted automatically
on destroy.
feat(expiration_banner): enhance wording of expiration
feat(dossiers/expiration_banner): enhance wording regarding expiration to include duree_conservation_dossiers_dans_ds + extension_conservation, also add spec on expiration_banner for instructeur
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
- rename `dossiers_id_with_notifications` to `followed_dossiers_with_notifications`,
- rename `notifications_per_procedure` to `procedures_with_notifications`,
- return an ActiveRecord::Relation instead of the result of the query, so that the call place can compose it,
- `merge` with the wanted Dossier scope in the call places, don’t bother passing it as a parameter,
- use the “state” (now “scope”) parameter as a scope method that can be just applied on `Dossier`.
It is actually the same thing as Gestionnaire.procedures. It already included the procedures with paths as well as the archived procedures, and in production, there were no Gestionnaire for who procedures was returning a different result than visible_procedures (expect for two baddata brouillon procedures with a nil path).
In addition, Procedure.path is now nonnull, which means the Procedure.avec_lien scope is pointless.
Finally, the current spec showed that the only procedure not visible to the gestion was the one he was not assigned to.