| 3489 | 3489 |     end | 
  | 3490 | 3490 |   end | 
  | 3491 | 3491 |  | 
  |  | 3492 |   def test_change_of_project_parent_should_update_shared_versions_with_derived_priorities | 
  |  | 3493 |     with_settings('parent_issue_priority' => 'derived') do | 
  |  | 3494 |       parent = Project.find 1 | 
  |  | 3495 |       child = Project.find 3 | 
  |  | 3496 |       assert_equal parent, child.parent | 
  |  | 3497 |       assert version = parent.versions.create(name: 'test', sharing: 'descendants') | 
  |  | 3498 |       assert version.persisted? | 
  |  | 3499 |       assert child.shared_versions.include?(version) | 
  |  | 3500 |  | 
  |  | 3501 |       # create a situation where the child issue id is lower than the parent issue id. | 
  |  | 3502 |       # When the parent project is removed, the version inherited from there will be removed from | 
  |  | 3503 |       # both issues. At least on MySQL the record with the lower Id will be processed first. | 
  |  | 3504 |       # | 
  |  | 3505 |       # If this update on the child triggers an update on the parent record (here, due to the derived | 
  |  | 3506 |       # priority), the already loaded parent issue is considered stale when it's version is updated. | 
  |  | 3507 |       assert child_issue = child.issues.first | 
  |  | 3508 |       parent_issue = Issue.create! project: child, subject: 'test', tracker: child_issue.tracker, author: child_issue.author, status: child_issue.status, fixed_version: version | 
  |  | 3509 |       assert child_issue.update fixed_version: version, priority_id: 6, parent: parent_issue | 
  |  | 3510 |       parent_issue.update_column :priority_id, 4 # force a priority update when the version is nullified | 
  |  | 3511 |  | 
  |  | 3512 |       assert child.update parent: nil | 
  |  | 3513 |  | 
  |  | 3514 |       child.reload | 
  |  | 3515 |       assert !child.shared_versions.include?(version) | 
  |  | 3516 |  | 
  |  | 3517 |       child_issue.reload | 
  |  | 3518 |       assert_nil child_issue.fixed_version | 
  |  | 3519 |       assert_equal 6, child_issue.priority_id | 
  |  | 3520 |  | 
  |  | 3521 |       parent_issue.reload | 
  |  | 3522 |       assert_nil parent_issue.fixed_version | 
  |  | 3523 |       assert_equal 6, parent_issue.priority_id | 
  |  | 3524 |     end | 
  |  | 3525 |   end | 
  |  | 3526 |  | 
  | 3492 | 3527 |   def test_create_should_not_add_anonymous_as_watcher | 
  | 3493 | 3528 |     Role.anonymous.add_permission!(:add_issue_watchers) | 
  | 3494 | 3529 |  |