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