Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

avoid AnonymousUser persisting in after(:all) block

ulferts6f5095a83748
diff --git a/modules/storages/spec/requests/api/v3/file_links/file_links_api_spec.rb b/modules/storages/spec/requests/api/v3/file_links/file_links_api_spec.rb
index ea1b4112221..359a82c1c0f 100644
--- a/modules/storages/spec/requests/api/v3/file_links/file_links_api_spec.rb
+++ b/modules/storages/spec/requests/api/v3/file_links/file_links_api_spec.rb
@@ -36,13 +36,13 @@ RSpec.describe 'API v3 file links resource' do
include UserPermissionsHelper
def enable_module(project, modul)
- project.enabled_module_names = project.enabled_module_names + [modul]
- project.save
+ project.enabled_modules.create(name: modul)
end
def disable_module(project, modul)
- project.enabled_module_names = project.enabled_module_names - [modul]
- project.save
+ # Avoid project.enabled_module_names and a subsequent save as that would create an AnonymousUser in an
+ # after(:all) block, which persists the user in the RequestStore.
+ project.enabled_modules.detect { |m| m.name == modul }.destroy
end
shared_association_default(:priority) { create(:priority) }