Enable duo_features_enabled on seeded project in gitlab:duo:setup
What does this MR do and why?
The gitlab:duo:setup rake task seeds a Duo-licensed group and project for local development. It correctly sets instance-level and group-level duo_features_enabled settings, but did not set the project-level project_setting.duo_features_enabled.
The Project.with_duo_features_enabled scope (used by EE::ProjectsFinder#by_duo_licensed_feature) joins directly on project_settings.duo_features_enabled = true and does not honor namespace inheritance. This caused the seeded gitlab-duo/test project to be excluded from finders using duo_licensed_feature -- concretely, it did not appear in the AI Catalog 'Enable' project dropdown.
Fix: Add ensure_project_settings! to BaseStrategy in setup.rb that enables duo_features_enabled on the seeded project after seed_data runs. Call it from both SelfManagedStrategy and GitlabComStrategy.
References
Screenshots or screen recordings
N/A -- development tooling change only.
How to set up and validate locally
These steps create a new project with a different path, so an existing gitlab-duo/test project is not modified.
Notes:
- The group path defaults to
gitlab-duo(settable withGITLAB_DUO_GROUP_PATH). - The project path defaults to
test(settable withGITLAB_DUO_PROJECT_PATH). - The dropdown finder only shows projects where the user is a Maintainer or higher, and only group-namespace projects.
1. Check out the branch
git checkout duo/fix/600891-duo-setup-project-setting-duo-features-enabled2. Run the setup task with a new project path
GITLAB_DUO_PROJECT_PATH=duo-fix-test bundle exec rake "gitlab:duo:setup"This creates gitlab-duo/duo-fix-test. An existing gitlab-duo/test project is not modified.
The output should include this line:
Enabling project-level Duo features setting....3. Confirm the setting in the Rails console
p = Project.find_by_full_path('gitlab-duo/duo-fix-test')
p.project_setting.duo_features_enabled # => true
Project.with_duo_features_enabled.include?(p) # => true4. Confirm in the UI
As a user with Maintainer or higher on gitlab-duo/duo-fix-test, open the AI Catalog and start the "Enable" flow on an agent or flow. The project should appear in the dropdown.
5. Run the test
bundle exec rspec ee/spec/lib/gitlab/duo/developments/setup_spec.rbThe new shared example enables duo_features_enabled on the seeded project runs under both SelfManagedStrategy and GitlabComStrategy contexts.
Old repro steps
- Run
bundle exec rake "gitlab:duo:setup" - In rails console, verify:
Project.find_by_full_path('gitlab-duo/test').project_setting.duo_features_enabledreturnstrue - Visit the AI Catalog 'Enable' project dropdown -- the
gitlab-duo/testproject should appear without any manual rails-console intervention.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.