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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
7d5b8993
Commit
7d5b8993
authored
Mar 16, 2017
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Build project cache key in a helper
parent
901e70fb
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
2 deletions
+59
-2
app/helpers/ci_status_helper.rb
app/helpers/ci_status_helper.rb
+4
-0
app/helpers/projects_helper.rb
app/helpers/projects_helper.rb
+7
-0
app/views/shared/projects/_project.html.haml
app/views/shared/projects/_project.html.haml
+1
-2
spec/helpers/ci_status_helper_spec.rb
spec/helpers/ci_status_helper_spec.rb
+7
-0
spec/helpers/projects_helper_spec.rb
spec/helpers/projects_helper_spec.rb
+40
-0
No files found.
app/helpers/ci_status_helper.rb
View file @
7d5b8993
...
...
@@ -59,6 +59,10 @@ module CiStatusHelper
custom_icon
(
icon_name
)
end
def
pipeline_status_cache_key
(
pipeline_status
)
"pipeline-status/
#{
pipeline_status
.
sha
}
-
#{
pipeline_status
.
status
}
"
end
def
render_project_pipeline_status
(
pipeline_status
,
tooltip_placement:
'auto left'
)
project
=
pipeline_status
.
project
path
=
pipelines_namespace_project_commit_path
(
...
...
app/helpers/projects_helper.rb
View file @
7d5b8993
...
...
@@ -159,6 +159,13 @@ module ProjectsHelper
choose a GitLab CI Yaml template and commit your changes.
#{
link_to_autodeploy_doc
}
"
.
html_safe
end
def
project_list_cache_key
(
project
)
key
=
[
project
.
namespace
.
cache_key
,
project
.
cache_key
,
controller
.
controller_name
,
controller
.
action_name
,
current_application_settings
.
cache_key
,
'v2.3'
]
key
<<
pipeline_status_cache_key
(
project
.
pipeline_status
)
if
project
.
pipeline_status
.
has_status?
key
end
private
def
repo_children_classes
(
field
)
...
...
app/views/shared/projects/_project.html.haml
View file @
7d5b8993
...
...
@@ -6,8 +6,7 @@
-
css_class
=
''
unless
local_assigns
[
:css_class
]
-
show_last_commit_as_description
=
false
unless
local_assigns
[
:show_last_commit_as_description
]
==
true
&&
project
.
commit
-
css_class
+=
" no-description"
if
project
.
description
.
blank?
&&
!
show_last_commit_as_description
-
cache_key
=
[
project
.
namespace
.
cache_key
,
project
.
cache_key
,
controller
.
controller_name
,
controller
.
action_name
,
current_application_settings
.
cache_key
,
'v2.3'
]
-
cache_key
.
push
"pipeline-status/
#{
project
.
pipeline_status
.
sha
}
-
#{
project
.
pipeline_status
.
status
}
"
if
project
.
pipeline_status
.
has_status?
-
cache_key
=
project_list_cache_key
(
project
)
%li
.project-row
{
class:
css_class
}
=
cache
(
cache_key
)
do
...
...
spec/helpers/ci_status_helper_spec.rb
View file @
7d5b8993
...
...
@@ -16,4 +16,11 @@ describe CiStatusHelper do
helper
.
ci_icon_for_status
(
failed_commit
.
status
)
end
end
describe
"#pipeline_status_cache_key"
do
it
"builds a cache key for pipeline status"
do
pipeline_status
=
Ci
::
PipelineStatus
.
new
(
build
(
:project
),
sha:
"123abc"
,
status:
"success"
)
expect
(
helper
.
pipeline_status_cache_key
(
pipeline_status
)).
to
eq
(
"pipeline-status/123abc-success"
)
end
end
end
spec/helpers/projects_helper_spec.rb
View file @
7d5b8993
...
...
@@ -63,6 +63,46 @@ describe ProjectsHelper do
end
end
describe
"#project_list_cache_key"
do
let
(
:project
)
{
create
(
:project
)
}
it
"includes the namespace"
do
expect
(
helper
.
project_list_cache_key
(
project
)).
to
include
(
project
.
namespace
.
cache_key
)
end
it
"includes the project"
do
expect
(
helper
.
project_list_cache_key
(
project
)).
to
include
(
project
.
cache_key
)
end
it
"includes the controller name"
do
expect
(
helper
.
controller
).
to
receive
(
:controller_name
).
and_return
(
"testcontroller"
)
expect
(
helper
.
project_list_cache_key
(
project
)).
to
include
(
"testcontroller"
)
end
it
"includes the controller action"
do
expect
(
helper
.
controller
).
to
receive
(
:action_name
).
and_return
(
"testaction"
)
expect
(
helper
.
project_list_cache_key
(
project
)).
to
include
(
"testaction"
)
end
it
"includes the application settings"
do
settings
=
Gitlab
::
CurrentSettings
.
current_application_settings
expect
(
helper
.
project_list_cache_key
(
project
)).
to
include
(
settings
.
cache_key
)
end
it
"includes a version"
do
expect
(
helper
.
project_list_cache_key
(
project
)).
to
include
(
"v2.3"
)
end
it
"includes the pipeline status when there is a status"
do
create
(
:ci_pipeline
,
:success
,
project:
project
,
sha:
project
.
commit
.
sha
)
expect
(
helper
.
project_list_cache_key
(
project
)).
to
include
(
"pipeline-status/
#{
project
.
commit
.
sha
}
-success"
)
end
end
describe
'link_to_member'
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:project
)
{
create
(
:empty_project
,
group:
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