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
8deb9f8f
Commit
8deb9f8f
authored
Jan 21, 2020
by
Małgorzata Ksionek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new methods to project and specs
Refactor model method and spec
parent
0c07b9d5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
105 additions
and
0 deletions
+105
-0
ee/app/models/ee/project.rb
ee/app/models/ee/project.rb
+21
-0
ee/spec/models/project_spec.rb
ee/spec/models/project_spec.rb
+84
-0
No files found.
ee/app/models/ee/project.rb
View file @
8deb9f8f
...
...
@@ -723,6 +723,27 @@ module EE
packages
.
where
(
package_type:
package_type
).
exists?
end
def
disable_overriding_approvers_per_merge_request
return
self
[
:disable_overriding_approvers_per_merge_request
]
unless
License
.
feature_available?
(
:merge_request_approvers_rules
)
::
Gitlab
::
CurrentSettings
.
disable_overriding_approvers_per_merge_request?
||
self
[
:disable_overriding_approvers_per_merge_request
]
end
def
merge_requests_author_approval
return
self
[
:merge_requests_author_approval
]
unless
License
.
feature_available?
(
:merge_request_approvers_rules
)
return
false
if
::
Gitlab
::
CurrentSettings
.
prevent_merge_requests_author_approval?
self
[
:merge_requests_author_approval
]
end
def
merge_requests_disable_committers_approval
return
self
[
:merge_requests_disable_committers_approval
]
unless
License
.
feature_available?
(
:merge_request_approvers_rules
)
::
Gitlab
::
CurrentSettings
.
prevent_merge_requests_committers_approval?
||
self
[
:merge_requests_disable_committers_approval
]
end
def
license_compliance
strong_memoize
(
:license_compliance
)
{
SCA
::
LicenseCompliance
.
new
(
self
)
}
end
...
...
ee/spec/models/project_spec.rb
View file @
8deb9f8f
...
...
@@ -482,6 +482,90 @@ describe Project do
end
end
context
'merge requests related settings'
do
shared_examples
'setting modified by application setting'
do
context
'final setting'
do
using
RSpec
::
Parameterized
::
TableSyntax
where
(
:app_setting
,
:project_setting
,
:feature_enabled
,
:final_setting
)
do
true
|
true
|
true
|
true
false
|
true
|
true
|
true
true
|
false
|
true
|
true
false
|
false
|
true
|
false
true
|
true
|
false
|
true
false
|
true
|
false
|
true
true
|
false
|
false
|
false
false
|
false
|
false
|
false
end
with_them
do
let
(
:project
)
{
create
(
:project
)
}
before
do
stub_licensed_features
(
feature
=>
feature_enabled
)
stub_application_setting
(
application_setting
=>
app_setting
)
project
.
update
(
setting
=>
project_setting
)
end
it
'shows proper setting'
do
expect
(
project
.
send
(
setting
)).
to
eq
(
final_setting
)
end
end
end
end
describe
'#disable_overriding_approvers_per_merge_request'
do
it_behaves_like
'setting modified by application setting'
do
let
(
:feature
)
{
:merge_request_approvers_rules
}
let
(
:setting
)
{
:disable_overriding_approvers_per_merge_request
}
let
(
:application_setting
)
{
:disable_overriding_approvers_per_merge_request
}
end
end
describe
'#merge_requests_disable_committers_approval'
do
it_behaves_like
'setting modified by application setting'
do
let
(
:feature
)
{
:merge_request_approvers_rules
}
let
(
:setting
)
{
:merge_requests_disable_committers_approval
}
let
(
:application_setting
)
{
:prevent_merge_requests_committers_approval
}
end
end
describe
'#merge_requests_author_approval'
do
context
'final setting'
do
using
RSpec
::
Parameterized
::
TableSyntax
where
(
:app_setting
,
:project_setting
,
:feature_enabled
,
:final_setting
)
do
true
|
true
|
true
|
false
false
|
true
|
true
|
true
true
|
false
|
true
|
false
false
|
false
|
true
|
false
true
|
true
|
false
|
true
false
|
true
|
false
|
true
true
|
false
|
false
|
false
false
|
false
|
false
|
false
end
with_them
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:feature
)
{
:merge_request_approvers_rules
}
let
(
:setting
)
{
:merge_requests_author_approval
}
let
(
:application_setting
)
{
:prevent_merge_requests_author_approval
}
before
do
stub_licensed_features
(
feature
=>
feature_enabled
)
stub_application_setting
(
application_setting
=>
app_setting
)
project
.
update
(
setting
=>
project_setting
)
end
it
'shows proper setting'
do
expect
(
project
.
send
(
setting
)).
to
eq
(
final_setting
)
end
end
end
end
end
describe
'#has_active_hooks?'
do
context
"with group hooks"
do
let
(
:group
)
{
create
(
:group
)
}
...
...
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