Do not allow requirement proxy object to have different project_id from its work item

It is possible to have a Requirement object with a different project_id from the work item that it belongs to. The following spec fails:

  it 'creates a requirement from different project' do
    work_item = create(:work_item, :requirement)
    work_item.requirement.update(project: create(:project))

    expect(work_item.project).to eq(work_item.reload.requirement.project)
  end

There is no indication that this scenario is happening in production, but it would be nice to have a model validation to prevent this.

The following discussion from !98313 (merged) should be addressed:

  • @cablett started a discussion: (+6 comments)

    @felipe_artur do you reckon it's worth adding a test to check if the synnced requirement has been updated as well? I would think they both share the associated test report collection so I think it'll be ok - but wanted to get your read on that 👍