BUGFIX: site_contact_username was case-sensitive

This commit is contained in:
Régis Hanol 2014-01-23 11:26:31 +01:00
parent 202d1064ea
commit bfc9664231
2 changed files with 6 additions and 1 deletions

View File

@ -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

View File

@ -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