##// END OF EJS Templates
remove trailing white-spaces from test/functional/issue_moves_controller_test.rb....
Toshi MARUYAMA -
r6788:ee40c7aac325
parent child
Show More
@@ -1,156 +1,156
1 1 require File.expand_path('../../test_helper', __FILE__)
2 2
3 3 class IssueMovesControllerTest < ActionController::TestCase
4 4 fixtures :all
5 5
6 6 def setup
7 7 User.current = nil
8 8 end
9 9
10 10 def test_get_issue_moves_new
11 11 @request.session[:user_id] = 2
12 12 get :new, :id => 1
13 13
14 14 assert_tag :tag => 'option', :content => 'eCookbook',
15 15 :attributes => { :value => '1', :selected => 'selected' }
16 16 %w(new_tracker_id status_id priority_id assigned_to_id).each do |field|
17 17 assert_tag :tag => 'option', :content => '(No change)', :attributes => { :value => '' },
18 18 :parent => {:tag => 'select', :attributes => {:id => field}}
19 19 assert_no_tag :tag => 'option', :attributes => {:selected => 'selected'},
20 20 :parent => {:tag => 'select', :attributes => {:id => field}}
21 21 end
22 22
23 23 # Be sure we don't include inactive enumerations
24 24 assert ! IssuePriority.find(15).active?
25 25 assert_no_tag :option, :attributes => {:value => '15'},
26 26 :parent => {:tag => 'select', :attributes => {:id => 'priority_id'} }
27 27 end
28 28
29 29 def test_create_one_issue_to_another_project
30 30 @request.session[:user_id] = 2
31 31 post :create, :id => 1, :new_project_id => 2, :tracker_id => '', :assigned_to_id => '', :status_id => '', :start_date => '', :due_date => ''
32 32 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook'
33 33 assert_equal 2, Issue.find(1).project_id
34 34 end
35 35
36 36 def test_create_one_issue_to_another_project_should_follow_when_needed
37 37 @request.session[:user_id] = 2
38 38 post :create, :id => 1, :new_project_id => 2, :follow => '1'
39 39 assert_redirected_to '/issues/1'
40 40 end
41 41
42 42 def test_bulk_create_to_another_project
43 43 @request.session[:user_id] = 2
44 44 post :create, :ids => [1, 2], :new_project_id => 2
45 45 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook'
46 46 # Issues moved to project 2
47 47 assert_equal 2, Issue.find(1).project_id
48 48 assert_equal 2, Issue.find(2).project_id
49 49 # No tracker change
50 50 assert_equal 1, Issue.find(1).tracker_id
51 51 assert_equal 2, Issue.find(2).tracker_id
52 52 end
53
53
54 54 def test_bulk_create_to_another_tracker
55 55 @request.session[:user_id] = 2
56 56 post :create, :ids => [1, 2], :new_tracker_id => 2
57 57 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook'
58 58 assert_equal 2, Issue.find(1).tracker_id
59 59 assert_equal 2, Issue.find(2).tracker_id
60 60 end
61 61
62 62 context "#create via bulk move" do
63 63 setup do
64 64 @request.session[:user_id] = 2
65 65 end
66
66
67 67 should "allow changing the issue priority" do
68 68 post :create, :ids => [1, 2], :priority_id => 6
69 69
70 70 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook'
71 71 assert_equal 6, Issue.find(1).priority_id
72 72 assert_equal 6, Issue.find(2).priority_id
73 73
74 74 end
75 75
76 76 should "allow adding a note when moving" do
77 77 post :create, :ids => [1, 2], :notes => 'Moving two issues'
78 78
79 79 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook'
80 80 assert_equal 'Moving two issues', Issue.find(1).journals.sort_by(&:id).last.notes
81 81 assert_equal 'Moving two issues', Issue.find(2).journals.sort_by(&:id).last.notes
82 82
83 83 end
84
84
85 85 end
86 86
87 87 def test_bulk_copy_to_another_project
88 88 @request.session[:user_id] = 2
89 89 assert_difference 'Issue.count', 2 do
90 90 assert_no_difference 'Project.find(1).issues.count' do
91 91 post :create, :ids => [1, 2], :new_project_id => 2, :copy_options => {:copy => '1'}
92 92 end
93 93 end
94 94 assert_redirected_to '/projects/ecookbook/issues'
95 95 end
96 96
97 97 context "#create via bulk copy" do
98 98 should "allow not changing the issue's attributes" do
99 99 @request.session[:user_id] = 2
100 100 issue_before_move = Issue.find(1)
101 101 assert_difference 'Issue.count', 1 do
102 102 assert_no_difference 'Project.find(1).issues.count' do
103 103 post :create, :ids => [1], :new_project_id => 2, :copy_options => {:copy => '1'}, :new_tracker_id => '', :assigned_to_id => '', :status_id => '', :start_date => '', :due_date => ''
104 104 end
105 105 end
106 106 issue_after_move = Issue.first(:order => 'id desc', :conditions => {:project_id => 2})
107 107 assert_equal issue_before_move.tracker_id, issue_after_move.tracker_id
108 108 assert_equal issue_before_move.status_id, issue_after_move.status_id
109 109 assert_equal issue_before_move.assigned_to_id, issue_after_move.assigned_to_id
110 110 end
111
111
112 112 should "allow changing the issue's attributes" do
113 113 # Fixes random test failure with Mysql
114 114 # where Issue.all(:limit => 2, :order => 'id desc', :conditions => {:project_id => 2}) doesn't return the expected results
115 115 Issue.delete_all("project_id=2")
116
116
117 117 @request.session[:user_id] = 2
118 118 assert_difference 'Issue.count', 2 do
119 119 assert_no_difference 'Project.find(1).issues.count' do
120 120 post :create, :ids => [1, 2], :new_project_id => 2, :copy_options => {:copy => '1'}, :new_tracker_id => '', :assigned_to_id => 4, :status_id => 3, :start_date => '2009-12-01', :due_date => '2009-12-31'
121 121 end
122 122 end
123 123
124 124 copied_issues = Issue.all(:limit => 2, :order => 'id desc', :conditions => {:project_id => 2})
125 125 assert_equal 2, copied_issues.size
126 126 copied_issues.each do |issue|
127 127 assert_equal 2, issue.project_id, "Project is incorrect"
128 128 assert_equal 4, issue.assigned_to_id, "Assigned to is incorrect"
129 129 assert_equal 3, issue.status_id, "Status is incorrect"
130 130 assert_equal '2009-12-01', issue.start_date.to_s, "Start date is incorrect"
131 131 assert_equal '2009-12-31', issue.due_date.to_s, "Due date is incorrect"
132 132 end
133 133 end
134 134
135 135 should "allow adding a note when copying" do
136 136 @request.session[:user_id] = 2
137 137 assert_difference 'Issue.count', 1 do
138 138 post :create, :ids => [1], :copy_options => {:copy => '1'}, :notes => 'Copying one issue', :new_tracker_id => '', :assigned_to_id => 4, :status_id => 3, :start_date => '2009-12-01', :due_date => '2009-12-31'
139 139 end
140
140
141 141 issue = Issue.first(:order => 'id DESC')
142 142 assert_equal 1, issue.journals.size
143 143 journal = issue.journals.first
144 144 assert_equal 0, journal.details.size
145 145 assert_equal 'Copying one issue', journal.notes
146 146 end
147 147 end
148
148
149 149 def test_copy_to_another_project_should_follow_when_needed
150 150 @request.session[:user_id] = 2
151 151 post :create, :ids => [1], :new_project_id => 2, :copy_options => {:copy => '1'}, :follow => '1'
152 152 issue = Issue.first(:order => 'id DESC')
153 153 assert_redirected_to :controller => 'issues', :action => 'show', :id => issue
154 154 end
155 155
156 156 end
General Comments 0
You need to be logged in to leave comments. Login now