Project

General

Profile

Feature #10989 » cant_close_before_sub_issues_closed_v3.patch

Marius BĂLTEANU, 2016-12-16 10:13

View differences:

app/models/issue.rb
validates :estimated_hours, :numericality => {:greater_than_or_equal_to => 0, :allow_nil => true, :message => :invalid}
validates :start_date, :date => true
validates :due_date, :date => true
validate :validate_issue, :validate_required_fields
validate :validate_issue, :validate_required_fields, :validate_subtasks
attr_protected :id
scope :visible, lambda {|*args|
......
end
end
# Validates the issue against open subtasks
def validate_subtasks
if closing? && descendants.open.any?
errors.add :base, I18n.t(:error_can_not_close_issue_with_open_subtasks)
end
end
# Set the done_ratio using the status if that setting is set. This will keep the done_ratios
# even if the user turns off the setting later
def update_done_ratio_from_issue_status
config/locales/en.yml
error_ldap_bind_credentials: "Invalid LDAP Account/Password"
error_no_tracker_allowed_for_new_issue_in_project: "The project doesn't have any trackers for which you can create an issue"
error_no_projects_with_tracker_allowed_for_new_issue: "There are no projects with trackers for which you can create an issue"
error_can_not_close_issue_with_open_subtasks: "You cannot close an issue with open subtasks"
mail_subject_lost_password: "Your %{value} password"
mail_body_lost_password: 'To change your password, click on the following link:'
test/unit/issue_subtasking_test.rb
parent.generate_child!(:estimated_hours => 7)
assert_equal 12, parent.reload.total_estimated_hours
end
def test_parent_with_open_subtasks_cannot_be_closed
parent = Issue.generate!
parent.generate_child!()
parent.reload
parent.status = IssueStatus.where(:is_closed => true).first
parent.save
assert_include 'You cannot close an issue with open subtasks', parent.errors.full_messages
end
def test_parent_with_closed_subtasks_can_be_closed
parent = Issue.generate!
parent.generate_child!(:status => IssueStatus.where(:is_closed => true).first)
parent.reload
closed_status = IssueStatus.where(:is_closed => true).first
parent.status = closed_status
assert_save parent
assert parent.status, closed_status
end
end
(3-3/3)