Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
1e126638
Commit
1e126638
authored
Apr 19, 2022
by
Alex Kalderimis
Committed by
Brett Walker
Apr 19, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Freeze the authorize value to prevent changes
parent
c153ce12
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
5 deletions
+6
-5
app/graphql/types/base_object.rb
app/graphql/types/base_object.rb
+3
-1
spec/graphql/types/base_object_spec.rb
spec/graphql/types/base_object_spec.rb
+3
-4
No files found.
app/graphql/types/base_object.rb
View file @
1e126638
...
...
@@ -10,7 +10,9 @@ module Types
edge_type_class
Types
::
BaseEdge
def
self
.
authorize
(
*
args
)
@authorize_args
=
args
if
args
.
any?
raise
'Cannot redefine authorize'
if
@authorize_args
&&
args
.
any?
@authorize_args
=
args
.
freeze
if
args
.
any?
@authorize_args
||
(
superclass
.
respond_to?
(
:authorize
)
?
superclass
.
authorize
:
nil
)
end
...
...
spec/graphql/types/base_object_spec.rb
View file @
1e126638
...
...
@@ -442,11 +442,10 @@ RSpec.describe Types::BaseObject do
expect
(
described_class
.
authorize
).
to
be_nil
expect
(
read_only_type
.
authorize
).
to
match_array
[
:read_only
]
expect
(
inherited_read_only_type
.
authorize
).
to
match_array
[
:read_only
]
end
read_only_type
.
authorize
(
:write_only
)
expect
(
read_only_type
.
authorize
).
to
match_array
[
:write_only
]
expect
(
inherited_read_only_type
.
authorize
).
to
match_array
[
:write_only
]
it
'can not redefine the authorize value'
do
expect
{
read_only_type
.
authorize
(
:write_only
)
}.
to
raise_error
(
'Cannot redefine authorize'
)
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment