diff --git a/lib/discourse.rb b/lib/discourse.rb index a769fd0d8fd..f6e02c7e2b9 100644 --- a/lib/discourse.rb +++ b/lib/discourse.rb @@ -168,7 +168,7 @@ module Discourse # Either returns the site_contact_username user or the first admin. def self.site_contact_user - user = User.where(username_lower: SiteSetting.site_contact_username).first if SiteSetting.site_contact_username.present? + user = User.where(username_lower: SiteSetting.site_contact_username.downcase).first if SiteSetting.site_contact_username.present? user ||= User.admins.real.order(:id).first end diff --git a/spec/components/discourse_spec.rb b/spec/components/discourse_spec.rb index 7c93e186185..66a128ead74 100644 --- a/spec/components/discourse_spec.rb +++ b/spec/components/discourse_spec.rb @@ -57,6 +57,11 @@ describe Discourse do Discourse.site_contact_user.should == another_admin end + it 'returns the user specified by the site setting site_contact_username regardless of its case' do + SiteSetting.stubs(:site_contact_username).returns(another_admin.username.upcase) + Discourse.site_contact_user.should == another_admin + end + it 'returns the first admin user otherwise' do SiteSetting.stubs(:site_contact_username).returns(nil) Discourse.site_contact_user.should == admin