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