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
d67553d3
Commit
d67553d3
authored
Sep 20, 2021
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests and improve pending builds and project update
parent
d321f552
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
21 deletions
+51
-21
app/services/ci/update_pending_build_service.rb
app/services/ci/update_pending_build_service.rb
+1
-1
app/services/projects/update_service.rb
app/services/projects/update_service.rb
+12
-2
spec/services/projects/update_service_spec.rb
spec/services/projects/update_service_spec.rb
+38
-18
No files found.
app/services/ci/update_pending_build_service.rb
View file @
d67553d3
...
...
@@ -2,7 +2,7 @@
module
Ci
class
UpdatePendingBuildService
VALID_PARAMS
=
%i[instance_runners_enabled]
.
freeze
VALID_PARAMS
=
%i[instance_runners_enabled
namespace_traversal_ids
]
.
freeze
InvalidParamsError
=
Class
.
new
(
StandardError
)
InvalidModelError
=
Class
.
new
(
StandardError
)
...
...
app/services/projects/update_service.rb
View file @
d67553d3
...
...
@@ -191,13 +191,23 @@ module Projects
.
execute
end
def
shared_runners_settings_toggled?
project
.
previous_changes
.
include?
(
:shared_runners_enabled
)
end
def
group_runners_settings_toggled?
return
false
unless
project
.
ci_cd_settings
.
present?
project
.
ci_cd_settings
.
previous_changes
.
include?
(
:group_runners_enabled
)
end
def
runners_settings_toggled?
(
%w[shared_runners_enabled group_runners_enabled]
&
project
.
previous_changes
).
any
?
shared_runners_settings_toggled?
||
group_runners_settings_toggled
?
end
def
group_runner_traversal_ids
if
project
.
group_runners_enabled?
project
.
namespace
.
traversal_ids
project
.
namespace
.
reset
.
traversal_ids
else
[]
end
...
...
spec/services/projects/update_service_spec.rb
View file @
d67553d3
...
...
@@ -443,41 +443,61 @@ RSpec.describe Projects::UpdateService do
context
'when updating runners settings'
do
let
(
:settings
)
do
{
instance_runners_enabled:
true
,
namespace_traversal_ids:
[]
}
{
instance_runners_enabled:
true
,
namespace_traversal_ids:
[
123
]
}
end
let!
(
:pending_build
)
do
create
(
:ci_pending_build
,
project:
project
,
**
settings
)
end
it
'updates builds queue when shared runners get disabled'
do
expect
{
update_project
(
shared_runners_enabled:
false
)
}
.
to
change
{
pending_build
.
reload
.
instance_runners_enabled
}.
to
(
false
)
context
'when project has shared runners enabled'
do
let
(
:project
)
{
create
(
:project
,
shared_runners_enabled:
true
)
}
expect
(
pending_build
.
reload
.
instance_runners_enabled
).
to
be
false
it
'updates builds queue when shared runners get disabled'
do
expect
{
update_project
(
project
,
admin
,
shared_runners_enabled:
false
)
}
.
to
change
{
pending_build
.
reload
.
instance_runners_enabled
}.
to
(
false
)
expect
(
pending_build
.
reload
.
instance_runners_enabled
).
to
be
false
end
end
it
'updates builds queue when shared runners get enabled'
do
expect
{
update_project
(
shared_runners_enabled:
true
)
}
.
to
not_change
{
pending_build
.
reload
.
instance_runners_enabled
}
context
'when project has shared runners disabled'
do
let
(
:project
)
{
create
(
:project
,
shared_runners_enabled:
false
)
}
expect
(
pending_build
.
reload
.
instance_runners_enabled
).
to
be
true
it
'updates builds queue when shared runners get enabled'
do
expect
{
update_project
(
project
,
admin
,
shared_runners_enabled:
true
)
}
.
to
not_change
{
pending_build
.
reload
.
instance_runners_enabled
}
expect
(
pending_build
.
reload
.
instance_runners_enabled
).
to
be
true
end
end
it
'updates builds queue when group runners get dis
abled'
do
update_project
(
group_runners_enabled:
false
)
context
'when project has group runners en
abled'
do
let
(
:project
)
{
create
(
:project
,
group_runners_enabled:
true
)
}
expect
(
pending_build
.
reload
.
namespace_traversal_ids
).
to
be_empty
end
before
do
project
.
ci_cd_settings
.
update!
(
group_runners_enabled:
true
)
end
it
'updates builds queue when group runners get en
abled'
do
update_project
(
group_runners_enabled:
tru
e
)
it
'updates builds queue when group runners get dis
abled'
do
update_project
(
project
,
admin
,
group_runners_enabled:
fals
e
)
expect
(
pending_build
.
reload
.
namespace_traversal_ids
).
not_to
be_empty
expect
(
pending_build
.
reload
.
namespace_traversal_ids
).
to
be_empty
end
end
def
update_project
(
**
params
)
update_project
(
project
,
admin
,
**
params
)
context
'when project has group runners disabled'
do
let
(
:project
)
{
create
(
:project
,
:in_subgroup
,
group_runners_enabled:
false
)
}
before
do
project
.
ci_cd_settings
.
update!
(
group_runners_enabled:
false
)
end
it
'updates builds queue when group runners get enabled'
do
update_project
(
project
,
admin
,
group_runners_enabled:
true
)
expect
(
pending_build
.
reload
.
namespace_traversal_ids
).
to
include
(
project
.
namespace
.
id
)
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