From 757c7a52916fbee75a94ee453e055e8ce02a428e Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Sat, 15 Dec 2012 02:19:21 +0100 Subject: [PATCH] Fix gravatar and ldap config --- app/helpers/application_helper.rb | 2 +- app/views/profiles/show.html.haml | 2 +- config/initializers/devise.rb | 22 ++++++++++------------ spec/helpers/application_helper_spec.rb | 4 ++-- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c9e939801c2..52715a265bd 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -34,7 +34,7 @@ module ApplicationHelper def gravatar_icon(user_email = '', size = nil) size = 40 if size.nil? || size <= 0 - if Gitlab.config.disable_gravatar? || user_email.blank? + if !Gitlab.config.gravatar.enabled || user_email.blank? 'no_avatar.png' else gravatar_url = request.ssl? ? Gitlab.config.gravatar.ssl_url : Gitlab.config.gravatar.plain_url diff --git a/app/views/profiles/show.html.haml b/app/views/profiles/show.html.haml index 177119f093a..934c1fdf7c4 100644 --- a/app/views/profiles/show.html.haml +++ b/app/views/profiles/show.html.haml @@ -33,7 +33,7 @@ %ul %li %p You can change your password on Account page - -unless Gitlab.config.disable_gravatar? + - if Gitlab.config.gravatar.enabled %li %p You can change your avatar at #{link_to "gravatar.com", "http://gravatar.com"} diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index db7246a1b9b..ed3ab71862a 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -205,20 +205,18 @@ Devise.setup do |config| # manager.default_strategies(:scope => :user).unshift :some_external_strategy # end - gl = Gitlab.config - - if gl.ldap_enabled? + if Gitlab.config.ldap.enabled config.omniauth :ldap, - :host => gl.ldap['host'], - :base => gl.ldap['base'], - :uid => gl.ldap['uid'], - :port => gl.ldap['port'], - :method => gl.ldap['method'], - :bind_dn => gl.ldap['bind_dn'], - :password => gl.ldap['password'] + :host => Gitlab.config.ldap['host'], + :base => Gitlab.config.ldap['base'], + :uid => Gitlab.config.ldap['uid'], + :port => Gitlab.config.ldap['port'], + :method => Gitlab.config.ldap['method'], + :bind_dn => Gitlab.config.ldap['bind_dn'], + :password => Gitlab.config.ldap['password'] end - gl.omniauth_providers.each do |gl_provider| - config.omniauth gl_provider['name'].to_sym, gl_provider['app_id'], gl_provider['app_secret'] + Gitlab.config.omniauth.providers.each do |provider| + config.omniauth provider['name'].to_sym, provider['app_id'], provider['app_secret'] end end diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index df66e3b48bd..ba1af08421b 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -43,7 +43,7 @@ describe ApplicationHelper do let(:user_email) { 'user@email.com' } it "should return a generic avatar path when Gravatar is disabled" do - Gitlab.config.stub(:disable_gravatar?).and_return(true) + Gitlab.config.gravatar.stub(:enabled).and_return(false) gravatar_icon(user_email).should == 'no_avatar.png' end @@ -63,7 +63,7 @@ describe ApplicationHelper do it "should return custom gravatar path when gravatar_url is set" do stub!(:request).and_return(double(:ssl? => false)) - Gitlab.config.stub(:gravatar_url).and_return('http://example.local/?s=%{size}&hash=%{hash}') + Gitlab.config.gravatar.stub(:plain_url).and_return('http://example.local/?s=%{size}&hash=%{hash}') gravatar_icon(user_email, 20).should == 'http://example.local/?s=20&hash=b58c6f14d292556214bd64909bcdb118' end