@@ -36,10 +36,8 class IssueMovesController < ApplicationController | |||
|
36 | 36 | moved_issues = [] |
|
37 | 37 | @issues.each do |issue| |
|
38 | 38 | issue.reload |
|
39 | issue.init_journal(User.current) | |
|
40 | issue.current_journal.notes = @notes if @notes.present? | |
|
41 | 39 | call_hook(:controller_issues_move_before_save, { :params => params, :issue => issue, :target_project => @target_project, :copy => !!@copy }) |
|
42 | if r = issue.move_to_project(@target_project, new_tracker, {:copy => @copy, :attributes => extract_changed_attributes_for_move(params)}) | |
|
40 | if r = issue.move_to_project(@target_project, new_tracker, {:copy => @copy, :attributes => extract_changed_attributes_for_move(params), :notes => @notes}) | |
|
43 | 41 | moved_issues << r |
|
44 | 42 | else |
|
45 | 43 | unsaved_issue_ids << issue.id |
@@ -152,7 +152,13 class Issue < ActiveRecord::Base | |||
|
152 | 152 | |
|
153 | 153 | def move_to_project_without_transaction(new_project, new_tracker = nil, options = {}) |
|
154 | 154 | options ||= {} |
|
155 | issue = options[:copy] ? self.class.new.copy_from(self) : self | |
|
155 | ||
|
156 | if options[:copy] | |
|
157 | issue = self.class.new.copy_from(self) | |
|
158 | else | |
|
159 | issue = self | |
|
160 | issue.init_journal(User.current, options[:notes]) | |
|
161 | end | |
|
156 | 162 | |
|
157 | 163 | if new_project && issue.project_id != new_project.id |
|
158 | 164 | # delete issue relations |
@@ -190,14 +196,12 class Issue < ActiveRecord::Base | |||
|
190 | 196 | if options[:attributes] |
|
191 | 197 | issue.attributes = options[:attributes] |
|
192 | 198 | end |
|
199 | if options[:copy] && options[:notes].present? | |
|
200 | issue.init_journal(User.current, options[:notes]) | |
|
201 | issue.current_journal.notify = false | |
|
202 | end | |
|
193 | 203 | if issue.save |
|
194 |
|
|
|
195 | if current_journal && current_journal.notes.present? | |
|
196 | issue.init_journal(current_journal.user, current_journal.notes) | |
|
197 | issue.current_journal.notify = false | |
|
198 | issue.save | |
|
199 | end | |
|
200 | else | |
|
204 | unless options[:copy] | |
|
201 | 205 | # Manually update project_id on related time entries |
|
202 | 206 | TimeEntry.update_all("project_id = #{new_project.id}", {:issue_id => id}) |
|
203 | 207 |
@@ -634,12 +634,10 class IssueTest < ActiveSupport::TestCase | |||
|
634 | 634 | assert_equal User.current, @copy.author |
|
635 | 635 | end |
|
636 | 636 | |
|
637 |
should " |
|
|
637 | should "create a journal with notes" do | |
|
638 | 638 | date = Date.today |
|
639 | 639 | notes = "Notes added when copying" |
|
640 | User.current = User.find(9) | |
|
641 | @issue.init_journal(User.current, notes) | |
|
642 | @copy = @issue.move_to_project(Project.find(3), Tracker.find(2), {:copy => true, :attributes => {:start_date => date}}) | |
|
640 | @copy = @issue.move_to_project(Project.find(3), Tracker.find(2), {:copy => true, :notes => notes, :attributes => {:start_date => date}}) | |
|
643 | 641 | |
|
644 | 642 | assert_equal 1, @copy.journals.size |
|
645 | 643 | journal = @copy.journals.first |
General Comments 0
You need to be logged in to leave comments.
Login now