Skip to content

[63434] Fix user with a particular set of permissions seeing errors when updating work packages dates #18658

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

cbliard
Copy link
Member

@cbliard cbliard commented Apr 16, 2025

Ticket

https://community.openproject.org/wp/63434

What are you trying to accomplish?

The wrong permissions are checked in the date picker. It always checks for add_work_packages, but it should also check for edit_work_packages when it's an update.

Screenshots

image

What approach did you choose and why?

Use correct contract when calling SetAttributesService: either UpdateContract when editing an existing work package or CreateContract when being with a new work package.

I also revised the routing as there was something odd going on when trying to add a controller spec for DatePickerController. I kept having some "no route exists" for new action, so I made it a bit more sane by:

  • changing route path from .../datepicker_dialog_content to .../date_picker to match controller name and make things easier to find when navigating code.
  • moving new action for date_picker to the collection level of work_packages scope.
  • moving new action for progress to the collection level of work_packages scope.

Merge checklist

  • Added/updated tests
  • Added/updated documentation in Lookbook (patterns, previews, etc)
  • Tested major browsers (Chrome, Firefox, Edge, ...)

cbliard added 3 commits April 16, 2025 09:16
Having the route being `datepicker_dialog_content` leads to looking for
a `DatepickerDialogContentController`, but that would be wrong as the
controller is `DatePickerController`. That's not coherent. That's why
routes were moved to `date_picker` so that the routes and the controller
are named the same

Also moved the `new` action to the collection level so that it does not
need a dummy `work_package_id` with value `new` anymore.
It does not need a dummy `work_package_id` with value `new` to render
the preview for a work package creation.

Refactored the `DialogPreviewController` to simplify the logic used to
compute the preview url.
@cbliard cbliard force-pushed the bug/63434-user-with-a-particular-set-of-permissions-sees-error-when-updating-wp-dates branch from c57c2a0 to bf7c253 Compare April 17, 2025 09:17
https://community.openproject.org/wp/63434

The contract class being used was always `WorkPackages::CreateContract`.
It needs to be `WorkPackages::UpdateContract` when the user edits fields
so that the correct permissions are checked.

Also added a spec for the date picker controller.
@cbliard cbliard marked this pull request as ready for review April 17, 2025 09:49
@cbliard cbliard added this to the 16.0.x milestone Apr 17, 2025
cbliard added a commit that referenced this pull request Apr 17, 2025
Seen through a flaky spec: `modules/boards/spec/features/board_enterprise_spec.rb:63`
on job https://github.com/opf/openproject/actions/runs/14512895098/job/40715394915
on PR #18658

Reproduction command that worked on my machine:

```
OPENPROJECT_TESTING_NO_HEADLESS=1 CI=true rspec -fd './modules/boards/spec/features/board_enterprise_spec.rb[1:1:2]' './modules/calendar/spec/features/calendar_widget_spec.rb[1:5:2:1]' --seed 61699
```

It seems the enterprise banner was always present, but the test
sometimes passed because the banner was not loaded yet when the test
checked for it. It could not be scrolled into but was present.

This commit hides the banner if the current user already has enterprise
edition.
@cbliard
Copy link
Member Author

cbliard commented Apr 17, 2025

Fix the flaky spec in another PR.

oliverguenther pushed a commit that referenced this pull request Apr 22, 2025
Seen through a flaky spec: `modules/boards/spec/features/board_enterprise_spec.rb:63`
on job https://github.com/opf/openproject/actions/runs/14512895098/job/40715394915
on PR #18658

Reproduction command that worked on my machine:

```
OPENPROJECT_TESTING_NO_HEADLESS=1 CI=true rspec -fd './modules/boards/spec/features/board_enterprise_spec.rb[1:1:2]' './modules/calendar/spec/features/calendar_widget_spec.rb[1:5:2:1]' --seed 61699
```

It seems the enterprise banner was always present, but the test
sometimes passed because the banner was not loaded yet when the test
checked for it. It could not be scrolled into but was present.

This commit hides the banner if the current user already has enterprise
edition.
@cbliard
Copy link
Member Author

cbliard commented Apr 22, 2025

The failing spec ./modules/boards/spec/features/board_enterprise_spec.rb:63 is a flaky one which has been fixed in another PR.
Merging.

@cbliard cbliard merged commit c69ee44 into dev Apr 22, 2025
22 of 23 checks passed
@cbliard cbliard deleted the bug/63434-user-with-a-particular-set-of-permissions-sees-error-when-updating-wp-dates branch April 22, 2025 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

2 participants