@@ -1,81 +1,81 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 |
# |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 |
# |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | require File.expand_path('../../test_helper', __FILE__) |
|
18 | require File.expand_path('../../test_helper', __FILE__) | |
19 | require 'custom_fields_controller' |
|
19 | require 'custom_fields_controller' | |
20 |
|
20 | |||
21 | # Re-raise errors caught by the controller. |
|
21 | # Re-raise errors caught by the controller. | |
22 | class CustomFieldsController; def rescue_action(e) raise e end; end |
|
22 | class CustomFieldsController; def rescue_action(e) raise e end; end | |
23 |
|
23 | |||
24 | class CustomFieldsControllerTest < ActionController::TestCase |
|
24 | class CustomFieldsControllerTest < ActionController::TestCase | |
25 | fixtures :custom_fields, :trackers, :users |
|
25 | fixtures :custom_fields, :trackers, :users | |
26 |
|
26 | |||
27 | def setup |
|
27 | def setup | |
28 | @controller = CustomFieldsController.new |
|
28 | @controller = CustomFieldsController.new | |
29 | @request = ActionController::TestRequest.new |
|
29 | @request = ActionController::TestRequest.new | |
30 | @response = ActionController::TestResponse.new |
|
30 | @response = ActionController::TestResponse.new | |
31 | @request.session[:user_id] = 1 |
|
31 | @request.session[:user_id] = 1 | |
32 | end |
|
32 | end | |
33 |
|
33 | |||
34 | def test_get_new_issue_custom_field |
|
34 | def test_get_new_issue_custom_field | |
35 | get :new, :type => 'IssueCustomField' |
|
35 | get :new, :type => 'IssueCustomField' | |
36 | assert_response :success |
|
36 | assert_response :success | |
37 | assert_template 'new' |
|
37 | assert_template 'new' | |
38 | assert_tag :select, |
|
38 | assert_tag :select, | |
39 | :attributes => {:name => 'custom_field[field_format]'}, |
|
39 | :attributes => {:name => 'custom_field[field_format]'}, | |
40 | :child => { |
|
40 | :child => { | |
41 | :tag => 'option', |
|
41 | :tag => 'option', | |
42 | :attributes => {:value => 'user'}, |
|
42 | :attributes => {:value => 'user'}, | |
43 | :content => 'User' |
|
43 | :content => 'User' | |
44 | } |
|
44 | } | |
45 | assert_tag :select, |
|
45 | assert_tag :select, | |
46 | :attributes => {:name => 'custom_field[field_format]'}, |
|
46 | :attributes => {:name => 'custom_field[field_format]'}, | |
47 | :child => { |
|
47 | :child => { | |
48 | :tag => 'option', |
|
48 | :tag => 'option', | |
49 | :attributes => {:value => 'version'}, |
|
49 | :attributes => {:value => 'version'}, | |
50 | :content => 'Version' |
|
50 | :content => 'Version' | |
51 | } |
|
51 | } | |
52 | end |
|
52 | end | |
53 |
|
53 | |||
54 | def test_get_new_with_invalid_custom_field_class_should_redirect_to_list |
|
54 | def test_get_new_with_invalid_custom_field_class_should_redirect_to_list | |
55 | get :new, :type => 'UnknownCustomField' |
|
55 | get :new, :type => 'UnknownCustomField' | |
56 | assert_redirected_to '/custom_fields' |
|
56 | assert_redirected_to '/custom_fields' | |
57 | end |
|
57 | end | |
58 |
|
58 | |||
59 | def test_post_new_list_custom_field |
|
59 | def test_post_new_list_custom_field | |
60 | assert_difference 'CustomField.count' do |
|
60 | assert_difference 'CustomField.count' do | |
61 | post :new, :type => "IssueCustomField", |
|
61 | post :new, :type => "IssueCustomField", | |
62 | :custom_field => {:name => "test_post_new_list", |
|
62 | :custom_field => {:name => "test_post_new_list", | |
63 | :default_value => "", |
|
63 | :default_value => "", | |
64 | :min_length => "0", |
|
64 | :min_length => "0", | |
65 | :searchable => "0", |
|
65 | :searchable => "0", | |
66 | :regexp => "", |
|
66 | :regexp => "", | |
67 | :is_for_all => "1", |
|
67 | :is_for_all => "1", | |
68 | :possible_values => "0.1\n0.2\n", |
|
68 | :possible_values => "0.1\n0.2\n", | |
69 | :max_length => "0", |
|
69 | :max_length => "0", | |
70 | :is_filter => "0", |
|
70 | :is_filter => "0", | |
71 | :is_required =>"0", |
|
71 | :is_required =>"0", | |
72 | :field_format => "list", |
|
72 | :field_format => "list", | |
73 | :tracker_ids => ["1", ""]} |
|
73 | :tracker_ids => ["1", ""]} | |
74 |
end |
|
74 | end | |
75 | assert_redirected_to '/custom_fields?tab=IssueCustomField' |
|
75 | assert_redirected_to '/custom_fields?tab=IssueCustomField' | |
76 | field = IssueCustomField.find_by_name('test_post_new_list') |
|
76 | field = IssueCustomField.find_by_name('test_post_new_list') | |
77 | assert_not_nil field |
|
77 | assert_not_nil field | |
78 | assert_equal ["0.1", "0.2"], field.possible_values |
|
78 | assert_equal ["0.1", "0.2"], field.possible_values | |
79 | assert_equal 1, field.trackers.size |
|
79 | assert_equal 1, field.trackers.size | |
80 | end |
|
80 | end | |
81 | end |
|
81 | end |
General Comments 0
You need to be logged in to leave comments.
Login now