Patch #1676 ยป only_show_incomplete_target_versions.patch
app/models/issue.rb (working copy) | ||
---|---|---|
254 | 254 |
def to_s |
255 | 255 |
"#{tracker} ##{id}: #{subject}" |
256 | 256 |
end |
257 | ||
258 |
def active_versions |
|
259 |
project.active_versions(:for => self) |
|
260 |
end |
|
261 | ||
257 | 262 |
end |
app/models/project.rb (working copy) | ||
---|---|---|
239 | 239 |
end |
240 | 240 |
end |
241 | 241 | |
242 |
def active_versions(options = {}) |
|
243 |
issue = options[:for] if options[:for].is_a?(Issue) |
|
244 |
versions.select do |v| |
|
245 |
!v.completed? || issue && issue.fixed_version && |
|
246 |
v.id == issue.fixed_version.id |
|
247 |
end |
|
248 |
end |
|
249 |
|
|
242 | 250 |
protected |
243 | 251 |
def validate |
244 | 252 |
errors.add(parent_id, " must be a root project") if parent and parent.parent |
app/views/issues/_form.rhtml (working copy) | ||
---|---|---|
30 | 30 |
{:controller => 'projects', :action => 'add_issue_category', :id => @project}, |
31 | 31 |
:class => 'small', :tabindex => 199) if authorize_for('projects', 'add_issue_category') %></p> |
32 | 32 |
<%= content_tag('p', f.select(:fixed_version_id, |
33 |
(@project.versions.sort.collect {|v| [v.name, v.id]}),
|
|
33 |
(@issue.active_versions.sort.collect {|v| [v.name, v.id]}),
|
|
34 | 34 |
{ :include_blank => true })) unless @project.versions.empty? %> |
35 | 35 |
</div> |
36 | 36 |
app/views/issues/_form_update.rhtml (working copy) | ||
---|---|---|
5 | 5 |
<div class="splitcontentright"> |
6 | 6 |
<p><%= f.select :done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }) %></p> |
7 | 7 |
<%= content_tag('p', f.select(:fixed_version_id, |
8 |
(@project.versions.sort.collect {|v| [v.name, v.id]}),
|
|
8 |
(@issue.active_versions.sort.collect {|v| [v.name, v.id]}),
|
|
9 | 9 |
{ :include_blank => true })) unless @project.versions.empty? %> |
10 | 10 |
</div> |
app/views/issues/bulk_edit.rhtml (working copy) | ||
---|---|---|
27 | 27 |
<label><%= l(:field_fixed_version) %>: |
28 | 28 |
<%= select_tag('fixed_version_id', content_tag('option', l(:label_no_change_option), :value => '') + |
29 | 29 |
content_tag('option', l(:label_none), :value => 'none') + |
30 |
options_from_collection_for_select(@project.versions, :id, :name)) %></label> |
|
30 |
options_from_collection_for_select(@project.active_versions, :id, :name)) %></label>
|
|
31 | 31 |
</p> |
32 | 32 | |
33 | 33 |
<p> |
app/views/issues/context_menu.rhtml (working copy) | ||
---|---|---|
20 | 20 |
<% end -%> |
21 | 21 |
</ul> |
22 | 22 |
</li> |
23 |
<% unless @project.versions.empty? -%>
|
|
23 |
<% unless @issue.active_versions.empty? -%>
|
|
24 | 24 |
<li class="folder"> |
25 | 25 |
<a href="#" class="submenu"><%= l(:field_fixed_version) %></a> |
26 | 26 |
<ul> |
27 |
<% @project.versions.sort.each do |v| -%>
|
|
27 |
<% @issue.active_versions.sort.each do |v| -%>
|
|
28 | 28 |
<li><%= context_menu_link v.name, {:controller => 'issues', :action => 'edit', :id => @issue, 'issue[fixed_version_id]' => v, :back_to => @back}, :method => :post, |
29 | 29 |
:selected => (v == @issue.fixed_version), :disabled => !@can[:update] %></li> |
30 | 30 |
<% end -%> |
test/fixtures/issues.yml (working copy) | ||
---|---|---|
91 | 91 |
status_id: 1 |
92 | 92 |
start_date: <%= Date.today.to_s(:db) %> |
93 | 93 |
due_date: <%= 1.days.from_now.to_date.to_s(:db) %> |
94 |
|
|
94 |
issues_007: |
|
95 |
created_on: 2006-07-19 21:04:21 +02:00 |
|
96 |
project_id: 1 |
|
97 |
updated_on: 2006-07-19 21:09:50 +02:00 |
|
98 |
priority_id: 5 |
|
99 |
subject: Some closed issue |
|
100 |
id: 7 |
|
101 |
fixed_version_id: 1 |
|
102 |
category_id: |
|
103 |
description: Some closed issue |
|
104 |
tracker_id: 2 |
|
105 |
assigned_to_id: 3 |
|
106 |
author_id: 2 |
|
107 |
status_id: 5 |
|
108 |
start_date: <%= 2.day.ago.to_date.to_s(:db) %> |
|
109 |
due_date: |
test/unit/issue_test.rb (working copy) | ||
---|---|---|
181 | 181 |
assert_nil Issue.find_by_id(1) |
182 | 182 |
assert_nil TimeEntry.find_by_issue_id(1) |
183 | 183 |
end |
184 | ||
185 |
def test_active_versions_have_current_even_if_completed |
|
186 |
issue = issues(:issues_007) |
|
187 |
assert issue.fixed_version.completed? |
|
188 |
assert issue.active_versions.include?(issue.fixed_version), |
|
189 |
'Even if version is completed it should be considered active for issue assigned to it' |
|
190 |
end |
|
191 | ||
192 |
def test_active_versions_work_for_new_issue |
|
193 |
issue = Issue.new(:project_id => projects(:projects_001).id) |
|
194 |
assert !issue.active_versions.empty?, 'there should be active versions for new issue' |
|
195 |
end |
|
184 | 196 |
end |
test/unit/project_test.rb (working copy) | ||
---|---|---|
18 | 18 |
require File.dirname(__FILE__) + '/../test_helper' |
19 | 19 |
|
20 | 20 |
class ProjectTest < Test::Unit::TestCase |
21 |
fixtures :projects, :issues, :issue_statuses, :journals, :journal_details, :users, :members, :roles, :projects_trackers, :trackers, :boards
|
|
21 |
fixtures :all
|
|
22 | 22 |
|
23 | 23 |
def setup |
24 | 24 |
@ecookbook = Project.find(1) |
... | ... | |
130 | 130 |
assert_equal [1, 2, 3], parent.rolled_up_trackers.collect(&:id) |
131 | 131 |
assert_equal [2, 3], child.rolled_up_trackers.collect(&:id) |
132 | 132 |
end |
133 |
|
|
134 |
def test_active_versions_have_future_versions |
|
135 |
version = versions(:versions_003) |
|
136 |
assert !version.completed? |
|
137 |
assert projects(:projects_001).active_versions.include?(version), |
|
138 |
'Future version (or one without effective date) should be included' |
|
139 |
end |
|
140 |
|
|
141 |
def test_active_versions_have_incomplete_versions |
|
142 |
version = versions(:versions_002) |
|
143 |
assert !version.completed? |
|
144 |
assert projects(:projects_001).active_versions.include?(version), |
|
145 |
'Incomplete versions should be included' |
|
146 |
end |
|
147 |
|
|
148 |
def test_active_versions_dont_have_completed |
|
149 |
version = versions(:versions_001) |
|
150 |
assert version.completed? |
|
151 |
assert !projects(:projects_001).active_versions.include?(version), |
|
152 |
'Completed versions shouldn\'t be included' |
|
153 |
end |
|
133 | 154 |
end |