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