Commit 59cdb025 authored by Dmytro Zaporozhets (DZ)'s avatar Dmytro Zaporozhets (DZ)

Merge branch '36830-fj-show-avatar-with-host' into 'master'

Provide absolute URL to project avatar in meta tags

See merge request gitlab-org/gitlab!45776
parents 10c44bc2 e05244e5
......@@ -57,7 +57,10 @@ module PageLayoutHelper
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
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
end
%w(project user group).each do |type|
let(:object) { build(type, trait) }
let(:trait) { :with_avatar }
context "with @#{type} assigned" do
it "uses #{type.titlecase} avatar if available" do
object = double(avatar_url: 'http://example.com/uploads/-/system/avatar.png')
before do
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
it 'falls back to the default when avatar_url is nil' do
object = double(avatar_url: nil)
assign(type, object)
context 'when avatar_url is nil' do
let(:trait) { nil }
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
......@@ -77,6 +82,16 @@ RSpec.describe PageLayoutHelper do
expect(helper.page_image).to match_asset_path 'assets/gitlab_logo.png'
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
......
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