diff --git a/app/helpers/pipelines_helper.rb b/app/helpers/pipelines_helper.rb new file mode 100644 index 00000000000..23b9ff97521 --- /dev/null +++ b/app/helpers/pipelines_helper.rb @@ -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 diff --git a/app/views/projects/pipelines/_info.html.haml b/app/views/projects/pipelines/_info.html.haml index 6d60f836866..a280f5a62ab 100644 --- a/app/views/projects/pipelines/_info.html.haml +++ b/app/views/projects/pipelines/_info.html.haml @@ -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? diff --git a/changelogs/unreleased/tc-pipeline-show-trigger-date.yml b/changelogs/unreleased/tc-pipeline-show-trigger-date.yml index eb2a22af5f4..4de784d98f3 100644 --- a/changelogs/unreleased/tc-pipeline-show-trigger-date.yml +++ b/changelogs/unreleased/tc-pipeline-show-trigger-date.yml @@ -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: diff --git a/spec/features/commits_spec.rb b/spec/features/commits_spec.rb index 86a00401088..881f1fca4d1 100644 --- a/spec/features/commits_spec.rb +++ b/spec/features/commits_spec.rb @@ -12,6 +12,7 @@ describe 'Commits' do end let(:creator) { create(:user) } + let!(:pipeline) do create(:ci_pipeline, project: project, diff --git a/spec/helpers/pipelines_helper_spec.rb b/spec/helpers/pipelines_helper_spec.rb new file mode 100644 index 00000000000..8101fb71ee8 --- /dev/null +++ b/spec/helpers/pipelines_helper_spec.rb @@ -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