summaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2016-12-21 09:09:22 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2016-12-21 09:09:22 +0000
commitf3627e2a3d1a9fa606fc71f66776d4b879b92323 (patch)
tree4a417801393a9e68a7cccef954317a839227254b /test/unit
parent3d1f72bc509e2fc8fc55e0ece3c3e230910d07c4 (diff)
downloadredmine-f3627e2a3d1a9fa606fc71f66776d4b879b92323.tar.gz
redmine-f3627e2a3d1a9fa606fc71f66776d4b879b92323.zip
Prevent parent issue from being closed if a child issue is open (#10989).
git-svn-id: http://svn.redmine.org/redmine/trunk@16108 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/issue_subtasking_test.rb9
-rw-r--r--test/unit/issue_test.rb18
2 files changed, 27 insertions, 0 deletions
diff --git a/test/unit/issue_subtasking_test.rb b/test/unit/issue_subtasking_test.rb
index e878601b1..2ddfb49c6 100644
--- a/test/unit/issue_subtasking_test.rb
+++ b/test/unit/issue_subtasking_test.rb
@@ -330,4 +330,13 @@ class IssueSubtaskingTest < ActiveSupport::TestCase
parent.generate_child!(:estimated_hours => 7)
assert_equal 12, parent.reload.total_estimated_hours
end
+
+ def test_open_issue_with_closed_parent_should_not_validate
+ parent = Issue.generate!(:status_id => 5)
+ child = Issue.generate!
+
+ child.parent_issue_id = parent.id
+ assert !child.save
+ assert_include I18n.t("activerecord.errors.messages.open_issue_with_closed_parent"), child.errors.full_messages
+ end
end
diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb
index 844ed5934..235e2e7f7 100644
--- a/test/unit/issue_test.rb
+++ b/test/unit/issue_test.rb
@@ -1941,6 +1941,24 @@ class IssueTest < ActiveSupport::TestCase
assert !closed_statuses.empty?
end
+ def test_parent_issues_with_open_subtask_dont_allow_closed_statuses
+ parent = Issue.generate!
+ child = Issue.generate!(:parent_issue_id => parent.id)
+
+ allowed_statuses = parent.reload.new_statuses_allowed_to(users(:users_002))
+ assert allowed_statuses.any?
+ assert_equal [], allowed_statuses.select(&:is_closed?)
+ end
+
+ def test_parent_issues_with_closed_subtask_allow_closed_statuses
+ parent = Issue.generate!
+ child = Issue.generate!(:parent_issue_id => parent.id, :status_id => 5)
+
+ allowed_statuses = parent.reload.new_statuses_allowed_to(users(:users_002))
+ assert allowed_statuses.any?
+ assert allowed_statuses.select(&:is_closed?).any?
+ end
+
def test_reschedule_an_issue_without_dates
with_settings :non_working_week_days => [] do
issue = Issue.new(:start_date => nil, :due_date => nil)