Conversation
DefaultSpace. Use GlobalSpace when spaces dis…
Contributor
There was a problem hiding this comment.
Pull request overview
Separates the “default space” concept (resources with space_id: nil) from a new “global space” concept (all resources), fixing the issue where DefaultSpace incorrectly selected all items when spaces are enabled.
Changes:
- Updated
Space.defaultto returnDefaultSpacewhen spaces are enabled, otherwiseGlobalSpace. - Introduced
GlobalSpaceand refactoredDefaultSpaceto inherit from it while overriding resource relations to scope tospace_id: nil. - Added model tests to validate default space selection and basic resource scoping behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| app/models/space.rb | Switches Space.default implementation to choose between DefaultSpace and GlobalSpace based on the feature flag. |
| app/models/global_space.rb | Adds GlobalSpace implementation that exposes unscoped (“all resources”) relations and site-level metadata. |
| app/models/default_space.rb | Refactors DefaultSpace to inherit from GlobalSpace and overrides relations to filter space_id: nil. |
| app/controllers/application_controller.rb | Adjusts set_current_space behavior when spaces are disabled. |
| test/models/space_test.rb | Adds tests for Space.default selection and validates resource scoping for materials. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of changes
GlobalSpaceandDefaultSpaceconcepts. The former includes all resources, the latter includes only "default space" resources (wherespace_idis null).Motivation and context
#1286
Checklist