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
25aeb732
Commit
25aeb732
authored
May 27, 2020
by
Małgorzata Ksionek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add small alterations for better readability
Fix condition Add cr remarks Add cr remarks Add cr remarks
parent
076d4f7d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
67 deletions
+73
-67
ee/app/policies/ee/project_policy.rb
ee/app/policies/ee/project_policy.rb
+18
-11
ee/app/views/groups/push_rules/edit.html.haml
ee/app/views/groups/push_rules/edit.html.haml
+1
-1
ee/spec/controllers/projects/push_rules_controller_spec.rb
ee/spec/controllers/projects/push_rules_controller_spec.rb
+1
-1
ee/spec/services/projects/create_service_spec.rb
ee/spec/services/projects/create_service_spec.rb
+53
-54
No files found.
ee/app/policies/ee/project_policy.rb
View file @
25aeb732
...
@@ -99,7 +99,13 @@ module EE
...
@@ -99,7 +99,13 @@ module EE
end
end
end
end
with_scope
:subject
condition
(
:can_change_reject_unsigned_commits
)
do
admin?
||
(
can?
(
:maintainer_access
)
&&
reject_unsigned_commits_disabled_globally?
&&
reject_unsigned_commits_disabled_by_group?
)
end
condition
(
:commit_committer_check_disabled_by_group
)
do
condition
(
:commit_committer_check_disabled_by_group
)
do
if
group_push_rule_present?
if
group_push_rule_present?
!
subject
.
group
.
push_rule
.
commit_committer_check
!
subject
.
group
.
push_rule
.
commit_committer_check
...
@@ -113,6 +119,13 @@ module EE
...
@@ -113,6 +119,13 @@ module EE
@subject
.
feature_available?
(
:commit_committer_check
)
@subject
.
feature_available?
(
:commit_committer_check
)
end
end
condition
(
:can_change_commit_commiter_check
)
do
admin?
||
(
can?
(
:maintainer_access
)
&&
commit_committer_check_disabled_globally?
&&
commit_committer_check_disabled_by_group?
)
end
with_scope
:subject
with_scope
:subject
condition
(
:reject_unsigned_commits_available
)
do
condition
(
:reject_unsigned_commits_available
)
do
@subject
.
feature_available?
(
:reject_unsigned_commits
)
@subject
.
feature_available?
(
:reject_unsigned_commits
)
...
@@ -301,23 +314,17 @@ module EE
...
@@ -301,23 +314,17 @@ module EE
rule
{
~
can?
(
:push_code
)
}.
prevent
:push_code_to_protected_branches
rule
{
~
can?
(
:push_code
)
}.
prevent
:push_code_to_protected_branches
rule
{
admin
|
(
reject_unsigned_commits_disabled_globally
&
reject_unsigned_commits_disabled_by_group
&
can?
(
:maintainer_access
))
}.
enable
:change_reject_unsigned_commits
rule
{
can_change_reject_unsigned_commits
}.
enable
:change_reject_unsigned_commits
rule
{
reject_unsigned_commits_available
}.
enable
:read_reject_unsigned_commits
rule
{
reject_unsigned_commits_available
}.
enable
:read_reject_unsigned_commits
rule
{
~
reject_unsigned_commits_available
}.
prevent
:change_reject_unsigned_commits
rule
{
~
reject_unsigned_commits_available
}.
prevent
:change_reject_unsigned_commits
rule
{
admin
|
(
commit_committer_check_disabled_globally
&
commit_committer_check_disabled_by_group
&
can?
(
:maintainer_access
))
}.
policy
do
rule
{
can_change_commit_commiter_check
}.
enable
:change_commit_committer_check
enable
:change_commit_committer_check
end
rule
{
commit_committer_check_available
}.
policy
do
rule
{
commit_committer_check_available
}.
enable
:read_commit_committer_check
enable
:read_commit_committer_check
end
rule
{
~
commit_committer_check_available
}.
policy
do
rule
{
~
commit_committer_check_available
}.
prevent
:change_commit_committer_check
prevent
:change_commit_committer_check
end
rule
{
owner
|
reporter
}.
enable
:build_read_project
rule
{
owner
|
reporter
}.
enable
:build_read_project
...
...
ee/app/views/groups/push_rules/edit.html.haml
View file @
25aeb732
-
page_title
"Push Rules"
-
page_title
_
(
"Push Rules"
)
%h3
%h3
=
_
(
"Pre-defined push rules."
)
=
_
(
"Pre-defined push rules."
)
%p
.light
%p
.light
...
...
ee/spec/controllers/projects/push_rules_controller_spec.rb
View file @
25aeb732
...
@@ -39,8 +39,8 @@ describe Projects::PushRulesController do
...
@@ -39,8 +39,8 @@ describe Projects::PushRulesController do
shared_examples
'updateable setting'
do
|
rule_attr
,
updates
,
new_value
|
shared_examples
'updateable setting'
do
|
rule_attr
,
updates
,
new_value
|
it
"
#{
updates
?
'updates'
:
'does not update'
}
the setting"
do
it
"
#{
updates
?
'updates'
:
'does not update'
}
the setting"
do
patch
:update
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
1
,
push_rule:
{
rule_attr
=>
new_value
}
}
patch
:update
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
1
,
push_rule:
{
rule_attr
=>
new_value
}
}
be_new
,
be_old
=
new_value
?
[
be_truthy
,
be_falsy
]
:
[
be_falsy
,
be_truthy
]
be_new
,
be_old
=
new_value
?
[
be_truthy
,
be_falsy
]
:
[
be_falsy
,
be_truthy
]
expect
(
project
.
reload_push_rule
.
public_send
(
rule_attr
)).
to
(
updates
?
be_new
:
be_old
)
expect
(
project
.
reload_push_rule
.
public_send
(
rule_attr
)).
to
(
updates
?
be_new
:
be_old
)
end
end
end
end
...
...
ee/spec/services/projects/create_service_spec.rb
View file @
25aeb732
...
@@ -223,6 +223,13 @@ describe Projects::CreateService, '#execute' do
...
@@ -223,6 +223,13 @@ describe Projects::CreateService, '#execute' do
end
end
end
end
context
'when there are no push rules'
do
it
'does not create push rule'
do
expect
(
create_project
(
user
,
opts
).
push_rule
).
to
be_nil
end
end
end
context
'group push rules'
do
context
'group push rules'
do
before
do
before
do
stub_licensed_features
(
push_rules:
true
)
stub_licensed_features
(
push_rules:
true
)
...
@@ -242,11 +249,10 @@ describe Projects::CreateService, '#execute' do
...
@@ -242,11 +249,10 @@ describe Projects::CreateService, '#execute' do
end
end
context
'when group has push rule defined'
do
context
'when group has push rule defined'
do
let
(
:
push_rule
)
{
create
(
:push_rule_without_project
,
force_push_regex:
'testing me'
)
}
let
(
:group_
push_rule
)
{
create
(
:push_rule_without_project
,
force_push_regex:
'testing me'
)
}
before
do
before
do
group
.
update!
(
push_rule:
push_rule
)
group
.
update!
(
push_rule:
group_push_rule
)
group
.
add_owner
(
user
)
end
end
it
'creates push rule from group push rule'
do
it
'creates push rule from group push rule'
do
...
@@ -254,10 +260,10 @@ describe Projects::CreateService, '#execute' do
...
@@ -254,10 +260,10 @@ describe Projects::CreateService, '#execute' do
project_push_rule
=
project
.
push_rule
project_push_rule
=
project
.
push_rule
expect
(
project_push_rule
).
to
have_attributes
(
expect
(
project_push_rule
).
to
have_attributes
(
force_push_regex:
push_rule
.
force_push_regex
,
force_push_regex:
group_
push_rule
.
force_push_regex
,
deny_delete_tag:
push_rule
.
deny_delete_tag
,
deny_delete_tag:
group_
push_rule
.
deny_delete_tag
,
delete_branch_regex:
push_rule
.
delete_branch_regex
,
delete_branch_regex:
group_
push_rule
.
delete_branch_regex
,
commit_message_regex:
push_rule
.
commit_message_regex
,
commit_message_regex:
group_
push_rule
.
commit_message_regex
,
is_sample:
false
is_sample:
false
)
)
expect
(
project
.
project_setting
.
push_rule_id
).
to
eq
(
project_push_rule
.
id
)
expect
(
project
.
project_setting
.
push_rule_id
).
to
eq
(
project_push_rule
.
id
)
...
@@ -281,7 +287,7 @@ describe Projects::CreateService, '#execute' do
...
@@ -281,7 +287,7 @@ describe Projects::CreateService, '#execute' do
end
end
end
end
context
'when group has not
push rule defined'
do
context
'when group does not have
push rule defined'
do
let!
(
:sample
)
{
create
(
:push_rule_sample
)
}
let!
(
:sample
)
{
create
(
:push_rule_sample
)
}
it
'creates push rule from sample'
do
it
'creates push rule from sample'
do
...
@@ -296,13 +302,6 @@ describe Projects::CreateService, '#execute' do
...
@@ -296,13 +302,6 @@ describe Projects::CreateService, '#execute' do
end
end
end
end
context
'when there are no push rules'
do
it
'does not create push rule'
do
expect
(
create_project
(
user
,
opts
).
push_rule
).
to
be_nil
end
end
end
context
'when running on a primary node'
do
context
'when running on a primary node'
do
let_it_be
(
:primary
)
{
create
(
:geo_node
,
:primary
)
}
let_it_be
(
:primary
)
{
create
(
:geo_node
,
:primary
)
}
let_it_be
(
:secondary
)
{
create
(
:geo_node
)
}
let_it_be
(
:secondary
)
{
create
(
:geo_node
)
}
...
...
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