diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-12-13 15:04:11 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-12-13 15:04:11 +0000 |
commit | 7775f86a69f187b8e162280e1f4de1a8b58fd3dd (patch) | |
tree | 11d193dc381eb6c006d917ccf54439d81dde1de9 /test/functional/auth_sources_controller_test.rb | |
parent | c31f498ba6a21fd3e5ce7b9ba2f3b3cdc1b2e05b (diff) | |
download | redmine-7775f86a69f187b8e162280e1f4de1a8b58fd3dd.tar.gz redmine-7775f86a69f187b8e162280e1f4de1a8b58fd3dd.zip |
Code cleanup in AuthSource controller and views.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10996 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/functional/auth_sources_controller_test.rb')
-rw-r--r-- | test/functional/auth_sources_controller_test.rb | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/test/functional/auth_sources_controller_test.rb b/test/functional/auth_sources_controller_test.rb index ff3c5047c..c64dca66d 100644 --- a/test/functional/auth_sources_controller_test.rb +++ b/test/functional/auth_sources_controller_test.rb @@ -42,8 +42,15 @@ class AuthSourcesControllerTest < ActionController::TestCase assert_equal AuthSourceLdap, source.class assert source.new_record? - assert_tag 'input', :attributes => {:name => 'type', :value => 'AuthSourceLdap'} - assert_tag 'input', :attributes => {:name => 'auth_source[host]'} + assert_select 'form#auth_source_form' do + assert_select 'input[name=type][value=AuthSourceLdap]' + assert_select 'input[name=?]', 'auth_source[host]' + end + end + + def test_new_with_invalid_type_should_respond_with_404 + get :new, :type => 'foo' + assert_response 404 end def test_create @@ -52,7 +59,7 @@ class AuthSourcesControllerTest < ActionController::TestCase assert_redirected_to '/auth_sources' end - source = AuthSourceLdap.first(:order => 'id DESC') + source = AuthSourceLdap.order('id DESC').first assert_equal 'Test', source.name assert_equal '127.0.0.1', source.host assert_equal 389, source.port @@ -74,7 +81,23 @@ class AuthSourcesControllerTest < ActionController::TestCase assert_response :success assert_template 'edit' - assert_tag 'input', :attributes => {:name => 'auth_source[host]'} + assert_select 'form#auth_source_form' do + assert_select 'input[name=?]', 'auth_source[host]' + end + end + + def test_edit_should_not_contain_password + AuthSource.find(1).update_column :account_password, 'secret' + + get :edit, :id => 1 + assert_response :success + assert_select 'input[value=secret]', 0 + assert_select 'input[name=dummy_password][value=?]', /x+/ + end + + def test_edit_invalid_should_respond_with_404 + get :edit, :id => 99 + assert_response 404 end def test_update @@ -96,6 +119,7 @@ class AuthSourcesControllerTest < ActionController::TestCase def test_destroy assert_difference 'AuthSourceLdap.count', -1 do delete :destroy, :id => 1 + assert_redirected_to '/auth_sources' end end @@ -104,6 +128,7 @@ class AuthSourcesControllerTest < ActionController::TestCase assert_no_difference 'AuthSourceLdap.count' do delete :destroy, :id => 1 + assert_redirected_to '/auth_sources' end end |