Adds functional tests for CustomFieldsController.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7960 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
b23827491a
commit
f9bf53262a
|
@ -22,7 +22,7 @@ require 'custom_fields_controller'
|
||||||
class CustomFieldsController; def rescue_action(e) raise e end; end
|
class CustomFieldsController; def rescue_action(e) raise e end; end
|
||||||
|
|
||||||
class CustomFieldsControllerTest < ActionController::TestCase
|
class CustomFieldsControllerTest < ActionController::TestCase
|
||||||
fixtures :custom_fields, :trackers, :users
|
fixtures :custom_fields, :custom_values, :trackers, :users
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@controller = CustomFieldsController.new
|
@controller = CustomFieldsController.new
|
||||||
|
@ -31,6 +31,12 @@ class CustomFieldsControllerTest < ActionController::TestCase
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_index
|
||||||
|
get :index
|
||||||
|
assert_response :success
|
||||||
|
assert_template 'index'
|
||||||
|
end
|
||||||
|
|
||||||
def test_get_new_issue_custom_field
|
def test_get_new_issue_custom_field
|
||||||
get :new, :type => 'IssueCustomField'
|
get :new, :type => 'IssueCustomField'
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
@ -78,4 +84,34 @@ class CustomFieldsControllerTest < ActionController::TestCase
|
||||||
assert_equal ["0.1", "0.2"], field.possible_values
|
assert_equal ["0.1", "0.2"], field.possible_values
|
||||||
assert_equal 1, field.trackers.size
|
assert_equal 1, field.trackers.size
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_get_edit
|
||||||
|
get :edit, :id => 1
|
||||||
|
assert_response :success
|
||||||
|
assert_template 'edit'
|
||||||
|
assert_tag 'input', :attributes => {:name => 'custom_field[name]', :value => 'Database'}
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_post_edit
|
||||||
|
post :edit, :id => 1, :custom_field => {:name => 'New name'}
|
||||||
|
assert_redirected_to '/custom_fields?tab=IssueCustomField'
|
||||||
|
|
||||||
|
field = CustomField.find(1)
|
||||||
|
assert_equal 'New name', field.name
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_destroy
|
||||||
|
custom_values_count = CustomValue.count(:conditions => {:custom_field_id => 1})
|
||||||
|
assert custom_values_count > 0
|
||||||
|
|
||||||
|
assert_difference 'CustomField.count', -1 do
|
||||||
|
assert_difference 'CustomValue.count', - custom_values_count do
|
||||||
|
post :destroy, :id => 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_redirected_to '/custom_fields?tab=IssueCustomField'
|
||||||
|
assert_nil CustomField.find_by_id(1)
|
||||||
|
assert_nil CustomValue.find_by_custom_field_id(1)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue