Project

General

Profile

Feature #4403 » copy_to_another_project_and_relate.patch

Paul Preece, 2010-06-07 13:28

View differences:

test/functional/issues_controller_test.rb (working copy)
1126 1126
    issue = Issue.first(:order => 'id DESC')
1127 1127
    assert_redirected_to :controller => 'issues', :action => 'show', :id => issue
1128 1128
  end
1129

  
1130
  def test_copy_to_another_project_and_relate
1131
    @request.session[:user_id] = 2
1132
    Setting.cross_project_issue_relations = 1
1133
    post :move, :ids => [1], :new_project_id => 2, :copy_options => {:copy => '1'}, :follow => '1'
1134
    issue = Issue.first(:order => 'id DESC')
1135
    orig = Issue.last(:order => 'id DESC')
1136
    assert_equal issue.subject, orig.subject
1137
    assert_not_equal 0, issue.relations_from.size
1138
  end
1129 1139
  
1130 1140
  def test_context_menu_one_issue
1131 1141
    @request.session[:user_id] = 2
app/controllers/issues_controller.rb (working copy)
274 274
        call_hook(:controller_issues_move_before_save, { :params => params, :issue => issue, :target_project => @target_project, :copy => !!@copy })
275 275
        if r = issue.move_to_project(@target_project, new_tracker, {:copy => @copy, :attributes => changed_attributes})
276 276
          moved_issues << r
277
          if @copy && Setting.cross_project_issue_relations?
278
            relation = IssueRelation.new
279
            relation.issue_to = issue
280
            relation.issue_from = r
281
            relation.relation_type = "duplicates"
282
            relation.save
283
          end
277 284
        else
278 285
          unsaved_issue_ids << issue.id
279 286
        end
(3-3/5)