From 7775f86a69f187b8e162280e1f4de1a8b58fd3dd Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Thu, 13 Dec 2012 15:04:11 +0000 Subject: Code cleanup in AuthSource controller and views. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10996 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- test/functional/auth_sources_controller_test.rb | 33 ++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'test/functional') 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 -- cgit v1.2.3