diff --git a/app/assets/javascripts/discourse/widgets/home-logo.js.es6 b/app/assets/javascripts/discourse/widgets/home-logo.js.es6 index 5c7454df117..86bc33966a7 100644 --- a/app/assets/javascripts/discourse/widgets/home-logo.js.es6 +++ b/app/assets/javascripts/discourse/widgets/home-logo.js.es6 @@ -17,7 +17,7 @@ export default createWidget("home-logo", { }, logoUrl() { - return this.siteSettings.site_logo_url || ""; + return this.siteSettings.site_home_logo_url || ""; }, mobileLogoUrl() { diff --git a/app/models/site_setting.rb b/app/models/site_setting.rb index ee20d17616a..0bdf7b3000e 100644 --- a/app/models/site_setting.rb +++ b/app/models/site_setting.rb @@ -175,8 +175,19 @@ class SiteSetting < ActiveRecord::Base site_logo_small_url site_mobile_logo_url site_favicon_url + site_home_logo_url }.each { |client_setting| client_settings << client_setting } + def self.site_home_logo_url + upload = SiteSetting.logo + + if SiteSetting.defaults.get(:title) != SiteSetting.title && !upload + '' + else + full_cdn_url(upload ? upload.url : '/images/d-logo-sketch.png') + end + end + def self.site_logo_url upload = self.logo upload ? full_cdn_url(upload.url) : self.logo_url(warn: false) diff --git a/spec/models/site_setting_spec.rb b/spec/models/site_setting_spec.rb index 6c6f556c29d..6f4cf60782c 100644 --- a/spec/models/site_setting_spec.rb +++ b/spec/models/site_setting_spec.rb @@ -150,6 +150,40 @@ describe SiteSetting do end end + describe '.site_home_logo_url' do + describe 'when logo site setting is set' do + let(:upload) { Fabricate(:upload) } + + before do + SiteSetting.logo = upload + end + + it 'should return the right URL' do + expect(SiteSetting.site_home_logo_url) + .to eq("#{Discourse.base_url}#{upload.url}") + end + end + + describe 'when logo site setting is not set' do + describe 'when there is a custom title' do + before do + SiteSetting.title = "test" + end + + it 'should return a blank string' do + expect(SiteSetting.site_home_logo_url).to eq('') + end + end + + describe 'when title has not been set' do + it 'should return the default logo url' do + expect(SiteSetting.site_home_logo_url) + .to eq("#{Discourse.base_url}/images/d-logo-sketch.png") + end + end + end + end + context 'deprecated site settings' do before do SiteSetting.force_https = true