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
fce20855
Commit
fce20855
authored
Sep 16, 2019
by
Mark Chao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Accept string for required_minimum_access_level
Add spec
parent
715655f0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
1 deletion
+26
-1
app/models/project_feature.rb
app/models/project_feature.rb
+2
-1
spec/models/project_feature_spec.rb
spec/models/project_feature_spec.rb
+24
-0
No files found.
app/models/project_feature.rb
View file @
fce20855
...
...
@@ -62,7 +62,8 @@ class ProjectFeature < ApplicationRecord
private
def
ensure_feature!
(
feature
)
feature
=
feature
.
model_name
.
plural
.
to_sym
if
feature
.
respond_to?
(
:model_name
)
feature
=
feature
.
model_name
.
plural
if
feature
.
respond_to?
(
:model_name
)
feature
=
feature
.
to_sym
raise
ArgumentError
,
"invalid project feature:
#{
feature
}
"
unless
FEATURES
.
include?
(
feature
)
feature
...
...
spec/models/project_feature_spec.rb
View file @
fce20855
...
...
@@ -228,4 +228,28 @@ describe ProjectFeature do
end
end
end
describe
'.required_minimum_access_level'
do
it
'handles reporter level'
do
expect
(
described_class
.
required_minimum_access_level
(
:merge_requests
)).
to
eq
(
Gitlab
::
Access
::
REPORTER
)
end
it
'handles guest level'
do
expect
(
described_class
.
required_minimum_access_level
(
:issues
)).
to
eq
(
Gitlab
::
Access
::
GUEST
)
end
it
'accepts ActiveModel'
do
expect
(
described_class
.
required_minimum_access_level
(
MergeRequest
)).
to
eq
(
Gitlab
::
Access
::
REPORTER
)
end
it
'accepts string'
do
expect
(
described_class
.
required_minimum_access_level
(
'merge_requests'
)).
to
eq
(
Gitlab
::
Access
::
REPORTER
)
end
it
'raises error if feature is invalid'
do
expect
do
described_class
.
required_minimum_access_level
(
:foos
)
end
.
to
raise_error
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