backlog 0.7.1 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ == 0.7.2 2007-08-17
2
+
3
+ * Fixed bugs in task reordering links
4
+ * Switched default language to English
5
+ * Fixed English mailer views
6
+
1
7
  == 0.7.1 2007-08-14
2
8
 
3
9
  * Added author and email to the gem to avoid false listing in Hoe Down!
@@ -57,13 +57,7 @@ class BacklogsController < ApplicationController
57
57
  def edit
58
58
  @backlog = Backlog.find(params[:id])
59
59
  unplanned_tasks = @backlog.tasks.select {|t| t.period.nil? && t.finished_at.nil?}.sort_by {|t| t.position}
60
- planned_tasks = @backlog.tasks.select {|t| t.period && t.finished_at.nil?}.sort do |t1, t2|
61
- if (cmp_period = t1.period.end_on <=> t2.period.end_on) != 0
62
- cmp_period
63
- else
64
- t1.position <=> t2.position
65
- end
66
- end
60
+ planned_tasks = @backlog.tasks.select {|t| t.period && t.finished_at.nil?}.sort_by {|t| [t.period.end_on, t.position]}
67
61
  @tasks = planned_tasks + unplanned_tasks
68
62
  @completed_tasks = @backlog.tasks.select {|t| t.finished_at}.sort {|t1, t2| t2.finished_at <=> t1.finished_at}
69
63
  end
@@ -147,7 +147,8 @@ class TasksController < ApplicationController
147
147
  end
148
148
 
149
149
  def move_to_period(with_layout = false)
150
- task = Task.find(params[:id][5..-1])
150
+ params[:id] = $1 if params[:id] =~ /^task_(\d*)$/
151
+ task = Task.find(params[:id])
151
152
  if request.post?
152
153
  period = params[:period_id] && Period.find(params[:period_id])
153
154
  if period && period.active_or_future?
@@ -170,7 +171,7 @@ class TasksController < ApplicationController
170
171
  task = Task.find(params[:id])
171
172
  if task.period
172
173
  params[:period_id] = task.period.lower_item && task.period.lower_item.id
173
- params[:id] = 'task_' + task.id.to_s
174
+ params[:id] = task.id
174
175
  move_to_period(true)
175
176
  else
176
177
  redirect_to :action => :edit, :id => task
data/app/models/task.rb CHANGED
@@ -9,15 +9,19 @@ class Task < ActiveRecord::Base
9
9
 
10
10
  belongs_to :backlog
11
11
  belongs_to :period
12
- acts_as_list :scope => :period_id
12
+ belongs_to :ancestor_task, :class_name => 'Task', :foreign_key => 'previous_task_id'
13
+ has_many :descendant_tasks, :class_name => 'Task', :foreign_key => 'previous_task_id', :dependent => :destroy
14
+
15
+ #before_validation_on_create {|task| task.position = -1}
16
+ acts_as_list :scope => '#{period_id ? "period_id = #{period_id}" : "period_id IS NULL AND backlog_id = #{backlog_id}"} AND finished_at IS NULL'
13
17
  has_many :estimates, :order => 'created_at', :dependent => :destroy
14
18
  has_many :works, :order => 'completed_at', :dependent => :destroy
15
19
  acts_as_tree :order => 'position'
16
20
 
17
21
  validates_presence_of :backlog_id, :if => Proc.new { |task| task.parent_id.nil? }
18
22
  validates_presence_of :parent_id, :if => Proc.new { |task| task.backlog_id.nil? }
19
- validates_presence_of :position, :if => Proc.new { |task| task.finished_at.nil? }
20
- validates_presence_of :finished_at, :if => Proc.new { |task| task.position.nil? }
23
+ validates_presence_of :position, :on => :update, :if => Proc.new { |task| task.finished_at.nil? }
24
+ validates_presence_of :finished_at, :on => :update, :if => Proc.new { |task| task.position.nil? }
21
25
  validates_presence_of :resolution, :if => :finished_at
22
26
  validates_presence_of :description, :if => :backlog_id
23
27
 
@@ -113,10 +117,11 @@ class Task < ActiveRecord::Base
113
117
 
114
118
  def open
115
119
  if finished_at
116
- insert_at 1
117
- self.position = 1
118
120
  self.finished_at = nil
119
121
  self.resolution = nil
122
+ insert_at 1
123
+ self.position = 1
124
+ self.save!
120
125
  estimate(initial_estimate)
121
126
  parent.open if parent
122
127
  end
@@ -141,6 +146,7 @@ class Task < ActiveRecord::Base
141
146
  self.position = nil
142
147
 
143
148
  if self.period
149
+ old_todo = self.todo
144
150
  self.finish(new_period.party == self.period.party ? Task::POSTPONED : Task::MOVED, true)
145
151
  ancestor_id = self.previous_task_id || self.id
146
152
  existing_task = Task.find_by_period_id_and_id(new_period.id, ancestor_id)
@@ -151,18 +157,18 @@ class Task < ActiveRecord::Base
151
157
  existing_task.previous_task_id = self.previous_task_id || self.id
152
158
  existing_task.description = self.description
153
159
  existing_task.save!
154
- existing_task.estimate(self.todo)
155
- existing_task.move_to_top
156
- existing_task.save!
160
+ existing_task.estimate(old_todo)
157
161
  else
158
162
  new_task = Task.new
159
- new_task.previous_task_id = self.previous_task_id || self.id
163
+ new_task.previous_task_id = ancestor_id
160
164
  new_task.backlog = root_task.backlog
161
165
  new_task.period = new_period
162
166
  new_task.description = self.description
167
+ new_task.initial_estimate = self.initial_estimate
163
168
  new_task.insert_at 1
169
+ new_task.position = 1
164
170
  new_task.save!
165
- new_task.estimate(self.todo)
171
+ new_task.estimate(old_todo)
166
172
  end
167
173
  else
168
174
  self.period_id = new_period.id
@@ -1,8 +1,6 @@
1
1
  module Localization
2
2
  CONFIG = {
3
- # Default language
4
- :default_language => 'no',
5
-
3
+ :default_language => 'en',
6
4
  :web_charset => 'utf-8'
7
5
  }
8
6
 
@@ -1,4 +1,3 @@
1
- # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
1
  first:
3
2
  id: 1
4
3
  created_at: 2007-06-11
@@ -13,22 +12,32 @@ another:
13
12
  period_id: 2
14
13
  description: second task
15
14
  position: 1
16
- started:
15
+ postponed:
17
16
  id: 3
17
+ created_at: 2007-06-12
18
+ backlog_id: 1
19
+ period_id: 2
20
+ description: postponed task
21
+ finished_at: 2007-08-02 14:15:42
22
+ resolution: POSTPONED
23
+ started:
24
+ id: 4
18
25
  created_at: 2007-08-02 14:15:42
19
26
  backlog_id: 2
20
27
  period_id: 2
21
28
  description: third task
22
29
  position: 2
23
30
  in_last_period:
24
- id: 4
31
+ id: 5
25
32
  created_at: 2007-08-02 14:15:42
26
33
  backlog_id: 1
27
34
  period_id: 3
28
35
  description: task in last period
36
+ initial_estimate: 1.0
29
37
  position: 1
38
+ previous_task_id: 3
30
39
  not_planned:
31
- id: 5
40
+ id: 6
32
41
  created_at: 2007-08-02 14:15:42
33
42
  backlog_id: 1
34
43
  description: unplanned task
@@ -6,5 +6,5 @@ first:
6
6
  completed_at: 2007-06-12T14:35:00
7
7
  started:
8
8
  id: 2
9
- task_id: 3
9
+ task_id: 4
10
10
  started_at: 2007-06-12T13:35:00
@@ -6,115 +6,114 @@ class TasksController; def rescue_action(e) raise e end; end
6
6
 
7
7
  class TasksControllerTest < Test::Unit::TestCase
8
8
  fixtures :parties, :users, :groups, :groups_users, :backlogs, :periods, :tasks, :works, :estimates
9
-
9
+
10
10
  def setup
11
11
  @controller = TasksController.new
12
12
  @request = ActionController::TestRequest.new
13
13
  @response = ActionController::TestResponse.new
14
14
  @request.session[:user_id] = 1000001
15
15
  end
16
-
16
+
17
17
  def test_index
18
18
  get :index
19
19
  assert_redirected_to :controller => 'backlogs'
20
20
  end
21
-
21
+
22
22
  def test_list
23
23
  get :list
24
24
  assert_redirected_to :controller => 'backlogs'
25
25
  end
26
-
26
+
27
27
  def test_list_started
28
28
  get :list_started, :id => '1'
29
29
  assert_response :success
30
30
  assert_template 'list_started'
31
-
31
+
32
32
  assert_not_nil assigns(:tasks)
33
33
  assert_not_nil assigns(:selected_task)
34
34
  end
35
-
35
+
36
36
  def test_list_started_no_selected_task
37
37
  get :list_started
38
38
  assert_response :success
39
39
  assert_template 'list_started'
40
-
40
+
41
41
  assert_not_nil assigns(:tasks)
42
42
  assert_nil assigns(:selected_task)
43
43
  end
44
-
44
+
45
45
  def test_new
46
46
  get :new
47
-
47
+
48
48
  assert_response :success
49
49
  assert_template 'new'
50
-
50
+
51
51
  assert_not_nil assigns(:task)
52
52
  end
53
-
53
+
54
54
  def test_create
55
55
  num_tasks = Task.count
56
-
56
+
57
57
  post :create, :task => {:description => 'an important task', :backlog_id => '2',
58
- :period_id => '2', :position => '4'}
59
-
58
+ :period_id => '2'}
59
+
60
60
  task = assigns(:task)
61
61
  assert_equal [], task.errors.full_messages
62
-
62
+
63
63
  assert_response :redirect
64
64
  assert_redirected_to :controller => 'periods', :action => 'show', :id => Period.find(2)
65
-
65
+
66
66
  assert_equal num_tasks + 1, Task.count
67
67
  end
68
-
68
+
69
69
  def test_create_without_period
70
70
  num_tasks = Task.count
71
-
72
- post :create, :task => {:description => 'an important task', :backlog_id => '2',
73
- :position => '1'}
74
-
71
+
72
+ post :create, :task => {:description => 'an important task', :backlog_id => '2'}
73
+
75
74
  task = assigns(:task)
76
75
  assert_equal [], task.errors.full_messages
77
-
76
+
78
77
  assert_response :redirect
79
78
  assert_redirected_to :controller => 'backlogs', :action => :edit, :id => 2
80
-
79
+
81
80
  assert_equal num_tasks + 1, Task.count
82
81
  end
83
-
82
+
84
83
  def test_edit
85
84
  get :edit, :id => 1
86
-
85
+
87
86
  assert_response :success
88
87
  assert_template 'edit'
89
-
88
+
90
89
  assert_not_nil assigns(:task)
91
90
  assert assigns(:task).valid?
92
91
  end
93
-
92
+
94
93
  def test_update
95
94
  post :update, :id => 2, :task => {:description => 'Two'}
96
95
  assert_response :redirect
97
96
  assert_redirected_to :action => 'show', :id => 2
98
-
97
+
99
98
  after = Task.find(2)
100
99
  assert_equal 'Two', after.description
101
100
  end
102
-
101
+
103
102
  def test_destroy
104
103
  assert_not_nil Task.find(1)
105
-
104
+
106
105
  post :destroy, :id => 1
107
106
  assert_response :redirect
108
107
  assert_redirected_to :controller => 'periods', :action => 'show', :id => Period.find(1)
109
-
108
+
110
109
  assert_raise(ActiveRecord::RecordNotFound) {
111
110
  Task.find(1)
112
111
  }
113
112
  end
114
-
113
+
115
114
  def test_end_work
116
115
  before = Task.find(1)
117
-
116
+
118
117
  post :end_work, :id => 1, :work => {:work_started_at_time => (Time.now - 3600).strftime('%H:%M')}
119
118
  assert_response :redirect
120
119
  assert_redirected_to :controller => 'works', :action => :new,
@@ -123,34 +122,56 @@ class TasksControllerTest < Test::Unit::TestCase
123
122
  'work[completed_at]' => Time.next_quarter.iso8601,
124
123
  'work[started_at]' => Time.previous_quarter.iso8601,
125
124
  'estimate[todo]' => 1
126
-
125
+
127
126
  after = Task.find(1)
128
127
  assert((after.total_done == BigDecimal('1')) || (after.total_done - 1 < 0.2))
129
128
  end
130
129
 
130
+ def test_move_to_next_period
131
+ before = Task.find(tasks(:another).id)
132
+
133
+ post :move_to_next_period, :id => tasks(:another).id
134
+
135
+ assert_response :redirect
136
+ assert_redirected_to :controller => 'periods',
137
+ :action => :show,
138
+ :id => 2
139
+
140
+ after = Task.find(tasks(:another).id)
141
+ assert_equal tasks(:another).period_id, after.period_id
142
+
143
+ new_task = Task.find_by_period_id_and_previous_task_id(periods(:future).id, before.id)
144
+ assert_nil new_task.finished_at
145
+ assert_nil new_task.resolution
146
+ tasks = Task.find_all_by_period_id(3)
147
+ assert_equal 1, new_task.position
148
+ end
149
+
131
150
  def test_move_to_next_period_at_end
132
151
  before = Task.find(tasks(:in_last_period).id)
133
152
  assert_equal tasks(:in_last_period).period_id, before.period_id
134
-
153
+
135
154
  post :move_to_next_period, :id => tasks(:in_last_period).id
136
155
 
137
156
  assert_response :redirect
138
157
  assert_redirected_to :controller => 'periods',
139
- :action => :new,
140
- :period => {:party_id => 1}
141
-
158
+ :action => :new,
159
+ :period => {:party_id => 1}
160
+
142
161
  before.reload
143
162
  assert_equal tasks(:in_last_period).period_id, before.period_id
144
-
163
+
145
164
  after = Task.find(tasks(:in_last_period).id)
146
165
  assert_equal before.period_id, after.period_id
147
166
  end
148
167
 
149
168
  def test_move_to_period
150
169
  highest = Task.find(:first, :order => 'id DESC')
170
+
151
171
  post :move_to_period, :id => 'task_2',
152
- :detour => {:action => 'show_no_layout', :id => '2', :controller => 'periods'},
153
- :period_id => '3'
172
+ :detour => {:action => 'show_no_layout', :id => '2', :controller => 'periods'},
173
+ :period_id => '3'
174
+
154
175
  new_task = Task.find(:first, :order => 'id DESC')
155
176
  assert new_task.id != highest.id
156
177
  assert_equal 3, new_task.period_id
@@ -158,9 +179,31 @@ class TasksControllerTest < Test::Unit::TestCase
158
179
 
159
180
  def test_move_to_period_past
160
181
  post :move_to_period, :id => 'task_2',
161
- :detour => {:action => 'show_no_layout', :id => '2', :controller => 'periods'},
162
- :period_id => '1'
182
+ :detour => {:action => 'show_no_layout', :id => '2', :controller => 'periods'},
183
+ :period_id => '1'
163
184
  assert_equal 2, tasks(:another).period_id
164
185
  end
165
186
 
187
+ def test_move_to_period_back_to_earlier_period
188
+ task_to_move = tasks(:in_last_period)
189
+ target_task = tasks(:postponed)
190
+ target_period = periods(:active)
191
+
192
+ post :move_to_period, {"id"=> task_to_move.id,
193
+ "detour"=>{"action"=>"edit_no_layout", "id"=>"39", "controller"=>"backlogs"},
194
+ "period_id"=> target_period.id
195
+ }
196
+
197
+ old_task = Task.find(task_to_move.id)
198
+ assert_not_nil old_task.finished_at
199
+ assert_equal Task::POSTPONED, old_task.resolution
200
+ assert_nil old_task.position
201
+
202
+ new_task = Task.find(target_task.id)
203
+ new_task.reload
204
+ assert_nil new_task.finished_at
205
+ assert_nil new_task.resolution
206
+ assert_equal 1, new_task.position
207
+ end
208
+
166
209
  end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: backlog
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.7.1
7
- date: 2007-08-15 00:00:00 +02:00
6
+ version: 0.7.2
7
+ date: 2007-08-17 00:00:00 +02:00
8
8
  summary: Application to aid collecting, processing, organizing, reviewing and doing tasks.
9
9
  require_paths:
10
10
  - lib
@@ -227,7 +227,6 @@ files:
227
227
  - config/environments/datek_production.rb
228
228
  - LICENSE_LOCALIZATION
229
229
  - README.txt
230
- - doc
231
230
  - Manifest.txt
232
231
  - vendor
233
232
  - vendor/plugins
@@ -1750,12 +1749,12 @@ files:
1750
1749
  - app/views/works/weekly_work_sheet.rhtml
1751
1750
  - app/views/works/timeliste.rhtml
1752
1751
  - app/views/user_notify
1753
- - app/views/user_notify/forgot_password.rhtml
1754
- - app/views/user_notify/change_password.rhtml
1755
1752
  - app/views/user_notify/forgot_password_no.rhtml
1756
1753
  - app/views/user_notify/signup_no.rhtml
1757
1754
  - app/views/user_notify/change_password_no.rhtml
1758
- - app/views/user_notify/signup.rhtml
1755
+ - app/views/user_notify/change_password_en.rhtml
1756
+ - app/views/user_notify/forgot_password_en.rhtml
1757
+ - app/views/user_notify/signup_en.rhtml
1759
1758
  - app/views/periods
1760
1759
  - app/views/periods/show.rhtml
1761
1760
  - app/views/periods/_show_active.rhtml
@@ -1785,5 +1784,5 @@ dependencies:
1785
1784
  requirements:
1786
1785
  - - ">="
1787
1786
  - !ruby/object:Gem::Version
1788
- version: 1.2.2
1787
+ version: 1.3.0
1789
1788
  version: