Mercurial > hg > soundsoftware-site
diff test/functional/custom_fields_controller_test.rb @ 1517:dffacf8a6908 redmine-2.5
Update to Redmine SVN revision 13367 on 2.5-stable branch
author | Chris Cannam |
---|---|
date | Tue, 09 Sep 2014 09:29:00 +0100 |
parents | e248c7af89ec |
children |
line wrap: on
line diff
--- a/test/functional/custom_fields_controller_test.rb Tue Sep 09 09:28:31 2014 +0100 +++ b/test/functional/custom_fields_controller_test.rb Tue Sep 09 09:29:00 2014 +0100 @@ -30,19 +30,36 @@ assert_template 'index' end - def test_new + def test_new_without_type_should_render_select_type + get :new + assert_response :success + assert_template 'select_type' + assert_select 'input[name=type]', CustomField.subclasses.size + assert_select 'input[name=type][checked=checked]', 1 + end + + def test_new_should_work_for_each_customized_class_and_format custom_field_classes.each do |klass| - get :new, :type => klass.name - assert_response :success - assert_template 'new' - assert_kind_of klass, assigns(:custom_field) - assert_select 'form#custom_field_form' do - assert_select 'select#custom_field_field_format[name=?]', 'custom_field[field_format]' - assert_select 'input[type=hidden][name=type][value=?]', klass.name + Redmine::FieldFormat.available_formats.each do |format_name| + get :new, :type => klass.name, :custom_field => {:field_format => format_name} + assert_response :success + assert_template 'new' + assert_kind_of klass, assigns(:custom_field) + assert_equal format_name, assigns(:custom_field).format.name + assert_select 'form#custom_field_form' do + assert_select 'select#custom_field_field_format[name=?]', 'custom_field[field_format]' + assert_select 'input[type=hidden][name=type][value=?]', klass.name + end end end end + def test_new_should_have_string_default_format + get :new, :type => 'IssueCustomField' + assert_response :success + assert_equal 'string', assigns(:custom_field).format.name + end + def test_new_issue_custom_field get :new, :type => 'IssueCustomField' assert_response :success @@ -83,7 +100,9 @@ def test_default_value_should_be_a_checkbox_for_bool_custom_field get :new, :type => 'IssueCustomField', :custom_field => {:field_format => 'bool'} assert_response :success - assert_select 'input[name=?][type=checkbox]', 'custom_field[default_value]' + assert_select 'select[name=?]', 'custom_field[default_value]' do + assert_select 'option', 3 + end end def test_default_value_should_not_be_present_for_user_custom_field @@ -102,9 +121,10 @@ assert_equal 'list', field.field_format end - def test_new_with_invalid_custom_field_class_should_render_404 + def test_new_with_invalid_custom_field_class_should_render_select_type get :new, :type => 'UnknownCustomField' - assert_response 404 + assert_response :success + assert_template 'select_type' end def test_create_list_custom_field @@ -149,6 +169,14 @@ assert_template 'new' end + def test_create_without_type_should_render_select_type + assert_no_difference 'CustomField.count' do + post :create, :custom_field => {:name => ''} + end + assert_response :success + assert_template 'select_type' + end + def test_edit get :edit, :id => 1 assert_response :success