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