backlog 0.6.6 → 0.7.0
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 +11 -0
- data/app/controllers/application.rb +2 -1
- data/app/controllers/periods_controller.rb +1 -1
- data/app/controllers/tasks_controller.rb +11 -4
- data/app/helpers/application_helper.rb +2 -2
- data/app/models/backlog.rb +1 -0
- data/app/models/group.rb +0 -1
- data/app/models/task.rb +42 -19
- data/app/views/backlogs/_tasks.rhtml +11 -2
- data/app/views/backlogs/edit.rhtml +0 -9
- data/app/views/periods/_show_active.rhtml +1 -1
- data/app/views/tasks/_completed.rhtml +8 -0
- data/app/views/tasks/_fields_header.rhtml +1 -1
- data/app/views/tasks/_form.rhtml +2 -2
- data/app/views/tasks/_period_header.rhtml +1 -0
- data/app/views/tasks/_task.rhtml +3 -3
- data/db/migrate/019_remove_unique_index_for_period_position.rb +9 -0
- data/db/schema.rb +1 -3
- data/test/fixtures/periods.yml +6 -2
- data/test/fixtures/tasks.yml +14 -8
- data/test/functional/periods_controller_test.rb +6 -1
- data/test/functional/tasks_controller_test.rb +29 -7
- data/test/functional/works_controller_test.rb +31 -38
- data/test/test_helper.rb +24 -4
- metadata +4 -3
data/History.txt
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
== 0.7.0 2007-08-14
|
2
|
+
|
3
|
+
* Back in business after halting to avoid spamming people.
|
4
|
+
* Fixed work flow when moving task to other period using drag&drop in side bar
|
5
|
+
* Fixed bug in moving tasks to other periods
|
6
|
+
* Optimized slightly by omitting generating layout data for no_layout action
|
7
|
+
* Added more validation of "position" fields
|
8
|
+
* Added completed tasks to backlog edit view
|
9
|
+
* Removed unique index for periods(party_id, position) since it broke list updates in PostgreSQL
|
10
|
+
* Added better assertion of position sequences in tests
|
11
|
+
|
1
12
|
== 0.6.6 2007-08-07
|
2
13
|
|
3
14
|
* Improved task lists in backlog edit view.
|
@@ -4,6 +4,7 @@ require 'user_system'
|
|
4
4
|
class ApplicationController < ActionController::Base
|
5
5
|
include Localization
|
6
6
|
include UserSystem
|
7
|
+
include ApplicationHelper
|
7
8
|
include ActionView::Helpers::TagHelper
|
8
9
|
include ActionView::Helpers::JavaScriptHelper
|
9
10
|
include ActionView::Helpers::PrototypeHelper
|
@@ -138,7 +139,7 @@ class ApplicationController < ActionController::Base
|
|
138
139
|
content << "</ul>\n"
|
139
140
|
content << drop_receiving_element("sidebar_#{period.id}",
|
140
141
|
:update => "spotlight",
|
141
|
-
:url => {
|
142
|
+
:url => with_detour({:controller => 'tasks', :action => "move_to_period", :period_id => period.id, :layout => false}),
|
142
143
|
:accept => "tasks", :loading => "", :complete => "",
|
143
144
|
:hoverclass => 'highlight')
|
144
145
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class PeriodsController < ApplicationController
|
2
|
-
skip_before_filter :populate_layout, :only => [:index, :
|
2
|
+
skip_before_filter :populate_layout, :only => [:index, :show_no_layout, :destroy, :burn_down_chart_thumbnail, :burn_down_chart]
|
3
3
|
skip_before_filter :authenticate_user, :only => [:burn_down_chart, :burn_down_chart_thumbnail, :burn_down_chart_large]
|
4
4
|
|
5
5
|
def index
|
@@ -59,18 +59,24 @@ class TasksController < ApplicationController
|
|
59
59
|
back_or_redirect_to :controller => 'periods', :action => :show, :id => @task.period, :task => @task.id
|
60
60
|
return
|
61
61
|
end
|
62
|
+
|
63
|
+
# TODO (uwe): This should be moved to the Task model: Task#period=
|
62
64
|
if params[:task] && params[:task][:period_id]
|
63
65
|
if params[:task][:period_id] != ''
|
64
66
|
if params[:task][:period_id].to_i != @task.period_id
|
67
|
+
@task.remove_from_list
|
65
68
|
params[:task][:position] = Period.find(params[:task][:period_id]).tasks.size
|
66
69
|
end
|
67
70
|
else
|
68
71
|
if @task.period_id != nil
|
72
|
+
@task.remove_from_list
|
69
73
|
@task.period = nil
|
70
|
-
|
74
|
+
new_pos = @task.backlog.tasks.count(:conditions => 'period_id IS NULL') + 1
|
75
|
+
params[:task][:position] = new_pos
|
71
76
|
end
|
72
77
|
end
|
73
78
|
end
|
79
|
+
|
74
80
|
if params[:task] && @task.update_attributes(params[:task])
|
75
81
|
flash[:notice] = 'Task was successfully updated.'
|
76
82
|
if params[:task][:todo] && params[:task][:todo].to_i == 0
|
@@ -137,11 +143,11 @@ class TasksController < ApplicationController
|
|
137
143
|
end
|
138
144
|
task.insert_at params[:position]
|
139
145
|
task.save!
|
140
|
-
back_or_redirect_to :controller => 'periods', :action => :
|
146
|
+
back_or_redirect_to :controller => 'periods', :action => :show_no_layout, :id => task.period, :task => task.id
|
141
147
|
end
|
142
148
|
|
143
149
|
def move_to_period(with_layout = false)
|
144
|
-
task = Task.find(params[:id])
|
150
|
+
task = Task.find(params[:id][5..-1])
|
145
151
|
if request.post?
|
146
152
|
period = params[:period_id] && Period.find(params[:period_id])
|
147
153
|
if period && period.active_or_future?
|
@@ -150,7 +156,7 @@ class TasksController < ApplicationController
|
|
150
156
|
if with_layout
|
151
157
|
back_or_redirect_to :controller => 'periods', :action => :show, :id => next_task.period, :task_id => next_task.id
|
152
158
|
else
|
153
|
-
back_or_redirect_to :controller => 'periods', :action => :
|
159
|
+
back_or_redirect_to :controller => 'periods', :action => :show_no_layout, :id => next_task.period, :task_id => next_task.id
|
154
160
|
end
|
155
161
|
else
|
156
162
|
detour_to :controller => 'periods', :action => :new, :period => {:party_id => task.period.party_id}, :layout => with_layout && determine_layout
|
@@ -164,6 +170,7 @@ class TasksController < ApplicationController
|
|
164
170
|
task = Task.find(params[:id])
|
165
171
|
if task.period
|
166
172
|
params[:period_id] = task.period.lower_item && task.period.lower_item.id
|
173
|
+
params[:id] = 'task_' + task.id.to_s
|
167
174
|
move_to_period(true)
|
168
175
|
else
|
169
176
|
redirect_to :action => :edit, :id => task
|
@@ -11,10 +11,10 @@ module ApplicationHelper
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def detour_to(title, options, html_options = nil)
|
14
|
-
link_to title,
|
14
|
+
link_to title, with_detour(options), html_options
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
17
|
+
def with_detour(options)
|
18
18
|
detour_options = {:detour => params.reject {|k, v| [:detour, :return_from_detour].include? k.to_sym}}.update(options)
|
19
19
|
if options[:layout]== false
|
20
20
|
if params[:action] !~ /_no_layout$/
|
data/app/models/backlog.rb
CHANGED
@@ -10,6 +10,7 @@ class Backlog < ActiveRecord::Base
|
|
10
10
|
validates_length_of :invoice_code, :allow_nil => true, :maximum => 255
|
11
11
|
|
12
12
|
has_many :tasks, :order => 'period_id, position', :dependent => :destroy
|
13
|
+
has_many :unplanned_tasks, :class_name => 'Task', :conditions => 'period_id IS NULL', :order => 'position'
|
13
14
|
|
14
15
|
def active_tasks
|
15
16
|
tasks.find(:all, :conditions => "finished_at IS NULL", :order => "position")
|
data/app/models/group.rb
CHANGED
data/app/models/task.rb
CHANGED
@@ -16,11 +16,11 @@ class Task < ActiveRecord::Base
|
|
16
16
|
|
17
17
|
validates_presence_of :backlog_id, :if => Proc.new { |task| task.parent_id.nil? }
|
18
18
|
validates_presence_of :parent_id, :if => Proc.new { |task| task.backlog_id.nil? }
|
19
|
-
|
20
|
-
|
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? }
|
21
21
|
validates_presence_of :resolution, :if => :finished_at
|
22
22
|
validates_presence_of :description, :if => :backlog_id
|
23
|
-
|
23
|
+
|
24
24
|
validates_size_of :description, :maximum => 80, :if => :description
|
25
25
|
validates_size_of :customer, :maximum => 64, :if => :customer
|
26
26
|
|
@@ -121,7 +121,7 @@ class Task < ActiveRecord::Base
|
|
121
121
|
parent.open if parent
|
122
122
|
end
|
123
123
|
end
|
124
|
-
|
124
|
+
|
125
125
|
def reopen
|
126
126
|
if period.passed?
|
127
127
|
flash[:notice] = "You cannot reopen a task in a period that is passed."
|
@@ -132,23 +132,46 @@ class Task < ActiveRecord::Base
|
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
135
|
-
def move_to_period(
|
136
|
-
raise "Period missing" unless
|
135
|
+
def move_to_period(new_period)
|
136
|
+
raise "Period missing" unless new_period
|
137
137
|
raise "Cannot move finished tasks" unless active?
|
138
|
+
return if new_period == period
|
138
139
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
140
|
+
self.remove_from_list
|
141
|
+
self.position = nil
|
142
|
+
|
143
|
+
if self.period
|
144
|
+
self.finish(new_period.party == self.period.party ? Task::POSTPONED : Task::MOVED, true)
|
145
|
+
ancestor_id = self.previous_task_id || self.id
|
146
|
+
existing_task = Task.find_by_period_id_and_id(new_period.id, ancestor_id)
|
147
|
+
if existing_task ||= Task.find_by_period_id_and_previous_task_id(new_period.id, ancestor_id)
|
148
|
+
raise "mismatch" unless existing_task.backlog == root_task.backlog
|
149
|
+
raise "Mismatch" unless existing_task.period == new_period
|
150
|
+
existing_task.open
|
151
|
+
existing_task.previous_task_id = self.previous_task_id || self.id
|
152
|
+
existing_task.description = self.description
|
153
|
+
existing_task.save!
|
154
|
+
existing_task.estimate(self.todo)
|
155
|
+
existing_task.move_to_top
|
156
|
+
existing_task.save!
|
157
|
+
else
|
158
|
+
new_task = Task.new
|
159
|
+
new_task.previous_task_id = self.previous_task_id || self.id
|
160
|
+
new_task.backlog = root_task.backlog
|
161
|
+
new_task.period = new_period
|
162
|
+
new_task.description = self.description
|
163
|
+
new_task.insert_at 1
|
164
|
+
new_task.save!
|
165
|
+
new_task.estimate(self.todo)
|
166
|
+
end
|
167
|
+
else
|
168
|
+
self.period_id = new_period.id
|
169
|
+
self.period = new_period
|
170
|
+
self.insert_at(1)
|
171
|
+
self.position = 1
|
172
|
+
self.move_to_bottom
|
173
|
+
self.save!
|
174
|
+
end
|
152
175
|
end
|
153
176
|
|
154
177
|
def finish(resolution, save_work)
|
@@ -10,11 +10,20 @@
|
|
10
10
|
<% current_period = nil %>
|
11
11
|
<% for @task in tasks %>
|
12
12
|
<% if @task.period != current_period %>
|
13
|
-
|
14
|
-
<%= render :partial => '/tasks/fields_header', :locals => {:backlog => @backlog, :track_times => tasks.find {|t|t.period && t.period.active?}} %>
|
13
|
+
<%= render :partial => '/tasks/period_header', :locals => {:period => @task.period} %>
|
14
|
+
<%= render :partial => '/tasks/fields_header', :locals => {:backlog => @backlog, :active => true, :track_times => tasks.find {|t|t.period && t.period.active?}} %>
|
15
15
|
<% current_period = @task.period %>
|
16
16
|
<% end %>
|
17
17
|
<%= render :partial => '/tasks/task/', :locals => {:task => @task, :i => i += 1, :active => true, :highlight_task => false, :update => :maincontent} %>
|
18
18
|
<% end %>
|
19
19
|
</table>
|
20
20
|
</div>
|
21
|
+
|
22
|
+
<div class="mainblock">
|
23
|
+
<div class="btitle">
|
24
|
+
<h4><%=l(:completed_tasks) %></h4>
|
25
|
+
</div>
|
26
|
+
|
27
|
+
<%=render :partial => '/tasks/completed', :locals => {:i => 1} %>
|
28
|
+
</div>
|
29
|
+
|
@@ -10,14 +10,5 @@
|
|
10
10
|
|
11
11
|
<div id="maincontent">
|
12
12
|
<%=render :partial => 'tasks', :locals => {:tasks => @tasks}%>
|
13
|
-
|
14
|
-
<div class="mainblock">
|
15
|
-
<div class="btitle">
|
16
|
-
<h4><%=l(:completed_tasks) %></h4>
|
17
|
-
</div>
|
18
|
-
|
19
|
-
<%=render :partial => '/tasks/completed', :locals => {:i => 1} %>
|
20
|
-
</div>
|
21
|
-
|
22
13
|
</div>
|
23
14
|
|
@@ -38,7 +38,7 @@ function handleEvent(field, event, id) {
|
|
38
38
|
<% if task.backlog != current_backlog %>
|
39
39
|
<%= '<tr><td> </td></tr>' if current_backlog %>
|
40
40
|
<%=render :partial => '/tasks/backlog_header', :locals => { :backlog => task.backlog, :track_times => @tasks.find {|t|t.period && t.period.active?} } %>
|
41
|
-
<%= render :partial => '/tasks/fields_header', :locals => { :backlog => task.backlog, :track_times => @tasks.find {|t|t.period && t.period.active?} } %>
|
41
|
+
<%= render :partial => '/tasks/fields_header', :locals => { :backlog => task.backlog, :active => true, :track_times => @tasks.find {|t|t.period && t.period.active?} } %>
|
42
42
|
<% current_backlog = task.backlog %>
|
43
43
|
<% end %>
|
44
44
|
<%=render :partial => '/tasks/task', :locals => { :task => task, :i => i, :active => true, :highlight_task => task == @selected_task, :update => :spotlight } %>
|
@@ -1,4 +1,5 @@
|
|
1
1
|
<table class="input">
|
2
|
+
<!--
|
2
3
|
<tr>
|
3
4
|
<th/>
|
4
5
|
<th align="left"><%=l :resolution %></th>
|
@@ -6,7 +7,14 @@
|
|
6
7
|
<th></th>
|
7
8
|
<th><%=l(:done) if (@period && @period.track_work?) || @completed_tasks.find {|t| t.track_times?} %></th>
|
8
9
|
</tr>
|
10
|
+
-->
|
11
|
+
<% current_period = @completed_tasks.map(&:period).uniq.size == 1 ? @completed_tasks.first.period : nil%>
|
9
12
|
<% for task in @completed_tasks %>
|
13
|
+
<% if task.period != current_period %>
|
14
|
+
<%= render :partial => '/tasks/period_header', :locals => {:period => task.period} %>
|
15
|
+
<%= render :partial => '/tasks/fields_header', :locals => {:backlog => @backlog, :active => false, :track_times => false} %>
|
16
|
+
<% current_period = task.period %>
|
17
|
+
<% end %>
|
10
18
|
<%=render :partial => '/tasks/task', :locals => { :task => task, :i => i, :active => false, :highlight_task => task == @selected_task } %>
|
11
19
|
<% i += 1 %>
|
12
20
|
<% end %>
|
data/app/views/tasks/_form.rhtml
CHANGED
@@ -29,12 +29,12 @@
|
|
29
29
|
<p><label for="task_description"><%=l :task%></label><br/>
|
30
30
|
<%= text_field 'task', 'description', :size => 64, :maxlength => 80 %></p>
|
31
31
|
|
32
|
-
<% if @task.
|
32
|
+
<% if @task.enable_customer? %>
|
33
33
|
<p><label for="task_customer"><%=l :customer%></label><br/>
|
34
34
|
<%= text_field 'task', 'customer', :size => 64 %></p>
|
35
35
|
<% end %>
|
36
36
|
|
37
|
-
<% if @task.
|
37
|
+
<% if @task.track_todo? %>
|
38
38
|
<p><label for="task_initial_estimate"><%=l :estimate%></label><br/>
|
39
39
|
<%= text_field 'task', 'initial_estimate', :size => 4 %></p>
|
40
40
|
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<tr><th colspan="6"><%=link_to (period ? h(period.name) : l(:unplanned_tasks)), :controller => 'periods', :action => :show, :id => period%></th></tr>
|
data/app/views/tasks/_task.rhtml
CHANGED
@@ -85,10 +85,10 @@
|
|
85
85
|
</td>
|
86
86
|
</tr>
|
87
87
|
|
88
|
-
<% if active && (@task.period.nil? || @task.period.active_or_future?)
|
89
|
-
<%= draggable_element "task_#{@task.id}", :revert => true
|
88
|
+
<% if active && (@task.period.nil? || @task.period.active_or_future?) %>
|
89
|
+
<%= draggable_element "task_#{@task.id}", :revert => true %>
|
90
90
|
<%= drop_receiving_element "task_#{@task.id}",
|
91
|
-
:update => update, :url =>
|
91
|
+
:update => update, :url => with_detour({:controller => 'tasks', :action => "move_to", :period_id => @task.period_id, :position => @task.position, :layout => false}),
|
92
92
|
:accept => "tasks",
|
93
93
|
:loading => "",
|
94
94
|
:complete => "",
|
@@ -0,0 +1,9 @@
|
|
1
|
+
class RemoveUniqueIndexForPeriodPosition < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
remove_index "periods", ["party_id", "position"]
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.down
|
7
|
+
add_index "periods", ["position", "party_id"], :name => "index_periods_on_party_id_and_position", :unique => true
|
8
|
+
end
|
9
|
+
end
|
data/db/schema.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# migrations feature of ActiveRecord to incrementally modify your database, and
|
3
3
|
# then regenerate this schema definition.
|
4
4
|
|
5
|
-
ActiveRecord::Schema.define(:version =>
|
5
|
+
ActiveRecord::Schema.define(:version => 19) do
|
6
6
|
|
7
7
|
create_table "backlogs", :force => true do |t|
|
8
8
|
t.string "name", :limit => 64, :null => false
|
@@ -44,8 +44,6 @@ ActiveRecord::Schema.define(:version => 18) do
|
|
44
44
|
t.integer "party_id"
|
45
45
|
end
|
46
46
|
|
47
|
-
add_index "periods", ["position", "party_id"], :name => "index_periods_on_party_id_and_position", :unique => true
|
48
|
-
|
49
47
|
create_table "tasks", :force => true do |t|
|
50
48
|
t.integer "position"
|
51
49
|
t.string "description", :limit => 80, :null => false
|
data/test/fixtures/periods.yml
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
2
1
|
past:
|
3
2
|
id: 1
|
4
3
|
party_id: 1
|
@@ -11,4 +10,9 @@ active:
|
|
11
10
|
position: 2
|
12
11
|
start_on: 2007-06-25
|
13
12
|
end_on: 2907-07-08
|
14
|
-
|
13
|
+
future:
|
14
|
+
id: 3
|
15
|
+
party_id: 1
|
16
|
+
position: 3
|
17
|
+
start_on: 2907-07-09
|
18
|
+
end_on: 2907-07-22
|
data/test/fixtures/tasks.yml
CHANGED
@@ -5,26 +5,32 @@ first:
|
|
5
5
|
backlog_id: 1
|
6
6
|
period_id: 1
|
7
7
|
description: first task
|
8
|
-
position:
|
8
|
+
position: 1
|
9
9
|
another:
|
10
10
|
id: 2
|
11
11
|
created_at: 2007-06-12
|
12
12
|
backlog_id: 1
|
13
13
|
period_id: 2
|
14
14
|
description: second task
|
15
|
-
position:
|
15
|
+
position: 1
|
16
16
|
started:
|
17
17
|
id: 3
|
18
18
|
created_at: 2007-08-02 14:15:42
|
19
|
-
backlog_id:
|
19
|
+
backlog_id: 2
|
20
20
|
period_id: 2
|
21
21
|
description: third task
|
22
|
-
position:
|
23
|
-
|
22
|
+
position: 2
|
23
|
+
in_last_period:
|
24
24
|
id: 4
|
25
25
|
created_at: 2007-08-02 14:15:42
|
26
26
|
backlog_id: 1
|
27
|
-
period_id:
|
28
|
-
description: last
|
29
|
-
position:
|
27
|
+
period_id: 3
|
28
|
+
description: task in last period
|
29
|
+
position: 1
|
30
|
+
not_planned:
|
31
|
+
id: 5
|
32
|
+
created_at: 2007-08-02 14:15:42
|
33
|
+
backlog_id: 1
|
34
|
+
description: unplanned task
|
35
|
+
position: 1
|
30
36
|
|
@@ -12,6 +12,11 @@ class PeriodsControllerTest < Test::Unit::TestCase
|
|
12
12
|
@request = ActionController::TestRequest.new
|
13
13
|
@response = ActionController::TestResponse.new
|
14
14
|
@request.session[:user_id] = 1000001
|
15
|
+
assert_sequences
|
16
|
+
end
|
17
|
+
|
18
|
+
def teardown
|
19
|
+
assert_sequences
|
15
20
|
end
|
16
21
|
|
17
22
|
def test_index
|
@@ -45,7 +50,7 @@ class PeriodsControllerTest < Test::Unit::TestCase
|
|
45
50
|
post :create, :period => {:party_id => 1, :start_on => '2007-06-11', :end_on => '2007-06-24'}
|
46
51
|
|
47
52
|
assert_response :redirect
|
48
|
-
assert_redirected_to :action => :show, :id =>
|
53
|
+
assert_redirected_to :action => :show, :id => 3
|
49
54
|
|
50
55
|
assert_equal num_periods + 1, Period.count
|
51
56
|
end
|
@@ -54,7 +54,8 @@ class TasksControllerTest < Test::Unit::TestCase
|
|
54
54
|
def test_create
|
55
55
|
num_tasks = Task.count
|
56
56
|
|
57
|
-
post :create, :task => {:description => 'an important task', :backlog_id => '2',
|
57
|
+
post :create, :task => {:description => 'an important task', :backlog_id => '2',
|
58
|
+
:period_id => '2', :position => '4'}
|
58
59
|
|
59
60
|
task = assigns(:task)
|
60
61
|
assert_equal [], task.errors.full_messages
|
@@ -68,7 +69,8 @@ class TasksControllerTest < Test::Unit::TestCase
|
|
68
69
|
def test_create_without_period
|
69
70
|
num_tasks = Task.count
|
70
71
|
|
71
|
-
post :create, :task => {:description => 'an important task', :backlog_id => '2'
|
72
|
+
post :create, :task => {:description => 'an important task', :backlog_id => '2',
|
73
|
+
:position => '1'}
|
72
74
|
|
73
75
|
task = assigns(:task)
|
74
76
|
assert_equal [], task.errors.full_messages
|
@@ -127,18 +129,38 @@ class TasksControllerTest < Test::Unit::TestCase
|
|
127
129
|
end
|
128
130
|
|
129
131
|
def test_move_to_next_period_at_end
|
130
|
-
before = Task.find(
|
131
|
-
assert_equal
|
132
|
+
before = Task.find(tasks(:in_last_period).id)
|
133
|
+
assert_equal tasks(:in_last_period).period_id, before.period_id
|
132
134
|
|
133
|
-
post :move_to_next_period, :id =>
|
135
|
+
post :move_to_next_period, :id => tasks(:in_last_period).id
|
134
136
|
|
135
137
|
assert_response :redirect
|
136
138
|
assert_redirected_to :controller => 'periods',
|
137
139
|
:action => :new,
|
138
140
|
:period => {:party_id => 1}
|
139
141
|
|
140
|
-
|
141
|
-
assert_equal
|
142
|
+
before.reload
|
143
|
+
assert_equal tasks(:in_last_period).period_id, before.period_id
|
144
|
+
|
145
|
+
after = Task.find(tasks(:in_last_period).id)
|
146
|
+
assert_equal before.period_id, after.period_id
|
147
|
+
end
|
148
|
+
|
149
|
+
def test_move_to_period
|
150
|
+
highest = Task.find(:first, :order => 'id DESC')
|
151
|
+
post :move_to_period, :id => 'task_2',
|
152
|
+
:detour => {:action => 'show_no_layout', :id => '2', :controller => 'periods'},
|
153
|
+
:period_id => '3'
|
154
|
+
new_task = Task.find(:first, :order => 'id DESC')
|
155
|
+
assert new_task.id != highest.id
|
156
|
+
assert_equal 3, new_task.period_id
|
157
|
+
end
|
158
|
+
|
159
|
+
def test_move_to_period_past
|
160
|
+
post :move_to_period, :id => 'task_2',
|
161
|
+
:detour => {:action => 'show_no_layout', :id => '2', :controller => 'periods'},
|
162
|
+
:period_id => '1'
|
163
|
+
assert_equal 2, tasks(:another).period_id
|
142
164
|
end
|
143
165
|
|
144
166
|
end
|
@@ -5,113 +5,106 @@ require 'works_controller'
|
|
5
5
|
class WorksController; def rescue_action(e) raise e end; end
|
6
6
|
|
7
7
|
class WorksControllerTest < Test::Unit::TestCase
|
8
|
-
fixtures :users, :groups_users, :backlogs, :periods, :tasks, :works, :estimates
|
9
|
-
|
8
|
+
fixtures :parties, :users, :groups, :groups_users, :backlogs, :periods, :tasks, :works, :estimates
|
9
|
+
|
10
10
|
def setup
|
11
11
|
@controller = WorksController.new
|
12
12
|
@request = ActionController::TestRequest.new
|
13
13
|
@response = ActionController::TestResponse.new
|
14
14
|
@request.session[:user_id] = 1000001
|
15
|
+
assert_sequences
|
15
16
|
end
|
16
|
-
|
17
|
+
|
18
|
+
def teardown
|
19
|
+
assert_sequences
|
20
|
+
end
|
21
|
+
|
17
22
|
def test_index
|
18
23
|
get :index
|
19
24
|
assert_response :success
|
20
25
|
assert_template 'list'
|
21
26
|
end
|
22
|
-
|
27
|
+
|
23
28
|
def test_list
|
24
29
|
get :list
|
25
|
-
|
30
|
+
|
26
31
|
assert_response :success
|
27
32
|
assert_template 'list'
|
28
|
-
|
33
|
+
|
29
34
|
assert_not_nil assigns(:works)
|
30
35
|
end
|
31
|
-
|
36
|
+
|
32
37
|
def test_show
|
33
38
|
get :show, :id => 1
|
34
|
-
|
39
|
+
|
35
40
|
assert_response :success
|
36
41
|
assert_template 'show'
|
37
|
-
|
42
|
+
|
38
43
|
assert_not_nil assigns(:work)
|
39
44
|
assert assigns(:work).valid?
|
40
45
|
end
|
41
|
-
|
46
|
+
|
42
47
|
def test_new
|
43
48
|
get :new, :work => {:task_id => 1}
|
44
|
-
|
49
|
+
|
45
50
|
assert_response :success
|
46
51
|
assert_template 'new'
|
47
|
-
|
52
|
+
|
48
53
|
assert_not_nil assigns(:work)
|
49
54
|
end
|
50
|
-
|
55
|
+
|
51
56
|
def test_create
|
52
57
|
num_works = Work.count
|
53
|
-
|
58
|
+
|
54
59
|
post :create, :work => {:task_id => 1, :started_at => Time.now.iso8601}
|
55
|
-
|
60
|
+
|
56
61
|
assert_response :redirect
|
57
62
|
assert_redirected_to :controller => 'periods', :action => 'show', :id => 1, :task_id => 1
|
58
|
-
|
63
|
+
|
59
64
|
assert_equal num_works + 1, Work.count
|
60
65
|
end
|
61
|
-
|
66
|
+
|
62
67
|
def test_edit
|
63
68
|
get :edit, :id => 1
|
64
|
-
|
69
|
+
|
65
70
|
assert_response :success
|
66
71
|
assert_template 'edit'
|
67
|
-
|
72
|
+
|
68
73
|
assert_not_nil assigns(:work)
|
69
74
|
assert assigns(:work).valid?
|
70
75
|
end
|
71
|
-
|
76
|
+
|
72
77
|
def test_update
|
73
78
|
post :update, :id => 1
|
74
79
|
assert_response :redirect
|
75
80
|
assert_redirected_to :action => 'show', :id => 1
|
76
81
|
end
|
77
|
-
|
82
|
+
|
78
83
|
def test_destroy
|
79
84
|
assert_not_nil Work.find(1)
|
80
|
-
|
85
|
+
|
81
86
|
post :destroy, :id => 1
|
82
87
|
assert_response :redirect
|
83
88
|
assert_redirected_to :controller => 'periods', :action => 'list_work'
|
84
|
-
|
89
|
+
|
85
90
|
assert_raise(ActiveRecord::RecordNotFound) {
|
86
91
|
Work.find(1)
|
87
92
|
}
|
88
93
|
end
|
89
|
-
|
94
|
+
|
90
95
|
def test_update_with_finish
|
91
96
|
num_tasks = Task.count
|
92
97
|
num_open_tasks = Task.find_open.size
|
93
98
|
task = tasks(:started)
|
94
99
|
work = works(:started)
|
95
|
-
|
100
|
+
|
96
101
|
post :update, "commit"=>"Lagre", "action"=>"update", "id"=>work.id.to_s, "controller"=>"works", "estimate"=>{"todo"=>"0"}, "work"=>{"completed_at"=>"2007-08-02 14:15", "task_id"=> task.id.to_s, "user_id"=>"1000001", "started_at"=>"2007-08-02 14:00"}
|
97
102
|
|
98
103
|
assert_response :redirect
|
99
104
|
assert_redirected_to :controller => 'periods', :action => :show, :id => task.period, :task => nil
|
100
|
-
|
105
|
+
|
101
106
|
assert_equal num_tasks, Task.count
|
102
107
|
assert_equal num_open_tasks - 1, Task.find_open.size
|
103
|
-
assert_sequence
|
104
|
-
end
|
105
|
-
|
106
|
-
|
107
|
-
private
|
108
|
-
|
109
|
-
def assert_sequence
|
110
|
-
Period.find(:all).each do |p|
|
111
|
-
p.open_tasks.each_with_index do |t, i|
|
112
|
-
assert_equal i, t.position
|
113
|
-
end
|
114
|
-
end
|
115
108
|
end
|
116
109
|
|
117
110
|
end
|
data/test/test_helper.rb
CHANGED
@@ -17,18 +17,38 @@ class Test::Unit::TestCase
|
|
17
17
|
# don't care one way or the other, switching from MyISAM to InnoDB tables
|
18
18
|
# is recommended.
|
19
19
|
self.use_transactional_fixtures = true
|
20
|
-
|
20
|
+
|
21
21
|
# Instantiated fixtures are slow, but give you @david where otherwise you
|
22
22
|
# would need people(:david). If you don't want to migrate your existing
|
23
23
|
# test cases which use the @david style and don't mind the speed hit (each
|
24
24
|
# instantiated fixtures translates to a database query per test method),
|
25
25
|
# then set this back to true.
|
26
26
|
self.use_instantiated_fixtures = false
|
27
|
-
|
27
|
+
|
28
28
|
# Add more helper methods to be used by all tests here...
|
29
|
-
|
29
|
+
|
30
30
|
def add_stored_detour
|
31
31
|
@request.session[:detours] = [{:controller => 'bogus', :action => :location}]
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
|
+
def assert_sequences
|
35
|
+
Backlog.find(:all).each do |b|
|
36
|
+
b.unplanned_tasks.each_with_index do |t, i|
|
37
|
+
assert_equal i+1, t.position
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
Party.find(:all).each do |p|
|
42
|
+
p.periods.each_with_index do |period, i|
|
43
|
+
assert_equal i+1, period.position
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
Period.find(:all).each do |p|
|
48
|
+
p.open_tasks.each_with_index do |t, i|
|
49
|
+
assert_equal i+1, t.position
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
34
54
|
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
|
-
date: 2007-08-
|
6
|
+
version: 0.7.0
|
7
|
+
date: 2007-08-14 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
|
@@ -114,6 +114,7 @@ files:
|
|
114
114
|
- db/migrate
|
115
115
|
- db/migrate/008_add_backlog_options.rb
|
116
116
|
- db/migrate/014_add_customer_option.rb
|
117
|
+
- db/migrate/019_remove_unique_index_for_period_position.rb
|
117
118
|
- db/migrate/011_login_sugar.rb
|
118
119
|
- db/migrate/010_add_work_start.rb
|
119
120
|
- db/migrate/017_insert_datek_projects.rb
|
@@ -226,7 +227,6 @@ files:
|
|
226
227
|
- config/environments/datek_production.rb
|
227
228
|
- LICENSE_LOCALIZATION
|
228
229
|
- README.txt
|
229
|
-
- doc
|
230
230
|
- Manifest.txt
|
231
231
|
- vendor
|
232
232
|
- vendor/plugins
|
@@ -1730,6 +1730,7 @@ files:
|
|
1730
1730
|
- app/views/tasks/_backlog_header.rhtml
|
1731
1731
|
- app/views/tasks/list.rhtml
|
1732
1732
|
- app/views/tasks/_form.rhtml
|
1733
|
+
- app/views/tasks/_period_header.rhtml
|
1733
1734
|
- app/views/tasks/new.rhtml
|
1734
1735
|
- app/views/tasks/_fields_header.rhtml
|
1735
1736
|
- app/views/tasks/_completed.rhtml
|