From 29a3203b3fe08649b80def65b7750a866454d3d6 Mon Sep 17 00:00:00 2001 From: blackst0ne Date: Wed, 10 May 2017 15:26:17 +1100 Subject: Use relative paths for group/project/user avatars --- spec/models/user_spec.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'spec/models/user_spec.rb') diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index c7ddd17872b..b845e85b295 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -964,12 +964,19 @@ describe User, models: true do describe '#avatar_url' do let(:user) { create(:user, :with_avatar) } - subject { user.avatar_url } context 'when avatar file is uploaded' do + let(:gitlab_host) { "http://#{Gitlab.config.gitlab.host}" } let(:avatar_path) { "/uploads/user/avatar/#{user.id}/dk.png" } - it { should eq "http://#{Gitlab.config.gitlab.host}#{avatar_path}" } + it 'shows correct avatar url' do + expect(user.avatar_url).to eq(avatar_path) + expect(user.avatar_url(only_path: false)).to eq([gitlab_host, avatar_path].join) + + allow(ActionController::Base).to receive(:asset_host).and_return(gitlab_host) + + expect(user.avatar_url).to eq([gitlab_host, avatar_path].join) + end end end -- cgit v1.2.1