##// END OF EJS Templates
Adds functional test for #test_connection....
Jean-Philippe Lang -
r8933:9ffccf5304dc
parent child
Show More
@@ -64,8 +64,8 class AuthSourcesController < ApplicationController
64 begin
64 begin
65 @auth_method.test_connection
65 @auth_method.test_connection
66 flash[:notice] = l(:notice_successful_connection)
66 flash[:notice] = l(:notice_successful_connection)
67 rescue => text
67 rescue Exception => e
68 flash[:error] = l(:error_unable_to_connect, text.message)
68 flash[:error] = l(:error_unable_to_connect, e.message)
69 end
69 end
70 redirect_to :action => 'index'
70 redirect_to :action => 'index'
71 end
71 end
@@ -93,4 +93,22 class LdapAuthSourcesControllerTest < ActionController::TestCase
93 post :destroy, :id => 1
93 post :destroy, :id => 1
94 end
94 end
95 end
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 end
114 end
General Comments 0
You need to be logged in to leave comments. Login now