FIX: avatar_url includes upload_path twice when local storage used

This commit is contained in:
Vinoth Kannan 2018-06-06 18:27:30 +05:30
parent a50cd8675a
commit d8e641cd98
2 changed files with 4 additions and 3 deletions

View File

@ -63,7 +63,8 @@ class SessionController < ApplicationController
sso.groups = current_user.groups.pluck(:name).join(",")
if current_user.uploaded_avatar.present?
avatar_url = "#{Discourse.store.absolute_base_url}/#{Discourse.store.get_path_for_upload(current_user.uploaded_avatar)}"
base_url = Discourse.store.external? ? "#{Discourse.store.absolute_base_url}/" : Discourse.base_url
avatar_url = "#{base_url}#{Discourse.store.get_path_for_upload(current_user.uploaded_avatar)}"
sso.avatar_url = UrlHelper.absolute Discourse.store.cdn_url(avatar_url)
end

View File

@ -630,7 +630,7 @@ RSpec.describe SessionController do
expect(sso2.profile_background_url.blank?).to_not eq(true)
expect(sso2.card_background_url.blank?).to_not eq(true)
expect(sso2.avatar_url).to start_with(SiteSetting.s3_cdn_url)
expect(sso2.avatar_url).to start_with("#{SiteSetting.s3_cdn_url}/original")
expect(sso2.profile_background_url).to start_with(SiteSetting.s3_cdn_url)
expect(sso2.card_background_url).to start_with(SiteSetting.s3_cdn_url)
end
@ -774,7 +774,7 @@ RSpec.describe SessionController do
expect(sso2.profile_background_url.blank?).to_not eq(true)
expect(sso2.card_background_url.blank?).to_not eq(true)
expect(sso2.avatar_url).to start_with(Discourse.base_url)
expect(sso2.avatar_url).to start_with("#{Discourse.store.absolute_base_url}/original")
expect(sso2.profile_background_url).to start_with(Discourse.base_url)
expect(sso2.card_background_url).to start_with(Discourse.base_url)
end