##// END OF EJS Templates
Adds functional tests....
Jean-Philippe Lang -
r8828:c49ef8e543c4
parent child
Show More
@@ -219,6 +219,11 class AttachmentsControllerTest < ActionController::TestCase
219 assert_response 403
219 assert_response 403
220 end
220 end
221
221
222 def test_show_invalid_should_respond_with_404
223 get :show, :id => 999
224 assert_response 404
225 end
226
222 def test_download_text_file
227 def test_download_text_file
223 get :download, :id => 4
228 get :download, :id => 4
224 assert_response :success
229 assert_response :success
@@ -57,6 +57,30 class IssueCategoriesControllerTest < ActionController::TestCase
57 assert_template 'new'
57 assert_template 'new'
58 end
58 end
59
59
60 def test_create_from_issue_form
61 @request.session[:user_id] = 2 # manager
62 assert_difference 'IssueCategory.count' do
63 xhr :post, :create, :project_id => '1', :issue_category => {:name => 'New category'}
64 end
65 category = IssueCategory.first(:order => 'id DESC')
66 assert_equal 'New category', category.name
67
68 assert_response :success
69 assert_select_rjs :replace, 'issue_category_id' do
70 assert_select "option[value=#{category.id}][selected=selected]"
71 end
72 end
73
74 def test_create_from_issue_form_with_failure
75 @request.session[:user_id] = 2 # manager
76 assert_no_difference 'IssueCategory.count' do
77 xhr :post, :create, :project_id => '1', :issue_category => {:name => ''}
78 end
79
80 assert_response :success
81 assert_match /alert/, @response.body
82 end
83
60 def test_edit
84 def test_edit
61 @request.session[:user_id] = 2
85 @request.session[:user_id] = 2
62 get :edit, :id => 2
86 get :edit, :id => 2
@@ -49,6 +49,13 class IssueStatusesControllerTest < ActionController::TestCase
49 assert_equal 'New status', status.name
49 assert_equal 'New status', status.name
50 end
50 end
51
51
52 def test_create_with_failure
53 post :create, :issue_status => {:name => ''}
54 assert_response :success
55 assert_template 'new'
56 assert_error_tag :content => /name can't be blank/i
57 end
58
52 def test_edit
59 def test_edit
53 get :edit, :id => '3'
60 get :edit, :id => '3'
54 assert_response :success
61 assert_response :success
@@ -62,6 +69,13 class IssueStatusesControllerTest < ActionController::TestCase
62 assert_equal 'Renamed status', status.name
69 assert_equal 'Renamed status', status.name
63 end
70 end
64
71
72 def test_update_with_failure
73 put :update, :id => '3', :issue_status => {:name => ''}
74 assert_response :success
75 assert_template 'edit'
76 assert_error_tag :content => /name can't be blank/i
77 end
78
65 def test_destroy
79 def test_destroy
66 Issue.delete_all("status_id = 1")
80 Issue.delete_all("status_id = 1")
67
81
General Comments 0
You need to be logged in to leave comments. Login now