Commit 0759db80 authored by Toon Claes's avatar Toon Claes

Move user_link to generic UsersHelper

Make the user_link helper more generic to be used for objects other
than pipelines.
parent a57890bc
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
module UsersHelper
def user_link(user)
link_to(user.name, user_path(user),
title: user.email,
class: 'has-tooltip commit-committer-link')
end
end
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
triggered #{time_ago_with_tooltip(@pipeline.created_at)} triggered #{time_ago_with_tooltip(@pipeline.created_at)}
- if @pipeline.user - if @pipeline.user
by by
= pipeline_user_avatar(@pipeline) = user_avatar(user: @pipeline.user, size: 24)
= pipeline_user_link(@pipeline) = user_link(@pipeline.user)
.header-action-buttons .header-action-buttons
- if can?(current_user, :update_pipeline, @pipeline.project) - if can?(current_user, :update_pipeline, @pipeline.project)
- if @pipeline.retryable? - if @pipeline.retryable?
......
require 'rails_helper' require 'rails_helper'
describe PipelinesHelper do describe AvatarsHelper do
let(:user) { create(:user) } 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 describe '#user_avatar' do
subject { helper.pipeline_user_avatar(pipeline) } subject { helper.user_avatar(user: user) }
it "links to the user's profile" do it "links to the user's profile" do
is_expected.to include("href=\"#{user_path(user)}\"") is_expected.to include("href=\"#{user_path(user)}\"")
...@@ -17,19 +15,7 @@ describe PipelinesHelper do ...@@ -17,19 +15,7 @@ describe PipelinesHelper do
end end
it "contains the user's avatar image" do it "contains the user's avatar image" do
is_expected.to include(CGI.escapeHTML(user.avatar_url(24))) is_expected.to include(CGI.escapeHTML(user.avatar_url(16)))
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 end
end end
require 'rails_helper'
describe UsersHelper do
let(:user) { create(:user) }
describe '#user_link' do
subject { helper.user_link(user) }
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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment