backlog 0.31.0 → 0.31.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -4
- data/app/models/task.rb +26 -5
- data/config/routes.rb +0 -2
- data/test/functional/periods_controller_test.rb +10 -0
- data/test/unit/task_test.rb +47 -0
- metadata +2 -2
data/History.txt
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
== 0.31.1 2008-04-24
|
2
|
+
|
3
|
+
=== Fixes
|
4
|
+
|
5
|
+
* Fixed moving of subtasks. Now supertasks are also moved.
|
6
|
+
|
1
7
|
== 0.31.0 2008-04-14
|
2
8
|
|
3
9
|
=== Features
|
@@ -10,10 +16,6 @@
|
|
10
16
|
* Added list of all task owners to Edit Task view.
|
11
17
|
* Changed so that the creator of a task automatically grabs it.
|
12
18
|
|
13
|
-
=== Internal
|
14
|
-
|
15
|
-
*
|
16
|
-
|
17
19
|
== 0.30.0 2008-04-09
|
18
20
|
|
19
21
|
=== Features
|
data/app/models/task.rb
CHANGED
@@ -69,6 +69,14 @@ class Task < ActiveRecord::Base
|
|
69
69
|
def self.recent_conditions
|
70
70
|
return "finished_at >= '#{1.week.ago.iso8601}'"
|
71
71
|
end
|
72
|
+
|
73
|
+
def self.find_descendant(period_id, ancestor_task_id)
|
74
|
+
candidate_tasks = Task.find :all,
|
75
|
+
:conditions => ["id = ? OR previous_task_id = ?", ancestor_task_id, ancestor_task_id]
|
76
|
+
candidate_tasks = candidate_tasks.select {|t| t.root_task.period_id == period_id}
|
77
|
+
logger.error "Multiple descendants in period: #{period_id} #{ancestor_task_id}" if candidate_tasks.size > 1
|
78
|
+
candidate_tasks[0]
|
79
|
+
end
|
72
80
|
|
73
81
|
def self_with_children
|
74
82
|
[self] << children.map {|t| t.self_with_children}.flatten
|
@@ -158,9 +166,13 @@ class Task < ActiveRecord::Base
|
|
158
166
|
|
159
167
|
if self.period
|
160
168
|
old_todo = self.todo
|
161
|
-
|
162
|
-
|
163
|
-
|
169
|
+
if parent
|
170
|
+
parent.move_to_period new_period
|
171
|
+
end
|
172
|
+
if leaf?
|
173
|
+
self.finish((new_period.nil? || (new_period.party == self.period.party)) ? Task::POSTPONED : Task::MOVED, true)
|
174
|
+
end
|
175
|
+
existing_task = Task.find_descendant(new_period && new_period.id, ancestor_id)
|
164
176
|
if existing_task ||= Task.find_by_period_id_and_previous_task_id(new_period && new_period.id, ancestor_id)
|
165
177
|
raise "mismatch" unless existing_task.backlog == root_task.backlog
|
166
178
|
raise "Mismatch" unless existing_task.period == new_period
|
@@ -173,8 +185,13 @@ class Task < ActiveRecord::Base
|
|
173
185
|
else
|
174
186
|
new_task = Task.new
|
175
187
|
new_task.previous_task_id = ancestor_id
|
176
|
-
|
177
|
-
|
188
|
+
if parent
|
189
|
+
new_parent = Task.find_descendant(new_period.id, parent.ancestor_id)
|
190
|
+
new_task.parent = new_parent
|
191
|
+
else
|
192
|
+
new_task.backlog = root_task.backlog
|
193
|
+
new_task.period = new_period
|
194
|
+
end
|
178
195
|
new_task.description = self.description
|
179
196
|
new_task.initial_estimate = self.initial_estimate
|
180
197
|
new_task.position = nil
|
@@ -405,4 +422,8 @@ class Task < ActiveRecord::Base
|
|
405
422
|
end
|
406
423
|
end
|
407
424
|
|
425
|
+
def ancestor_id
|
426
|
+
previous_task_id || id
|
427
|
+
end
|
428
|
+
|
408
429
|
end
|
data/config/routes.rb
CHANGED
@@ -131,6 +131,16 @@ class PeriodsControllerTest < Test::Unit::TestCase
|
|
131
131
|
check_move_effects(before, :future)
|
132
132
|
end
|
133
133
|
|
134
|
+
def test_move_task_to_next_period
|
135
|
+
before = Task.find(tasks(:another).id)
|
136
|
+
|
137
|
+
post :move_task_to_next_period, :id => tasks(:another).id
|
138
|
+
|
139
|
+
assert_response :redirect
|
140
|
+
|
141
|
+
check_move_effects(before, :future)
|
142
|
+
end
|
143
|
+
|
134
144
|
def test_move_task_to_next_period_xhr
|
135
145
|
before = Task.find(tasks(:another).id)
|
136
146
|
|
data/test/unit/task_test.rb
CHANGED
@@ -23,4 +23,51 @@ class TaskTest < Test::Unit::TestCase
|
|
23
23
|
tasks(:first).start_work
|
24
24
|
tasks(:another).start_work
|
25
25
|
end
|
26
|
+
|
27
|
+
def test_move_task_to_period
|
28
|
+
before = Task.find(tasks(:another).id)
|
29
|
+
period = periods(:future)
|
30
|
+
|
31
|
+
before.move_to_period period
|
32
|
+
|
33
|
+
check_move_effects(before, :future)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_move_task_to_period_subtask
|
37
|
+
before = Task.find(tasks(:subsubtask).id)
|
38
|
+
period = periods(:future)
|
39
|
+
|
40
|
+
before.move_to_period period
|
41
|
+
|
42
|
+
check_move_effects(before, :future)
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def check_move_effects(before, period_sym)
|
48
|
+
after = Task.find(before.id)
|
49
|
+
assert_equal before.period_id, after.period_id
|
50
|
+
assert_equal Task::POSTPONED, after.resolution
|
51
|
+
assert_not_nil after.finished_at
|
52
|
+
|
53
|
+
newest_task = Task.find(:first, :order => 'id DESC')
|
54
|
+
new_task = Task.find_descendant(periods(period_sym).id, before.id)
|
55
|
+
assert_not_nil newest_task
|
56
|
+
assert_not_nil new_task
|
57
|
+
assert_equal newest_task.id, new_task.id
|
58
|
+
assert_equal before.previous_task_id || before.id, new_task.previous_task_id
|
59
|
+
assert_nil new_task.finished_at
|
60
|
+
assert_nil new_task.resolution
|
61
|
+
assert_equal 1, new_task.position
|
62
|
+
|
63
|
+
while before.parent
|
64
|
+
before = before.parent
|
65
|
+
new_parent_task = Task.find_descendant(periods(period_sym).id, before.id)
|
66
|
+
assert new_parent_task
|
67
|
+
assert_equal new_parent_task.id, new_task.parent_id
|
68
|
+
new_task = new_parent_task
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
|
26
73
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: backlog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.31.
|
4
|
+
version: 0.31.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Uwe Kubosch
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-04-
|
12
|
+
date: 2008-04-24 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|