https://community.openproject.org/wp/61979
Switching to automatic mode was done in `ScheduleDependency` before. As
the scheduling mode was changed outside of the `SetScheduleService`, it
was not seen as a change and no dependent result was saved and
eventually the scheduling mode change was not persisted.
By moving the scheduling mode change to the `SetScheduleService`, the
dependent results are now correctly saved and the scheduling mode change
is persisted.
There was a bug were when considering the indirect predecessors of a
work package, it would consider all ancestors. This was wrong: only the
automatically scheduled ancestors should be considered, and ancestors
after the first manually scheduled ancestor should be ignored.
When a work package no longer have any predecessors (direct or indirect)
nor children, then it must switch to manual scheduling mode to keep its
dates.
This is now handled directly by the `WorkPackages::SetScheduleService`.
This simplifies the logic of `Relations::DeleteService` which no longer
has to switch a successor to manual by itself. It's all handled in the
ScheduleService.
With TestProf, it's possible to define a default factory for a given
factory using `FactoryBot.set_factory_default`. It activates if a
factory is set for a given field, for instance `author factory: :user`.
For work packages, there is no such factory defined for `type` field
because we have a `after_build` hook to use the first project's type.
Nevertheless, when a default factory has been set, we want to use it
instead, especially as getting the first type is not deterministic when
there are multiple types defined.
This commit makes the WorkPackage factory use this factory default for
the `type` field if one is defined.
This fixes flaky test `spec/services/relations/delete_service_spec.rb`
where the wrong type would be used instead of the intended one. I also
updated the position of the type with mandatory custom field to be after
the type task so that it would work even without the default factory.
When there are multiple predecessors for one work package, and one of
them is deleted, the successor must be rescheduled.
Common rescheduling code with `CreateService` and `UpdateService` has
been moved to `Relations::Concerns::Rescheduling` module.
When a work package becomes a successor of another work package, its
scheduling mode is switched to automatic if it has no children so that
it can be scheduled as soon as possible automatically.
Similarly, when a work package is no longer a successor of any other
work package, its scheduling mode is switched to manual if it has no
children and no dates so that it can keep its current dates.
* Fix argument alignment since f08bea3467
The FactoryBot.* prefix has been removed in f08bea3467. Since then
rubocop complains about Layout/ArgumentAlignment. This commit fixes it.
* do not fix alignments for modules/*/spec yet
hoping to be under the limit of 65535 characters for reviewdog to report on rubocop errors
Before, it was implemented by passing the changed attribut keys over to
the contract to whitelist them.
This lead to:
* The contract interface becoming bloated
* Having to rely on the knowledge of the developer not to falsely
whitelist an attribute. The developer would also have to make sure
to not perform a mass assignment after the attribute has been
whitelisted
The new approach it to integrate the behaviour into the model which is
first altered in the service before it is scrutinized in the contract.
The information about the changed attributes is now stored inside the
model which removes the necessity to flag the whitelisted attribute
separately. Additionally, the exact change is tracked. So if an
attribute is set to one value inside a whitelisted block there is no
risk in later on performing a mass assignment.
This comes at the cost of extending the models which is weird also it is
build into the default SetAttributesService so child classes do not have
to worry. One might include the module into every AR model but currently
we only need it for a very specific use case.
Updates the copyright to 2021 for all files that have a copyright. Files in our source code without the copyright header still do not receive one automatically. Additionally, backlisted files are also excluded.
Previously the copyright of chiliproject which references redmine stated a copyright of redmine up to and including 2017 which is not true for the code we have in here. Because of that I changed that to 2013