Project

General

Profile

Patch #23764 ยป clear_closed_on.diff

patch - Go MAEDA, 2016-09-05 11:19

View differences:

app/models/issue.rb (working copy)
262 262
  # Copies attributes from another issue, arg can be an id or an Issue
263 263
  def copy_from(arg, options={})
264 264
    issue = arg.is_a?(Issue) ? arg : Issue.visible.find(arg)
265
    self.attributes = issue.attributes.dup.except("id", "root_id", "parent_id", "lft", "rgt", "created_on", "updated_on")
265
    self.attributes = issue.attributes.dup.except("id", "root_id", "parent_id", "lft", "rgt", "created_on", "updated_on", "closed_on")
266 266
    self.custom_field_values = issue.custom_field_values.inject({}) {|h,v| h[v.custom_field_id] = v.value; h}
267 267
    self.status = issue.status
268 268
    self.author = User.current
......
1402 1402
    end
1403 1403
    Project.where(condition).having_trackers
1404 1404
  end
1405
 
1405

  
1406 1406
  # Returns a scope of trackers that user can assign the issue to
1407 1407
  def allowed_target_trackers(user=User.current)
1408 1408
    self.class.allowed_target_trackers(project, user, tracker_id_was)
test/unit/issue_test.rb (working copy)
762 762
    user = User.find(2)
763 763
    group = Group.generate!
764 764
    group.users << user
765
 
765

  
766 766
    issue = Issue.generate!(:author_id => 1, :assigned_to => group)
767 767
    assert_include 4, issue.new_statuses_allowed_to(user).map(&:id)
768 768
  end
......
1335 1335
    end
1336 1336
  end
1337 1337

  
1338
  def test_copy_should_clear_closed_on
1339
    copied_open = Issue.find(8).copy(:status_id => 1)
1340
    assert copied_open.save
1341
    assert_nil copied_open.closed_on
1342

  
1343
    copied_closed = Issue.find(8).copy
1344
    assert copied_closed.save
1345
    assert_not_nil copied_closed.closed_on
1346
  end
1347

  
1338 1348
  def test_should_not_call_after_project_change_on_creation
1339 1349
    issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1,
1340 1350
                      :subject => 'Test', :author_id => 1)
    (1-1/1)