diff --git a/app/models/auth_source_ldap.rb b/app/models/auth_source_ldap.rb index bf8d70478..5b8dc0cfe 100644 --- a/app/models/auth_source_ldap.rb +++ b/app/models/auth_source_ldap.rb @@ -49,8 +49,8 @@ class AuthSourceLdap < AuthSource def test_connection ldap_con = initialize_ldap_con(self.account, self.account_password) ldap_con.open { } - rescue Net::LDAP::LdapError => text - raise "LdapError: " + text + rescue Net::LDAP::LdapError => e + raise "LdapError: " + e.message end def auth_method_name diff --git a/test/functional/auth_sources_controller_test.rb b/test/functional/auth_sources_controller_test.rb index 96dcb5c78..ae197e227 100644 --- a/test/functional/auth_sources_controller_test.rb +++ b/test/functional/auth_sources_controller_test.rb @@ -117,11 +117,11 @@ class AuthSourcesControllerTest < ActionController::TestCase end def test_test_connection_with_failure - AuthSourceLdap.any_instance.stubs(:test_connection).raises(Exception.new("Something went wrong")) + AuthSourceLdap.any_instance.stubs(:initialize_ldap_con).raises(Net::LDAP::LdapError.new("Something went wrong")) get :test_connection, :id => 1 assert_redirected_to '/auth_sources' assert_not_nil flash[:error] - assert_include '(Something went wrong)', flash[:error] + assert_include 'Something went wrong', flash[:error] end end