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
7b621c27
Commit
7b621c27
authored
Sep 16, 2019
by
Mark Chao
Committed by
Bob Van Landuyt
Oct 01, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Accept string for required_minimum_access_level
Add spec
parent
9e27f0d9
Changes
2
Show 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 @
7b621c27
...
@@ -62,7 +62,8 @@ class ProjectFeature < ApplicationRecord
...
@@ -62,7 +62,8 @@ class ProjectFeature < ApplicationRecord
private
private
def
ensure_feature!
(
feature
)
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
)
raise
ArgumentError
,
"invalid project feature:
#{
feature
}
"
unless
FEATURES
.
include?
(
feature
)
feature
feature
...
...
spec/models/project_feature_spec.rb
View file @
7b621c27
...
@@ -228,4 +228,28 @@ describe ProjectFeature do
...
@@ -228,4 +228,28 @@ describe ProjectFeature do
end
end
end
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
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