From c49ef8e543c47ebe1a50f54811545ba21159beef Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Thu, 23 Feb 2012 14:39:55 +0000 Subject: [PATCH] Adds functional tests. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8948 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- .../functional/attachments_controller_test.rb | 5 ++++ .../issue_categories_controller_test.rb | 24 +++++++++++++++++++ .../issue_statuses_controller_test.rb | 14 +++++++++++ 3 files changed, 43 insertions(+) diff --git a/test/functional/attachments_controller_test.rb b/test/functional/attachments_controller_test.rb index 834e6b08b..4deae88c8 100644 --- a/test/functional/attachments_controller_test.rb +++ b/test/functional/attachments_controller_test.rb @@ -219,6 +219,11 @@ class AttachmentsControllerTest < ActionController::TestCase assert_response 403 end + def test_show_invalid_should_respond_with_404 + get :show, :id => 999 + assert_response 404 + end + def test_download_text_file get :download, :id => 4 assert_response :success diff --git a/test/functional/issue_categories_controller_test.rb b/test/functional/issue_categories_controller_test.rb index 221d5d1cc..15bee0ccd 100644 --- a/test/functional/issue_categories_controller_test.rb +++ b/test/functional/issue_categories_controller_test.rb @@ -57,6 +57,30 @@ class IssueCategoriesControllerTest < ActionController::TestCase assert_template 'new' end + def test_create_from_issue_form + @request.session[:user_id] = 2 # manager + assert_difference 'IssueCategory.count' do + xhr :post, :create, :project_id => '1', :issue_category => {:name => 'New category'} + end + category = IssueCategory.first(:order => 'id DESC') + assert_equal 'New category', category.name + + assert_response :success + assert_select_rjs :replace, 'issue_category_id' do + assert_select "option[value=#{category.id}][selected=selected]" + end + end + + def test_create_from_issue_form_with_failure + @request.session[:user_id] = 2 # manager + assert_no_difference 'IssueCategory.count' do + xhr :post, :create, :project_id => '1', :issue_category => {:name => ''} + end + + assert_response :success + assert_match /alert/, @response.body + end + def test_edit @request.session[:user_id] = 2 get :edit, :id => 2 diff --git a/test/functional/issue_statuses_controller_test.rb b/test/functional/issue_statuses_controller_test.rb index 33519de61..c32999f80 100644 --- a/test/functional/issue_statuses_controller_test.rb +++ b/test/functional/issue_statuses_controller_test.rb @@ -49,6 +49,13 @@ class IssueStatusesControllerTest < ActionController::TestCase assert_equal 'New status', status.name end + def test_create_with_failure + post :create, :issue_status => {:name => ''} + assert_response :success + assert_template 'new' + assert_error_tag :content => /name can't be blank/i + end + def test_edit get :edit, :id => '3' assert_response :success @@ -62,6 +69,13 @@ class IssueStatusesControllerTest < ActionController::TestCase assert_equal 'Renamed status', status.name end + def test_update_with_failure + put :update, :id => '3', :issue_status => {:name => ''} + assert_response :success + assert_template 'edit' + assert_error_tag :content => /name can't be blank/i + end + def test_destroy Issue.delete_all("status_id = 1") -- 2.39.5