@@ -0,0 +1,73 | |||||
|
1 | require File.dirname(__FILE__) + '/../test_helper' | |||
|
2 | require 'issue_statuses_controller' | |||
|
3 | ||||
|
4 | # Re-raise errors caught by the controller. | |||
|
5 | class IssueStatusesController; def rescue_action(e) raise e end; end | |||
|
6 | ||||
|
7 | ||||
|
8 | class IssueStatusesControllerTest < ActionController::TestCase | |||
|
9 | fixtures :issue_statuses, :issues | |||
|
10 | ||||
|
11 | def setup | |||
|
12 | @controller = IssueStatusesController.new | |||
|
13 | @request = ActionController::TestRequest.new | |||
|
14 | @response = ActionController::TestResponse.new | |||
|
15 | User.current = nil | |||
|
16 | @request.session[:user_id] = 1 # admin | |||
|
17 | end | |||
|
18 | ||||
|
19 | def test_index | |||
|
20 | # TODO: unify with #list | |||
|
21 | get :index | |||
|
22 | assert_response :success | |||
|
23 | assert_template 'list' | |||
|
24 | end | |||
|
25 | ||||
|
26 | def test_new | |||
|
27 | get :new | |||
|
28 | assert_response :success | |||
|
29 | assert_template 'new' | |||
|
30 | end | |||
|
31 | ||||
|
32 | def test_create | |||
|
33 | assert_difference 'IssueStatus.count' do | |||
|
34 | post :create, :issue_status => {:name => 'New status'} | |||
|
35 | end | |||
|
36 | assert_redirected_to 'issue_statuses/list' | |||
|
37 | status = IssueStatus.find(:first, :order => 'id DESC') | |||
|
38 | assert_equal 'New status', status.name | |||
|
39 | end | |||
|
40 | ||||
|
41 | def test_edit | |||
|
42 | get :edit, :id => '3' | |||
|
43 | assert_response :success | |||
|
44 | assert_template 'edit' | |||
|
45 | end | |||
|
46 | ||||
|
47 | def test_update | |||
|
48 | post :update, :id => '3', :issue_status => {:name => 'Renamed status'} | |||
|
49 | assert_redirected_to 'issue_statuses/list' | |||
|
50 | status = IssueStatus.find(3) | |||
|
51 | assert_equal 'Renamed status', status.name | |||
|
52 | end | |||
|
53 | ||||
|
54 | def test_destroy | |||
|
55 | Issue.delete_all("status_id = 1") | |||
|
56 | ||||
|
57 | assert_difference 'IssueStatus.count', -1 do | |||
|
58 | post :destroy, :id => '1' | |||
|
59 | end | |||
|
60 | assert_redirected_to 'issue_statuses/list' | |||
|
61 | assert_nil IssueStatus.find_by_id(1) | |||
|
62 | end | |||
|
63 | ||||
|
64 | def test_destroy_should_block_if_status_in_use | |||
|
65 | assert_not_nil Issue.find_by_status_id(1) | |||
|
66 | ||||
|
67 | assert_no_difference 'IssueStatus.count' do | |||
|
68 | post :destroy, :id => '1' | |||
|
69 | end | |||
|
70 | assert_redirected_to 'issue_statuses/list' | |||
|
71 | assert_not_nil IssueStatus.find_by_id(1) | |||
|
72 | end | |||
|
73 | end |
@@ -4,4 +4,10 issue_relation_001: | |||||
4 | issue_to_id: 9 |
|
4 | issue_to_id: 9 | |
5 | relation_type: blocks |
|
5 | relation_type: blocks | |
6 | delay: |
|
6 | delay: | |
|
7 | issue_relation_002: | |||
|
8 | id: 2 | |||
|
9 | issue_from_id: 2 | |||
|
10 | issue_to_id: 3 | |||
|
11 | relation_type: relates | |||
|
12 | delay: | |||
7 |
|
13 |
@@ -13,6 +13,7 class IssueRelationsControllerTest < ActionController::TestCase | |||||
13 | :member_roles, |
|
13 | :member_roles, | |
14 | :issues, |
|
14 | :issues, | |
15 | :issue_statuses, |
|
15 | :issue_statuses, | |
|
16 | :issue_relations, | |||
16 | :enabled_modules, |
|
17 | :enabled_modules, | |
17 | :enumerations, |
|
18 | :enumerations, | |
18 | :trackers |
|
19 | :trackers | |
@@ -31,13 +32,6 class IssueRelationsControllerTest < ActionController::TestCase | |||||
31 | ) |
|
32 | ) | |
32 | end |
|
33 | end | |
33 |
|
34 | |||
34 | def test_destroy_routing |
|
|||
35 | assert_recognizes( #TODO: use DELETE on issue URI |
|
|||
36 | {:controller => 'issue_relations', :action => 'destroy', :issue_id => '1', :id => '23'}, |
|
|||
37 | {:method => :post, :path => '/issues/1/relations/23/destroy'} |
|
|||
38 | ) |
|
|||
39 | end |
|
|||
40 |
|
||||
41 | def test_new |
|
35 | def test_new | |
42 | assert_difference 'IssueRelation.count' do |
|
36 | assert_difference 'IssueRelation.count' do | |
43 | @request.session[:user_id] = 3 |
|
37 | @request.session[:user_id] = 3 | |
@@ -56,4 +50,18 class IssueRelationsControllerTest < ActionController::TestCase | |||||
56 | :relation => {:issue_to_id => '4', :relation_type => 'relates', :delay => ''} |
|
50 | :relation => {:issue_to_id => '4', :relation_type => 'relates', :delay => ''} | |
57 | end |
|
51 | end | |
58 | end |
|
52 | end | |
|
53 | ||||
|
54 | def test_destroy_routing | |||
|
55 | assert_recognizes( #TODO: use DELETE on issue URI | |||
|
56 | {:controller => 'issue_relations', :action => 'destroy', :issue_id => '1', :id => '23'}, | |||
|
57 | {:method => :post, :path => '/issues/1/relations/23/destroy'} | |||
|
58 | ) | |||
|
59 | end | |||
|
60 | ||||
|
61 | def test_destroy | |||
|
62 | assert_difference 'IssueRelation.count', -1 do | |||
|
63 | @request.session[:user_id] = 3 | |||
|
64 | post :destroy, :id => '2', :issue_id => '3' | |||
|
65 | end | |||
|
66 | end | |||
59 | end |
|
67 | end |
@@ -32,6 +32,12 class SettingsControllerTest < ActionController::TestCase | |||||
32 | @request.session[:user_id] = 1 # admin |
|
32 | @request.session[:user_id] = 1 # admin | |
33 | end |
|
33 | end | |
34 |
|
34 | |||
|
35 | def test_index | |||
|
36 | get :index | |||
|
37 | assert_response :success | |||
|
38 | assert_template 'edit' | |||
|
39 | end | |||
|
40 | ||||
35 | def test_get_edit |
|
41 | def test_get_edit | |
36 | get :edit |
|
42 | get :edit | |
37 | assert_response :success |
|
43 | assert_response :success |
General Comments 0
You need to be logged in to leave comments.
Login now