-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Consistently use Version.visible scope #21716
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
f2bb812 to
85bdc78
Compare
| let(:portfolio) { create(:portfolio, public: false) } | ||
| let(:inaccessible_project) { create(:project, public: false) } | ||
| let(:version) { create(:version, project:, sharing: "system") } | ||
| let(:version) { create(:version, project:) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this surprising. Why would a spec that's designed to show that something might be inaccessibile define the tested version to use sharing: "system", which means that the version is shared system-wide?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently because it was never checked in the API :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. That's what I am hoping for. The worse explanation is usually something like "it's intended, you just don't understand how/why".
But I agree, it probably just was never noticed.
|
The old and the new check is not really equivalent. The I'm not too sure if it makes sense to have a user with |
Thanks for the feedback. Yes this is true, though looking at the failing specs I didn't expect it to be so bad xD
Me neither, but on the other hand we allow for this in our permissions scheme 🤷 And at least one spec relied on it. |
763be76 to
863e3c1
Compare
Previously there was a separate permissions check for /api/v3/versions/:id. This check at least looked like it was inconsistent with the visible-scope. Using the scope both for /api/v3/versions and /api/v3/versions/:id ensures that both will return results consistent with each other. As part of this change, the manage_versions permission was also added into the Version.visible scope and the Version#visible? method, because it was missing so far from those places.
863e3c1 to
fa784d5
Compare
Previously there was a separate permissions check for /api/v3/versions/:id. This check at least looked like it was inconsistent with the visible-scope.
Using the scope both for /api/v3/versions and /api/v3/versions/:id ensures that both will return results consistent with each other.
References
Discovered as a side-find while working on #21661