@@ -64,8 +64,8 class AuthSourcesController < ApplicationController | |||
|
64 | 64 | begin |
|
65 | 65 | @auth_method.test_connection |
|
66 | 66 | flash[:notice] = l(:notice_successful_connection) |
|
67 |
rescue => |
|
|
68 |
flash[:error] = l(:error_unable_to_connect, |
|
|
67 | rescue Exception => e | |
|
68 | flash[:error] = l(:error_unable_to_connect, e.message) | |
|
69 | 69 | end |
|
70 | 70 | redirect_to :action => 'index' |
|
71 | 71 | end |
@@ -93,4 +93,22 class LdapAuthSourcesControllerTest < ActionController::TestCase | |||
|
93 | 93 | post :destroy, :id => 1 |
|
94 | 94 | end |
|
95 | 95 | end |
|
96 | ||
|
97 | def test_test_connection | |
|
98 | AuthSourceLdap.any_instance.stubs(:test_connection).returns(true) | |
|
99 | ||
|
100 | get :test_connection, :id => 1 | |
|
101 | assert_redirected_to '/ldap_auth_sources' | |
|
102 | assert_not_nil flash[:notice] | |
|
103 | assert_match /successful/i, flash[:notice] | |
|
104 | end | |
|
105 | ||
|
106 | def test_test_connection_with_failure | |
|
107 | AuthSourceLdap.any_instance.stubs(:test_connection).raises(Exception.new("Something went wrong")) | |
|
108 | ||
|
109 | get :test_connection, :id => 1 | |
|
110 | assert_redirected_to '/ldap_auth_sources' | |
|
111 | assert_not_nil flash[:error] | |
|
112 | assert_include '(Something went wrong)', flash[:error] | |
|
113 | end | |
|
96 | 114 | end |
General Comments 0
You need to be logged in to leave comments.
Login now