Commit e05244e5 authored by fjsanpedro's avatar fjsanpedro

Show head image tags with avatar url

parent 9f498701
...@@ -57,7 +57,10 @@ module PageLayoutHelper ...@@ -57,7 +57,10 @@ module PageLayoutHelper
subject = @project || @user || @group subject = @project || @user || @group
image = subject.avatar_url if subject.present? args = {}
args[:only_path] = false if Feature.enabled?(:avatar_with_host)
image = subject.avatar_url(args) if subject.present?
image || default image || default
end end
......
---
name: avatar_with_host
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/45776
rollout_issue_url:
type: development
group: group::editor
default_enabled: false
...@@ -56,19 +56,24 @@ RSpec.describe PageLayoutHelper do ...@@ -56,19 +56,24 @@ RSpec.describe PageLayoutHelper do
end end
%w(project user group).each do |type| %w(project user group).each do |type|
let(:object) { build(type, trait) }
let(:trait) { :with_avatar }
context "with @#{type} assigned" do context "with @#{type} assigned" do
it "uses #{type.titlecase} avatar if available" do before do
object = double(avatar_url: 'http://example.com/uploads/-/system/avatar.png')
assign(type, object) assign(type, object)
end
expect(helper.page_image).to eq object.avatar_url it "uses #{type.titlecase} avatar full url" do
expect(helper.page_image).to eq object.avatar_url(only_path: false)
end end
it 'falls back to the default when avatar_url is nil' do context 'when avatar_url is nil' do
object = double(avatar_url: nil) let(:trait) { nil }
assign(type, object)
expect(helper.page_image).to match_asset_path 'assets/gitlab_logo.png' it 'falls back to the default when avatar_url is nil' do
expect(helper.page_image).to match_asset_path 'assets/gitlab_logo.png'
end
end end
end end
...@@ -77,6 +82,16 @@ RSpec.describe PageLayoutHelper do ...@@ -77,6 +82,16 @@ RSpec.describe PageLayoutHelper do
expect(helper.page_image).to match_asset_path 'assets/gitlab_logo.png' expect(helper.page_image).to match_asset_path 'assets/gitlab_logo.png'
end end
end end
context 'if avatar_with_host is disabled' do
it "#{type.titlecase} does not generate avatar full url" do
stub_feature_flags(avatar_with_host: false)
assign(type, object)
expect(helper.page_image).to eq object.avatar_url(only_path: true)
end
end
end 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