summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2011-11-29 20:04:30 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2011-11-29 20:04:30 +0000
commite5086772281335e732324420d1a5e84953aa8017 (patch)
tree90a870f96ce7831d23113cc797059ae9d6058cef /test
parentdd501b1ba30a90b78dbf8674ca541b3f306bc5c5 (diff)
downloadredmine-e5086772281335e732324420d1a5e84953aa8017.tar.gz
redmine-e5086772281335e732324420d1a5e84953aa8017.zip
Adds functional tests for EnumerationsController.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7987 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/functional/enumerations_controller_test.rb54
1 files changed, 47 insertions, 7 deletions
diff --git a/test/functional/enumerations_controller_test.rb b/test/functional/enumerations_controller_test.rb
index d306ef926..05e438b96 100644
--- a/test/functional/enumerations_controller_test.rb
+++ b/test/functional/enumerations_controller_test.rb
@@ -16,18 +16,11 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require File.expand_path('../../test_helper', __FILE__)
-require 'enumerations_controller'
-
-# Re-raise errors caught by the controller.
-class EnumerationsController; def rescue_action(e) raise e end; end
class EnumerationsControllerTest < ActionController::TestCase
fixtures :enumerations, :issues, :users
def setup
- @controller = EnumerationsController.new
- @request = ActionController::TestRequest.new
- @response = ActionController::TestResponse.new
@request.session[:user_id] = 1 # admin
end
@@ -37,6 +30,53 @@ class EnumerationsControllerTest < ActionController::TestCase
assert_template 'index'
end
+ def test_new
+ get :new, :type => 'IssuePriority'
+ assert_response :success
+ assert_template 'new'
+ assert_kind_of IssuePriority, assigns(:enumeration)
+ end
+
+ def test_create
+ assert_difference 'IssuePriority.count' do
+ post :create, :enumeration => {:type => 'IssuePriority', :name => 'Lowest'}
+ end
+ assert_redirected_to '/enumerations?type=IssuePriority'
+ e = IssuePriority.first(:order => 'id DESC')
+ assert_equal 'Lowest', e.name
+ end
+
+ def test_create_with_failure
+ assert_no_difference 'IssuePriority.count' do
+ post :create, :enumeration => {:type => 'IssuePriority', :name => ''}
+ end
+ assert_response :success
+ assert_template 'new'
+ end
+
+ def test_edit
+ get :edit, :id => 6
+ assert_response :success
+ assert_template 'edit'
+ end
+
+ def test_update
+ assert_no_difference 'IssuePriority.count' do
+ post :update, :id => 6, :enumeration => {:type => 'IssuePriority', :name => 'New name'}
+ end
+ assert_redirected_to '/enumerations?type=IssuePriority'
+ e = IssuePriority.find(6)
+ assert_equal 'New name', e.name
+ end
+
+ def test_update_with_failure
+ assert_no_difference 'IssuePriority.count' do
+ post :update, :id => 6, :enumeration => {:type => 'IssuePriority', :name => ''}
+ end
+ assert_response :success
+ assert_template 'edit'
+ end
+
def test_destroy_enumeration_not_in_use
post :destroy, :id => 7
assert_redirected_to :controller => 'enumerations', :action => 'index'