Show dashboard warning when favicon and/or logo urls contain the same filename as the shipped defaults

This commit is contained in:
Neil Lalonde 2013-06-05 16:43:39 -04:00
parent b55182b983
commit 4e8ff74b99
2 changed files with 51 additions and 3 deletions

View File

@ -106,9 +106,9 @@ class AdminDashboardData
end
def default_logo_check
if SiteSetting.logo_url == SiteSetting.defaults[:logo_url] or
SiteSetting.logo_small_url == SiteSetting.defaults[:logo_small_url] or
SiteSetting.favicon_url == SiteSetting.defaults[:favicon_url]
if SiteSetting.logo_url =~ /d-logo-sketch\.png/ or
SiteSetting.logo_small_url =~ /d-logo-sketch-small\.png/ or
SiteSetting.favicon_url =~ /default-favicon\.png/
I18n.t('dashboard.default_logo_warning')
end
end

View File

@ -144,6 +144,54 @@ describe AdminDashboardData do
end
end
describe 'default_logo_check' do
subject { AdminDashboardData.new.default_logo_check }
describe 'favicon_url check' do
before do
SiteSetting.stubs(:logo_url).returns('/assets/my-logo.jpg')
SiteSetting.stubs(:logo_small_url).returns('/assets/my-small-logo.jpg')
end
it 'returns a string when favicon_url is default' do
expect(subject).to_not be_nil
end
it 'returns a string when favicon_url contains default-favicon.png' do
SiteSetting.stubs(:favicon_url).returns('/discourse/images/default-favicon.png')
expect(subject).to_not be_nil
end
it 'returns nil when favicon_url does not match default-favicon.png' do
SiteSetting.stubs(:favicon_url).returns('/assets/my-favicon.png')
expect(subject).to be_nil
end
end
describe 'logo_url check' do
before do
SiteSetting.stubs(:favicon_url).returns('/assets/my-favicon.png')
SiteSetting.stubs(:logo_small_url).returns('/assets/my-small-logo.jpg')
end
it 'returns a string when logo_url is default' do
expect(subject).to_not be_nil
end
it 'returns a string when logo_url contains d-logo-sketch.png' do
SiteSetting.stubs(:logo_url).returns('/discourse/images/d-logo-sketch.png')
expect(subject).to_not be_nil
end
it 'returns nil when logo_url does not match d-logo-sketch.png' do
SiteSetting.stubs(:logo_url).returns('/assets/my-logo.png')
expect(subject).to be_nil
end
end
# etc.
end
describe 'auth_config_checks' do
shared_examples 'problem detection for login providers' do