43 Commits

Author SHA1 Message Date
Dombi Attila c4ceaf37e9 Fix delete service spec 2025-10-14 12:01:58 +02:00
Dombi Attila f4847b7497 Fix specs by triggering custom field validation. 2025-10-14 12:01:58 +02:00
Jan Sandbrink 0b87e7543f Freeze string literals in specs
Rolling out frozen string literals further by freezing all
string literals in core specs.
2025-05-05 09:29:55 +02:00
Dombi Attila 9412dc226d [#60122] Required custom fields prevent a WorkPackage from being added as a child
https://community.openproject.org/work_packages/60122
2025-03-21 12:53:26 +02:00
Christophe Bliard d47295bafb [61979] Switch successor to automatic mode even without rescheduling
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.
2025-03-17 11:46:41 +01:00
Christophe Bliard b739c997c4 Ignore predecessors of manually scheduled parents
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.
2025-02-25 09:18:27 +01:00
Christophe Bliard 3c5a6f50d5 Switch to manual scheduling mode during rescheduling of dependencies
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.
2025-02-25 09:18:26 +01:00
Christophe Bliard 5fef66cca1 Better handle rescheduling with work packages switching to automatic
There was a bug where a parent of a work package switching to automatic
would not be properly rescheduled.
2025-02-25 09:18:25 +01:00
Christophe Bliard fd24cc538d Make WorkPackage factory use default factory for type if one is defined
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.
2025-02-25 09:12:31 +01:00
Christophe Bliard 311ce0fea4 [59539] Reschedule successor when deleting a follows relation
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.
2025-02-25 09:12:31 +01:00
Christophe Bliard 6daf60e70e Add missing magic comment # frozen_string_literal: true 2025-02-25 09:12:27 +01:00
Christophe Bliard 612474c6e4 Fix unit tests broken by previous commit 2025-02-25 09:12:25 +01:00
Christophe Bliard 26fbc5522a [59539] switch scheduling mode when modifying follows relations
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.
2025-02-25 09:12:25 +01:00
Ivan Kuchin 4911b8a149 remove years from copyrights (except for COPYRIGHT file) 2024-07-31 15:02:49 +02:00
Oliver Günther e3e8d78972 Rename delay to lag
https://community.openproject.org/work_packages/44054
2024-04-08 19:31:38 +02:00
ulferts 3b2121f733 Revert "Merge remote-tracking branch 'origin/release/13.4' into dev"
This reverts commit 40b2bbeb09, reversing
changes made to b4c6cb17cc.
2024-03-21 11:31:17 +01:00
Ivan Kuchin 7787e457a3 Revert "Merge branch 'dev' into release/13.4"
This reverts commit a901541269, reversing
changes made to e573ca00b7.
2024-03-20 20:19:08 +01:00
Ivan Kuchin 9e4934cd0a change quotes using rubocop --only Style/StringLiterals,Style/QuotedSymbols -a 2024-03-20 18:05:22 +01:00
Christophe Bliard 8fa8584538 Run rubocop --autocorrect on all files
Only the safe cops have run. rubocop version is 1.59.0.
2024-01-05 15:27:09 +01:00
Christophe Bliard c795874f7f Update copyright year for 2024
command used: `rg -l 'Copyright \(C\) 2012-202\d the OpenProject' | xargs -n 100 sed -i -r 's/Copyright \(C\) 2012-202. the OpenProject/Copyright (C) 2012-2024 the OpenProject/'`
2024-01-02 16:23:54 +01:00
ulferts d2ea6e9f66 remove typed_dag error handling - no longer raisable 2023-10-24 11:53:17 +02:00
Klaus Zanders 27bdc1a1b9 Fix other intances where an entire suite of cops was disabled 2023-08-14 11:34:53 +02:00
Christophe Bliard 4c2a9d0aa8 Enable RSpec zero monkey patching mode
The plan for RSpec 4.0 is to disable monkey patching.

See https://github.com/rspec/rspec-core/blob/main/features/configuration/zero_monkey_patching_mode.feature for details.
2023-05-31 19:22:29 +02:00
Christophe Bliard 21a696ef9b Update copyright information for 2023 2022-12-30 15:51:26 +01:00
Christophe Bliard b50855a955 Use ServiceResult factory methods where possible
All was automatic through the use of `rubocop --autocorrect --only
OpenProject/UseServiceResultFactoryMethods app lib lib_static modules
spec`.
2022-06-16 10:01:57 +02:00
Christophe Bliard c6e44141db Remove :stubbed_work_package factory
Using build_stubbed(:work_package) works equally well.

Relates to commit e1607a6116
2022-06-08 15:24:11 +02:00
Christophe Bliard 48a4f1b6ad lint with rubocop --autocorrect (safe cops only) 2022-06-02 10:40:10 +02:00
Christophe Bliard a33524ef6d remove ruby magic comment for utf-8
ruby interprets source encoding as utf-8 since 2.0.0, making magic comment redundant and useless
2022-03-10 19:36:58 +01:00
Christophe Bliard bc8d423ec2 update copyright information for 2022 2022-03-01 17:05:59 +01:00
Christophe Bliard 47a297daae Fix argument alignment since f08bea3467 (#10129)
* 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
2022-02-02 21:48:06 +01:00
Oliver Günther f08bea3467 Remove FactoryBot.* prefix where applicable 2022-01-25 08:19:06 +01:00
ulferts 8d72897f62 use standard interface for relation create service 2021-12-06 11:29:38 +01:00
Oliver Günther ccfa29c728 Move license and copyright docs to root, fix names and references 2021-09-02 21:50:46 +02:00
ulferts 7ecf08e005 rework changed_by_system (#9043)
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.
2021-03-02 16:20:19 +01:00
ulferts 6140f4c7e9 update copyright to 2021 (#8925)
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
2021-01-13 17:47:45 +01:00
Henriette Dinger bd7f4e4814 Update copyright notice 2020-01-15 11:31:26 +01:00
ulferts 481fe5b291 use default end points for most of the relations api 2019-12-11 10:19:39 +01:00
ulferts 273402e20c stabilize flickering request spec 2019-12-03 15:44:41 +01:00
ulferts cd3ffe0cc5 adapt specs to altered interface 2019-11-01 13:14:18 +01:00
ulferts 05a93695d4 automatically reverse relates relationship 2019-05-27 10:22:58 +02:00
Oliver Günther 059770f533 FactoryGirl => FactoryBot
Removes the deprecation
2018-05-07 22:38:20 +02:00
Oliver Günther 6ef4211e77 Bump copyright to 2018 (#6171)
[ci skip]
2018-02-12 08:51:12 +01:00
Jens Ulferts 690e0ffc60 wp create/update/destroy via services 2017-11-29 15:27:29 +01:00