Adds functional tests.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8948 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2012-02-23 14:39:55 +00:00
parent e6a64aa00b
commit c49ef8e543
3 changed files with 43 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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")