summaryrefslogtreecommitdiffstats
path: root/test/functional/custom_fields_controller_test.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2011-11-27 21:11:10 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2011-11-27 21:11:10 +0000
commitf9bf53262a12f983cc8bdc3e650231ca6448cb81 (patch)
tree5935b82b151d6759dfe6ac84efa05e24859c9a44 /test/functional/custom_fields_controller_test.rb
parentb23827491a6d204eb118feeee16bec315dd9439c (diff)
downloadredmine-f9bf53262a12f983cc8bdc3e650231ca6448cb81.tar.gz
redmine-f9bf53262a12f983cc8bdc3e650231ca6448cb81.zip
Adds functional tests for CustomFieldsController.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7960 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/functional/custom_fields_controller_test.rb')
-rw-r--r--test/functional/custom_fields_controller_test.rb38
1 files changed, 37 insertions, 1 deletions
diff --git a/test/functional/custom_fields_controller_test.rb b/test/functional/custom_fields_controller_test.rb
index 57f0e9b8c..ce20b2b89 100644
--- a/test/functional/custom_fields_controller_test.rb
+++ b/test/functional/custom_fields_controller_test.rb
@@ -22,7 +22,7 @@ require 'custom_fields_controller'
class CustomFieldsController; def rescue_action(e) raise e end; end
class CustomFieldsControllerTest < ActionController::TestCase
- fixtures :custom_fields, :trackers, :users
+ fixtures :custom_fields, :custom_values, :trackers, :users
def setup
@controller = CustomFieldsController.new
@@ -31,6 +31,12 @@ class CustomFieldsControllerTest < ActionController::TestCase
@request.session[:user_id] = 1
end
+ def test_index
+ get :index
+ assert_response :success
+ assert_template 'index'
+ end
+
def test_get_new_issue_custom_field
get :new, :type => 'IssueCustomField'
assert_response :success
@@ -78,4 +84,34 @@ class CustomFieldsControllerTest < ActionController::TestCase
assert_equal ["0.1", "0.2"], field.possible_values
assert_equal 1, field.trackers.size
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