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
a1165f69
Commit
a1165f69
authored
Oct 06, 2021
by
Vijay Hawoldar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow minimal access value for UserHighestRole
Changelog: changed EE: true
parent
e9735782
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
1 deletion
+58
-1
app/models/user_highest_role.rb
app/models/user_highest_role.rb
+7
-1
ee/app/models/ee/user_highest_role.rb
ee/app/models/ee/user_highest_role.rb
+16
-0
ee/spec/models/ee/user_highest_role_spec.rb
ee/spec/models/ee/user_highest_role_spec.rb
+9
-0
ee/spec/services/users/update_highest_member_role_service_spec.rb
...services/users/update_highest_member_role_service_spec.rb
+26
-0
No files found.
app/models/user_highest_role.rb
View file @
a1165f69
...
...
@@ -3,7 +3,13 @@
class
UserHighestRole
<
ApplicationRecord
belongs_to
:user
,
optional:
false
validates
:highest_access_level
,
allow_nil:
true
,
inclusion:
{
in:
Gitlab
::
Access
.
all_values
}
validates
:highest_access_level
,
allow_nil:
true
,
inclusion:
{
in:
->
(
_
)
{
self
.
allowed_values
}
}
scope
:with_highest_access_level
,
->
(
highest_access_level
)
{
where
(
highest_access_level:
highest_access_level
)
}
def
self
.
allowed_values
Gitlab
::
Access
.
all_values
end
end
UserHighestRole
.
prepend_mod
ee/app/models/ee/user_highest_role.rb
0 → 100644
View file @
a1165f69
# frozen_string_literal: true
module
EE
module
UserHighestRole
extend
ActiveSupport
::
Concern
class_methods
do
extend
::
Gitlab
::
Utils
::
Override
override
:allowed_values
def
allowed_values
::
Gitlab
::
Access
.
values_with_minimal_access
end
end
end
end
ee/spec/models/ee/user_highest_role_spec.rb
0 → 100644
View file @
a1165f69
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
UserHighestRole
do
describe
'validations'
do
it
{
is_expected
.
to
validate_inclusion_of
(
:highest_access_level
).
in_array
([
nil
,
*
Gitlab
::
Access
.
values_with_minimal_access
])
}
end
end
ee/spec/services/users/update_highest_member_role_service_spec.rb
0 → 100644
View file @
a1165f69
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Users
::
UpdateHighestMemberRoleService
do
let_it_be
(
:user
)
{
create
(
:user
)
}
subject
(
:execute_service
)
{
described_class
.
new
(
user
).
execute
}
describe
'#execute'
do
context
'with an EE-only access level'
do
before
do
allow
(
user
).
to
receive
(
:current_highest_access_level
).
and_return
(
Gitlab
::
Access
::
MINIMAL_ACCESS
)
end
it
'updates the highest access level'
do
user_highest_role
=
create
(
:user_highest_role
,
:guest
,
user:
user
)
expect
{
execute_service
}
.
to
change
{
user_highest_role
.
reload
.
highest_access_level
}
.
from
(
Gitlab
::
Access
::
GUEST
)
.
to
(
Gitlab
::
Access
::
MINIMAL_ACCESS
)
end
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