@@ -0,0 +1,7 | |||
|
1 | issue_relation_001: | |
|
2 | id: 1 | |
|
3 | issue_from_id: 10 | |
|
4 | issue_to_id: 9 | |
|
5 | relation_type: blocks | |
|
6 | delay: | |
|
7 |
@@ -203,11 +203,17 class Issue < ActiveRecord::Base | |||
|
203 | 203 | project.assignable_users |
|
204 | 204 | end |
|
205 | 205 | |
|
206 | # Returns true if this issue is blocked by another issue that is still open | |
|
207 | def blocked? | |
|
208 | !relations_to.detect {|ir| ir.relation_type == 'blocks' && !ir.issue_from.closed?}.nil? | |
|
209 | end | |
|
210 | ||
|
206 | 211 | # Returns an array of status that user is able to apply |
|
207 | 212 | def new_statuses_allowed_to(user) |
|
208 | 213 | statuses = status.find_new_statuses_allowed_to(user.roles_for_project(project), tracker) |
|
209 | 214 | statuses << status unless statuses.empty? |
|
210 | statuses.uniq.sort | |
|
215 | statuses = statuses.uniq.sort | |
|
216 | blocked? ? statuses.reject {|s| s.is_closed?} : statuses | |
|
211 | 217 | end |
|
212 | 218 | |
|
213 | 219 | # Returns the mail adresses of users that should be notified for the issue |
@@ -125,4 +125,35 issues_008: | |||
|
125 | 125 | start_date: |
|
126 | 126 | due_date: |
|
127 | 127 | lock_version: 0 |
|
128 | ||
|
128 | issues_009: | |
|
129 | created_on: <%= 1.minute.ago.to_date.to_s(:db) %> | |
|
130 | project_id: 5 | |
|
131 | updated_on: <%= 1.minute.ago.to_date.to_s(:db) %> | |
|
132 | priority_id: 5 | |
|
133 | subject: Blocked Issue | |
|
134 | id: 9 | |
|
135 | fixed_version_id: | |
|
136 | category_id: | |
|
137 | description: This is an issue that is blocked by issue #10 | |
|
138 | tracker_id: 1 | |
|
139 | assigned_to_id: | |
|
140 | author_id: 2 | |
|
141 | status_id: 1 | |
|
142 | start_date: <%= Date.today.to_s(:db) %> | |
|
143 | due_date: <%= 1.days.from_now.to_date.to_s(:db) %> | |
|
144 | issues_010: | |
|
145 | created_on: <%= 1.minute.ago.to_date.to_s(:db) %> | |
|
146 | project_id: 5 | |
|
147 | updated_on: <%= 1.minute.ago.to_date.to_s(:db) %> | |
|
148 | priority_id: 5 | |
|
149 | subject: Issue Doing the Blocking | |
|
150 | id: 10 | |
|
151 | fixed_version_id: | |
|
152 | category_id: | |
|
153 | description: This is an issue that blocks issue #9 | |
|
154 | tracker_id: 1 | |
|
155 | assigned_to_id: | |
|
156 | author_id: 2 | |
|
157 | status_id: 1 | |
|
158 | start_date: <%= Date.today.to_s(:db) %> | |
|
159 | due_date: <%= 1.days.from_now.to_date.to_s(:db) %> |
@@ -20,7 +20,7 require File.dirname(__FILE__) + '/../test_helper' | |||
|
20 | 20 | class IssueTest < Test::Unit::TestCase |
|
21 | 21 | fixtures :projects, :users, :members, :member_roles, |
|
22 | 22 | :trackers, :projects_trackers, |
|
23 | :issue_statuses, :issue_categories, | |
|
23 | :issue_statuses, :issue_categories, :issue_relations, :workflows, | |
|
24 | 24 | :enumerations, |
|
25 | 25 | :issues, |
|
26 | 26 | :custom_fields, :custom_fields_projects, :custom_fields_trackers, :custom_values, |
@@ -234,6 +234,32 class IssueTest < Test::Unit::TestCase | |||
|
234 | 234 | assert_nil TimeEntry.find_by_issue_id(1) |
|
235 | 235 | end |
|
236 | 236 | |
|
237 | def test_blocked | |
|
238 | blocked_issue = Issue.find(9) | |
|
239 | blocking_issue = Issue.find(10) | |
|
240 | ||
|
241 | assert blocked_issue.blocked? | |
|
242 | assert !blocking_issue.blocked? | |
|
243 | end | |
|
244 | ||
|
245 | def test_blocked_issues_dont_allow_closed_statuses | |
|
246 | blocked_issue = Issue.find(9) | |
|
247 | ||
|
248 | allowed_statuses = blocked_issue.new_statuses_allowed_to(users(:users_002)) | |
|
249 | assert !allowed_statuses.empty? | |
|
250 | closed_statuses = allowed_statuses.select {|st| st.is_closed?} | |
|
251 | assert closed_statuses.empty? | |
|
252 | end | |
|
253 | ||
|
254 | def test_unblocked_issues_allow_closed_statuses | |
|
255 | blocking_issue = Issue.find(10) | |
|
256 | ||
|
257 | allowed_statuses = blocking_issue.new_statuses_allowed_to(users(:users_002)) | |
|
258 | assert !allowed_statuses.empty? | |
|
259 | closed_statuses = allowed_statuses.select {|st| st.is_closed?} | |
|
260 | assert !closed_statuses.empty? | |
|
261 | end | |
|
262 | ||
|
237 | 263 | def test_overdue |
|
238 | 264 | assert Issue.new(:due_date => 1.day.ago.to_date).overdue? |
|
239 | 265 | assert !Issue.new(:due_date => Date.today).overdue? |
General Comments 0
You need to be logged in to leave comments.
Login now