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
d6f6602c
Commit
d6f6602c
authored
Dec 05, 2019
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make preloading tags final step in relation
parent
eacf54fe
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
13 deletions
+31
-13
app/presenters/ci/legacy_stage_presenter.rb
app/presenters/ci/legacy_stage_presenter.rb
+12
-4
app/views/projects/stage/_stage.html.haml
app/views/projects/stage/_stage.html.haml
+3
-3
spec/presenters/ci/legacy_stage_presenter_spec.rb
spec/presenters/ci/legacy_stage_presenter_spec.rb
+16
-6
No files found.
app/presenters/ci/legacy_stage_presenter.rb
View file @
d6f6602c
...
...
@@ -4,16 +4,24 @@ module Ci
class
LegacyStagePresenter
<
Gitlab
::
View
::
Presenter
::
Delegated
presents
:legacy_stage
def
preloaded_statuses
legacy_stage
.
statuses
.
tap
do
|
statuses
|
def
latest_ordered_statuses
preload_statuses
(
legacy_stage
.
statuses
.
latest_ordered
)
end
def
retried_ordered_statuses
preload_statuses
(
legacy_stage
.
statuses
.
retried_ordered
)
end
private
def
preload_statuses
(
statuses
)
statuses
.
tap
do
|
statuses
|
# rubocop: disable CodeReuse/ActiveRecord
ActiveRecord
::
Associations
::
Preloader
.
new
.
preload
(
preloadable_statuses
(
statuses
),
:tags
)
# rubocop: enable CodeReuse/ActiveRecord
end
end
private
def
preloadable_statuses
(
statuses
)
statuses
.
reject
do
|
status
|
status
.
instance_of?
(
::
GenericCommitStatus
)
||
status
.
instance_of?
(
::
Ci
::
Bridge
)
...
...
app/views/projects/stage/_stage.html.haml
View file @
d6f6602c
-
sta
tuses
=
stage
.
present
(
current_user:
current_user
).
preloaded_statuses
-
sta
ge
=
stage
.
present
(
current_user:
current_user
)
%tr
%th
{
colspan:
10
}
...
...
@@ -8,8 +8,8 @@
=
ci_icon_for_status
(
stage
.
status
)
=
stage
.
name
.
titleize
=
render
sta
tuses
.
latest_ordered
,
stage:
false
,
ref:
false
,
pipeline_link:
false
,
allow_retry:
true
=
render
sta
tuses
.
retried_ordered
,
stage:
false
,
ref:
false
,
pipeline_link:
false
,
retried:
true
=
render
sta
ge
.
latest_ordered_statuses
,
stage:
false
,
ref:
false
,
pipeline_link:
false
,
allow_retry:
true
=
render
sta
ge
.
retried_ordered_statuses
,
stage:
false
,
ref:
false
,
pipeline_link:
false
,
retried:
true
%tr
%td
{
colspan:
10
}
spec/presenters/ci/legacy_stage_presenter_spec.rb
View file @
d6f6602c
...
...
@@ -4,18 +4,28 @@ require 'spec_helper'
describe
Ci
::
LegacyStagePresenter
do
let
(
:legacy_stage
)
{
create
(
:ci_stage
)
}
let
(
:presenter
)
{
described_class
.
new
(
legacy_stage
)
}
describe
'#preloaded_statuses'
do
subject
(
:preloaded_statuses
)
{
described_class
.
new
(
legacy_stage
).
preloaded_statuses
}
let!
(
:build
)
{
create
(
:ci_build
,
:tags
,
pipeline:
legacy_stage
.
pipeline
,
stage:
legacy_stage
.
name
)
}
let!
(
:retried_build
)
{
create
(
:ci_build
,
:tags
,
:retried
,
pipeline:
legacy_stage
.
pipeline
,
stage:
legacy_stage
.
name
)
}
let!
(
:build
)
{
create
(
:ci_build
,
:tags
,
pipeline:
legacy_stage
.
pipeline
,
stage:
legacy_stage
.
name
)
}
before
do
create
(
:generic_commit_status
,
pipeline:
legacy_stage
.
pipeline
,
stage:
legacy_stage
.
name
)
end
describe
'#latest_ordered_statuses'
do
subject
(
:latest_ordered_statuses
)
{
presenter
.
latest_ordered_statuses
}
before
do
create
(
:generic_commit_status
,
pipeline:
legacy_stage
.
pipeline
,
stage:
legacy_stage
.
name
)
it
'preloads build tags'
do
expect
(
latest_ordered_statuses
.
second
.
association
(
:tags
)).
to
be_loaded
end
end
describe
'#retried_ordered_statuses'
do
subject
(
:retried_ordered_statuses
)
{
presenter
.
retried_ordered_statuses
}
it
'preloads build tags'
do
expect
(
preload
ed_statuses
.
first
.
association
(
:tags
)).
to
be_loaded
expect
(
retried_order
ed_statuses
.
first
.
association
(
:tags
)).
to
be_loaded
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