Index: test/unit/issue_test.rb =================================================================== --- test/unit/issue_test.rb (revision 1075) +++ test/unit/issue_test.rb (working copy) @@ -18,7 +18,7 @@ require File.dirname(__FILE__) + '/../test_helper' class IssueTest < Test::Unit::TestCase - fixtures :projects, :users, :members, :trackers, :projects_trackers, :issue_statuses, :issue_categories, :enumerations, :issues, :custom_fields, :custom_values, :time_entries + fixtures :projects, :users, :members, :trackers, :projects_trackers, :issue_statuses, :issue_categories, :enumerations, :issues, :custom_fields, :custom_values, :time_entries, :versions def test_category_based_assignment issue = Issue.create(:project_id => 1, :tracker_id => 1, :author_id => 3, :status_id => 1, :priority => Enumeration.get_values('IPRI').first, :subject => 'Assignment test', :description => 'Assignment test', :category_id => 1) @@ -70,4 +70,13 @@ # Make sure time entries were move to the target project assert_equal 2, issue.time_entries.first.project_id end + + def test_inherit_version_due_date_if_necessary + issue = Issue.find(1) + version = Version.find(1) + issue.fixed_version = version + issue.due_date = nil + assert issue.save + assert_equal issue.due_date, version.due_date + end end Index: app/models/issue.rb =================================================================== --- app/models/issue.rb (revision 1075) +++ app/models/issue.rb (working copy) @@ -137,6 +137,13 @@ } @current_journal.save end + + # If the issue has a fixed version and the issue's due date is empty + # then fill it in with the due date of the fixed version + if (version = self.fixed_version) && self.due_date.blank? + self.due_date = version.due_date + end + # Save the issue even if the journal is not saved (because empty) true end