Commit a298f694 authored by Robert Speicher's avatar Robert Speicher

Use `User#avatar_url` instead of `avatar_icon` helper

parent 7a3b7629
......@@ -49,12 +49,10 @@ module PageLayoutHelper
def page_image
default = image_url('gitlab_logo.png')
if @project
@project.avatar_url || default
elsif @user
avatar_icon(@user)
elsif @group
@group.avatar_url || default
subject = @project || @user || @group
if subject.present?
subject.avatar_url || default
else
default
end
......
......@@ -70,49 +70,30 @@ describe PageLayoutHelper do
expect(helper.page_image).to end_with 'assets/gitlab_logo.png'
end
context 'with @project' do
it 'uses Project avatar if available' do
project = double(avatar_url: 'http://example.com/uploads/avatar.png')
assign(:project, project)
%w(project user group).each do |type|
context "with @#{type} assigned" do
it "uses #{type.titlecase} avatar if available" do
object = double(avatar_url: 'http://example.com/uploads/avatar.png')
assign(type, object)
expect(helper.page_image).to eq project.avatar_url
expect(helper.page_image).to eq object.avatar_url
end
it 'falls back to the default' do
project = double(avatar_url: nil)
assign(:project, project)
it 'falls back to the default when avatar_url is nil' do
object = double(avatar_url: nil)
assign(type, object)
expect(helper.page_image).to end_with 'assets/gitlab_logo.png'
end
end
context 'with @user' do
it 'delegates to avatar_icon helper' do
user = double('User')
assign(:user, user)
expect(helper).to receive(:avatar_icon).with(user)
helper.page_image
end
end
context 'with @group' do
it 'uses Group avatar if available' do
group = double(avatar_url: 'http://example.com/uploads/avatar.png')
assign(:group, group)
expect(helper.page_image).to eq group.avatar_url
end
context "with no assignments" do
it 'falls back to the default' do
group = double(avatar_url: nil)
assign(:group, group)
expect(helper.page_image).to end_with 'assets/gitlab_logo.png'
end
end
end
end
describe 'page_card_attributes' do
it 'raises ArgumentError when given more than two attributes' do
......
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