Skip to content
Snippets Groups Projects
Commit 38b57664 authored by Rémy Coutable's avatar Rémy Coutable Committed by GitLab Release Tools Bot
Browse files

Merge branch 'sh-fix-gon-helper-avatar' into 'master'

Fix no avatar not showing in user selection box

Closes #56268

See merge request gitlab-org/gitlab-ce!24346

(cherry picked from commit 82852058)

2265ce34 Fix no avatar not showing in user selection box
parent acd423c7
No related branches found
No related tags found
No related merge requests found
---
title: Fix no avatar not showing in user selection box
merge_request: 24346
author:
type: fixed
Loading
Loading
@@ -8,10 +8,7 @@ module Gitlab
 
def add_gon_variables
gon.api_version = 'v4'
gon.default_avatar_url =
Gitlab::Utils.append_path(
Gitlab.config.gitlab.url,
ActionController::Base.helpers.image_path('no_avatar.png'))
gon.default_avatar_url = default_avatar_url
gon.max_file_size = Gitlab::CurrentSettings.max_attachment_size
gon.asset_host = ActionController::Base.asset_host
gon.webpack_public_path = webpack_public_path
Loading
Loading
@@ -50,5 +47,15 @@ module Gitlab
# use this method to push multiple feature flags.
gon.push({ features: { var_name => enabled } }, true)
end
def default_avatar_url
# We can't use ActionController::Base.helpers.image_url because it
# doesn't return an actual URL because request is nil for some reason.
#
# We also can't use Gitlab::Utils.append_path because the image path
# may be an absolute URL.
URI.join(Gitlab.config.gitlab.url,
ActionController::Base.helpers.image_path('no_avatar.png')).to_s
end
end
end
Loading
Loading
@@ -29,4 +29,13 @@ describe Gitlab::GonHelper do
helper.push_frontend_feature_flag(:my_feature_flag, 10)
end
end
describe '#default_avatar_url' do
it 'returns an absolute URL' do
url = helper.default_avatar_url
expect(url).to match(/^http/)
expect(url).to match(/no_avatar.*png$/)
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment