Actually block issues from closing when a blocking issue isn't closed (#1740).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2800 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
85f634481e
commit
6994d1c23b
|
@ -203,11 +203,17 @@ class Issue < ActiveRecord::Base
|
||||||
project.assignable_users
|
project.assignable_users
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns true if this issue is blocked by another issue that is still open
|
||||||
|
def blocked?
|
||||||
|
!relations_to.detect {|ir| ir.relation_type == 'blocks' && !ir.issue_from.closed?}.nil?
|
||||||
|
end
|
||||||
|
|
||||||
# Returns an array of status that user is able to apply
|
# Returns an array of status that user is able to apply
|
||||||
def new_statuses_allowed_to(user)
|
def new_statuses_allowed_to(user)
|
||||||
statuses = status.find_new_statuses_allowed_to(user.roles_for_project(project), tracker)
|
statuses = status.find_new_statuses_allowed_to(user.roles_for_project(project), tracker)
|
||||||
statuses << status unless statuses.empty?
|
statuses << status unless statuses.empty?
|
||||||
statuses.uniq.sort
|
statuses = statuses.uniq.sort
|
||||||
|
blocked? ? statuses.reject {|s| s.is_closed?} : statuses
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the mail adresses of users that should be notified for the issue
|
# Returns the mail adresses of users that should be notified for the issue
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
issue_relation_001:
|
||||||
|
id: 1
|
||||||
|
issue_from_id: 10
|
||||||
|
issue_to_id: 9
|
||||||
|
relation_type: blocks
|
||||||
|
delay:
|
||||||
|
|
|
@ -125,4 +125,35 @@ issues_008:
|
||||||
start_date:
|
start_date:
|
||||||
due_date:
|
due_date:
|
||||||
lock_version: 0
|
lock_version: 0
|
||||||
|
issues_009:
|
||||||
|
created_on: <%= 1.minute.ago.to_date.to_s(:db) %>
|
||||||
|
project_id: 5
|
||||||
|
updated_on: <%= 1.minute.ago.to_date.to_s(:db) %>
|
||||||
|
priority_id: 5
|
||||||
|
subject: Blocked Issue
|
||||||
|
id: 9
|
||||||
|
fixed_version_id:
|
||||||
|
category_id:
|
||||||
|
description: This is an issue that is blocked by issue #10
|
||||||
|
tracker_id: 1
|
||||||
|
assigned_to_id:
|
||||||
|
author_id: 2
|
||||||
|
status_id: 1
|
||||||
|
start_date: <%= Date.today.to_s(:db) %>
|
||||||
|
due_date: <%= 1.days.from_now.to_date.to_s(:db) %>
|
||||||
|
issues_010:
|
||||||
|
created_on: <%= 1.minute.ago.to_date.to_s(:db) %>
|
||||||
|
project_id: 5
|
||||||
|
updated_on: <%= 1.minute.ago.to_date.to_s(:db) %>
|
||||||
|
priority_id: 5
|
||||||
|
subject: Issue Doing the Blocking
|
||||||
|
id: 10
|
||||||
|
fixed_version_id:
|
||||||
|
category_id:
|
||||||
|
description: This is an issue that blocks issue #9
|
||||||
|
tracker_id: 1
|
||||||
|
assigned_to_id:
|
||||||
|
author_id: 2
|
||||||
|
status_id: 1
|
||||||
|
start_date: <%= Date.today.to_s(:db) %>
|
||||||
|
due_date: <%= 1.days.from_now.to_date.to_s(:db) %>
|
||||||
|
|
|
@ -20,7 +20,7 @@ require File.dirname(__FILE__) + '/../test_helper'
|
||||||
class IssueTest < Test::Unit::TestCase
|
class IssueTest < Test::Unit::TestCase
|
||||||
fixtures :projects, :users, :members, :member_roles,
|
fixtures :projects, :users, :members, :member_roles,
|
||||||
:trackers, :projects_trackers,
|
:trackers, :projects_trackers,
|
||||||
:issue_statuses, :issue_categories,
|
:issue_statuses, :issue_categories, :issue_relations, :workflows,
|
||||||
:enumerations,
|
:enumerations,
|
||||||
:issues,
|
:issues,
|
||||||
:custom_fields, :custom_fields_projects, :custom_fields_trackers, :custom_values,
|
:custom_fields, :custom_fields_projects, :custom_fields_trackers, :custom_values,
|
||||||
|
@ -234,6 +234,32 @@ class IssueTest < Test::Unit::TestCase
|
||||||
assert_nil TimeEntry.find_by_issue_id(1)
|
assert_nil TimeEntry.find_by_issue_id(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_blocked
|
||||||
|
blocked_issue = Issue.find(9)
|
||||||
|
blocking_issue = Issue.find(10)
|
||||||
|
|
||||||
|
assert blocked_issue.blocked?
|
||||||
|
assert !blocking_issue.blocked?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_blocked_issues_dont_allow_closed_statuses
|
||||||
|
blocked_issue = Issue.find(9)
|
||||||
|
|
||||||
|
allowed_statuses = blocked_issue.new_statuses_allowed_to(users(:users_002))
|
||||||
|
assert !allowed_statuses.empty?
|
||||||
|
closed_statuses = allowed_statuses.select {|st| st.is_closed?}
|
||||||
|
assert closed_statuses.empty?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_unblocked_issues_allow_closed_statuses
|
||||||
|
blocking_issue = Issue.find(10)
|
||||||
|
|
||||||
|
allowed_statuses = blocking_issue.new_statuses_allowed_to(users(:users_002))
|
||||||
|
assert !allowed_statuses.empty?
|
||||||
|
closed_statuses = allowed_statuses.select {|st| st.is_closed?}
|
||||||
|
assert !closed_statuses.empty?
|
||||||
|
end
|
||||||
|
|
||||||
def test_overdue
|
def test_overdue
|
||||||
assert Issue.new(:due_date => 1.day.ago.to_date).overdue?
|
assert Issue.new(:due_date => 1.day.ago.to_date).overdue?
|
||||||
assert !Issue.new(:due_date => Date.today).overdue?
|
assert !Issue.new(:due_date => Date.today).overdue?
|
||||||
|
|
Loading…
Reference in New Issue