Skip to content

Commit

Permalink
Track date changes from a Version/Deliverable with a Journal.
Browse files Browse the repository at this point in the history
  • Loading branch information
edavis10 committed Sep 25, 2009
1 parent 460a495 commit 16abc4e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/deliverable_due_patch.rb
Expand Up @@ -27,6 +27,7 @@ module InstanceMethods
def update_issue_due_dates
self.issues.each do |issue|
if issue.due_date.blank? || issue.due_date_set_by_deliverable?
issue.init_journal(User.current)
issue.due_date = self.due
issue.save
end
Expand Down
1 change: 1 addition & 0 deletions lib/version_due_date_patch.rb
Expand Up @@ -17,6 +17,7 @@ module InstanceMethods
def update_issue_due_dates
self.fixed_issues.each do |issue|
if issue.due_date.blank? || issue.due_date_set_by_version?
issue.init_journal(User.current)
issue.due_date = self.due_date
issue.save
end
Expand Down
6 changes: 6 additions & 0 deletions spec/lib/version_due_date_patch_spec.rb
Expand Up @@ -16,38 +16,44 @@
:version => @version,
:due_date_set_by_version? => true,
:due_date= => true,
:init_journal => true,
:save => true)

@issue_with_other_due_date = mock_model(Issue,
:due_date => 3.days.since,
:version => @version,
:due_date_set_by_version? => false,
:due_date= => true,
:init_journal => true,
:save => true)

@issue_without_due_date = mock_model(Issue,
:due_date => nil,
:version => @version,
:due_date_set_by_version? => false,
:due_date= => true,
:init_journal => true,
:save => true)

@version.stub!(:fixed_issues).and_return([@issue_with_due_date_matching, @issue_with_other_due_date, @issue_without_due_date])
end

it 'should update all issues without a due date to the Version due_date' do
@issue_without_due_date.should_receive(:init_journal)
@issue_without_due_date.should_receive(:due_date=).with(@version.due_date)
@issue_without_due_date.should_receive(:save).and_return(true)
@version.update_issue_due_dates
end

it "should update all issues with due_dates matching the old version to the new due_date" do
@issue_with_due_date_matching.should_receive(:init_journal)
@issue_with_due_date_matching.should_receive(:due_date=).with(@version.due_date)
@issue_with_due_date_matching.should_receive(:save).and_return(true)
@version.update_issue_due_dates
end

it "should not update issues with due_dates different than the new or old version's due date" do
@issue_with_other_due_date.should_not_receive(:init_journal)
@issue_with_other_due_date.should_not_receive(:save)
@version.update_issue_due_dates
end
Expand Down

0 comments on commit 16abc4e

Please sign in to comment.