comparison 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
comparison
equal deleted inserted replaced
1516:b450a9d58aed 1517:dffacf8a6908
28 get :index 28 get :index
29 assert_response :success 29 assert_response :success
30 assert_template 'index' 30 assert_template 'index'
31 end 31 end
32 32
33 def test_new 33 def test_new_without_type_should_render_select_type
34 get :new
35 assert_response :success
36 assert_template 'select_type'
37 assert_select 'input[name=type]', CustomField.subclasses.size
38 assert_select 'input[name=type][checked=checked]', 1
39 end
40
41 def test_new_should_work_for_each_customized_class_and_format
34 custom_field_classes.each do |klass| 42 custom_field_classes.each do |klass|
35 get :new, :type => klass.name 43 Redmine::FieldFormat.available_formats.each do |format_name|
36 assert_response :success 44 get :new, :type => klass.name, :custom_field => {:field_format => format_name}
37 assert_template 'new' 45 assert_response :success
38 assert_kind_of klass, assigns(:custom_field) 46 assert_template 'new'
39 assert_select 'form#custom_field_form' do 47 assert_kind_of klass, assigns(:custom_field)
40 assert_select 'select#custom_field_field_format[name=?]', 'custom_field[field_format]' 48 assert_equal format_name, assigns(:custom_field).format.name
41 assert_select 'input[type=hidden][name=type][value=?]', klass.name 49 assert_select 'form#custom_field_form' do
50 assert_select 'select#custom_field_field_format[name=?]', 'custom_field[field_format]'
51 assert_select 'input[type=hidden][name=type][value=?]', klass.name
52 end
42 end 53 end
43 end 54 end
55 end
56
57 def test_new_should_have_string_default_format
58 get :new, :type => 'IssueCustomField'
59 assert_response :success
60 assert_equal 'string', assigns(:custom_field).format.name
44 end 61 end
45 62
46 def test_new_issue_custom_field 63 def test_new_issue_custom_field
47 get :new, :type => 'IssueCustomField' 64 get :new, :type => 'IssueCustomField'
48 assert_response :success 65 assert_response :success
81 end 98 end
82 99
83 def test_default_value_should_be_a_checkbox_for_bool_custom_field 100 def test_default_value_should_be_a_checkbox_for_bool_custom_field
84 get :new, :type => 'IssueCustomField', :custom_field => {:field_format => 'bool'} 101 get :new, :type => 'IssueCustomField', :custom_field => {:field_format => 'bool'}
85 assert_response :success 102 assert_response :success
86 assert_select 'input[name=?][type=checkbox]', 'custom_field[default_value]' 103 assert_select 'select[name=?]', 'custom_field[default_value]' do
104 assert_select 'option', 3
105 end
87 end 106 end
88 107
89 def test_default_value_should_not_be_present_for_user_custom_field 108 def test_default_value_should_not_be_present_for_user_custom_field
90 get :new, :type => 'IssueCustomField', :custom_field => {:field_format => 'user'} 109 get :new, :type => 'IssueCustomField', :custom_field => {:field_format => 'user'}
91 assert_response :success 110 assert_response :success
100 119
101 field = assigns(:custom_field) 120 field = assigns(:custom_field)
102 assert_equal 'list', field.field_format 121 assert_equal 'list', field.field_format
103 end 122 end
104 123
105 def test_new_with_invalid_custom_field_class_should_render_404 124 def test_new_with_invalid_custom_field_class_should_render_select_type
106 get :new, :type => 'UnknownCustomField' 125 get :new, :type => 'UnknownCustomField'
107 assert_response 404 126 assert_response :success
127 assert_template 'select_type'
108 end 128 end
109 129
110 def test_create_list_custom_field 130 def test_create_list_custom_field
111 assert_difference 'CustomField.count' do 131 assert_difference 'CustomField.count' do
112 post :create, :type => "IssueCustomField", 132 post :create, :type => "IssueCustomField",
147 end 167 end
148 assert_response :success 168 assert_response :success
149 assert_template 'new' 169 assert_template 'new'
150 end 170 end
151 171
172 def test_create_without_type_should_render_select_type
173 assert_no_difference 'CustomField.count' do
174 post :create, :custom_field => {:name => ''}
175 end
176 assert_response :success
177 assert_template 'select_type'
178 end
179
152 def test_edit 180 def test_edit
153 get :edit, :id => 1 181 get :edit, :id => 1
154 assert_response :success 182 assert_response :success
155 assert_template 'edit' 183 assert_template 'edit'
156 assert_tag 'input', :attributes => {:name => 'custom_field[name]', :value => 'Database'} 184 assert_tag 'input', :attributes => {:name => 'custom_field[name]', :value => 'Database'}