Add helpers for pipeline user link & user avatar
This commit is contained in:
parent
e2d5818ee1
commit
a57890bcaa
5 changed files with 50 additions and 3 deletions
11
app/helpers/pipelines_helper.rb
Normal file
11
app/helpers/pipelines_helper.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
module PipelinesHelper
|
||||
def pipeline_user_avatar(pipeline)
|
||||
user_avatar(user: pipeline.user, size: 24)
|
||||
end
|
||||
|
||||
def pipeline_user_link(pipeline)
|
||||
link_to(pipeline.user.name, user_path(pipeline.user),
|
||||
title: pipeline.user.email,
|
||||
class: 'has-tooltip commit-committer-link')
|
||||
end
|
||||
end
|
|
@ -5,8 +5,8 @@
|
|||
triggered #{time_ago_with_tooltip(@pipeline.created_at)}
|
||||
- if @pipeline.user
|
||||
by
|
||||
= user_avatar(user: @pipeline.user, size: 24, css_class: 'hidden-xs')
|
||||
= link_to(@pipeline.user.name, user_path(@pipeline.user.username), title: @pipeline.user.email, class: 'has-tooltip commit-committer-link')
|
||||
= pipeline_user_avatar(@pipeline)
|
||||
= pipeline_user_link(@pipeline)
|
||||
.header-action-buttons
|
||||
- if can?(current_user, :update_pipeline, @pipeline.project)
|
||||
- if @pipeline.retryable?
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
---
|
||||
title: Show pipeline creator & created_at in heading
|
||||
title: Show correct user & creation time in heading of the pipeline page
|
||||
merge_request: 9936
|
||||
author:
|
||||
|
|
|
@ -12,6 +12,7 @@ describe 'Commits' do
|
|||
end
|
||||
|
||||
let(:creator) { create(:user) }
|
||||
|
||||
let!(:pipeline) do
|
||||
create(:ci_pipeline,
|
||||
project: project,
|
||||
|
|
35
spec/helpers/pipelines_helper_spec.rb
Normal file
35
spec/helpers/pipelines_helper_spec.rb
Normal file
|
@ -0,0 +1,35 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe PipelinesHelper do
|
||||
let(:user) { create(:user) }
|
||||
let(:project) { create(:project) }
|
||||
let(:pipeline) { create(:ci_empty_pipeline, project: project, sha: project.commit.id, user: user) }
|
||||
|
||||
describe '#pipeline_user_avatar' do
|
||||
subject { helper.pipeline_user_avatar(pipeline) }
|
||||
|
||||
it "links to the user's profile" do
|
||||
is_expected.to include("href=\"#{user_path(user)}\"")
|
||||
end
|
||||
|
||||
it "has the user's name as title" do
|
||||
is_expected.to include("title=\"#{user.name}\"")
|
||||
end
|
||||
|
||||
it "contains the user's avatar image" do
|
||||
is_expected.to include(CGI.escapeHTML(user.avatar_url(24)))
|
||||
end
|
||||
end
|
||||
|
||||
describe '#pipeline_user_link' do
|
||||
subject { helper.pipeline_user_link(pipeline) }
|
||||
|
||||
it "links to the user's profile" do
|
||||
is_expected.to include("href=\"#{user_path(user)}\"")
|
||||
end
|
||||
|
||||
it "has the user's email as title" do
|
||||
is_expected.to include("title=\"#{user.email}\"")
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue