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