@@ -22,7 +22,7 require 'custom_fields_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, :custom_values, :trackers, :users | |
26 |
|
26 | |||
27 | def setup |
|
27 | def setup | |
28 | @controller = CustomFieldsController.new |
|
28 | @controller = CustomFieldsController.new | |
@@ -31,6 +31,12 class CustomFieldsControllerTest < ActionController::TestCase | |||||
31 | @request.session[:user_id] = 1 |
|
31 | @request.session[:user_id] = 1 | |
32 | end |
|
32 | end | |
33 |
|
33 | |||
|
34 | def test_index | |||
|
35 | get :index | |||
|
36 | assert_response :success | |||
|
37 | assert_template 'index' | |||
|
38 | end | |||
|
39 | ||||
34 | def test_get_new_issue_custom_field |
|
40 | def test_get_new_issue_custom_field | |
35 | get :new, :type => 'IssueCustomField' |
|
41 | get :new, :type => 'IssueCustomField' | |
36 | assert_response :success |
|
42 | assert_response :success | |
@@ -78,4 +84,34 class CustomFieldsControllerTest < ActionController::TestCase | |||||
78 | assert_equal ["0.1", "0.2"], field.possible_values |
|
84 | assert_equal ["0.1", "0.2"], field.possible_values | |
79 | assert_equal 1, field.trackers.size |
|
85 | assert_equal 1, field.trackers.size | |
80 | end |
|
86 | end | |
|
87 | ||||
|
88 | def test_get_edit | |||
|
89 | get :edit, :id => 1 | |||
|
90 | assert_response :success | |||
|
91 | assert_template 'edit' | |||
|
92 | assert_tag 'input', :attributes => {:name => 'custom_field[name]', :value => 'Database'} | |||
|
93 | end | |||
|
94 | ||||
|
95 | def test_post_edit | |||
|
96 | post :edit, :id => 1, :custom_field => {:name => 'New name'} | |||
|
97 | assert_redirected_to '/custom_fields?tab=IssueCustomField' | |||
|
98 | ||||
|
99 | field = CustomField.find(1) | |||
|
100 | assert_equal 'New name', field.name | |||
|
101 | end | |||
|
102 | ||||
|
103 | def test_destroy | |||
|
104 | custom_values_count = CustomValue.count(:conditions => {:custom_field_id => 1}) | |||
|
105 | assert custom_values_count > 0 | |||
|
106 | ||||
|
107 | assert_difference 'CustomField.count', -1 do | |||
|
108 | assert_difference 'CustomValue.count', - custom_values_count do | |||
|
109 | post :destroy, :id => 1 | |||
|
110 | end | |||
|
111 | end | |||
|
112 | ||||
|
113 | assert_redirected_to '/custom_fields?tab=IssueCustomField' | |||
|
114 | assert_nil CustomField.find_by_id(1) | |||
|
115 | assert_nil CustomValue.find_by_custom_field_id(1) | |||
|
116 | end | |||
81 | end |
|
117 | end |
General Comments 0
You need to be logged in to leave comments.
Login now