alphagov/whitehall — pull request #624 by heathd (2013-06-27 10:52:55+00:00)
Title: Bugfix: don't crash when redrafting policy

It's common for a policy to reference multiple editions of the same
document. For example, consider a news article N which references a
policy P. There would be an EditionRelation (N, P).

When that news article is re-drafted, a new EditionRelation is created
with (N', P).

Now suppose that we create a new policy P'. The policy trait (deleted by
this commit) would attempt to duplicate both (N, P) and (N', P). It does
this by assigning P'.related_editions = [N, N'].

In fact this is not necessary because the actual join is via the
document_id of P, which is unchanged for P'. In other words, as far as I
can tell, this trait has always been redundant, but for some reason has
not been causing any harm until now.

Something must have changed in the Rails 3.2 upgrade which has affected
the behaviour of the assignment or the validation check. I haven't been
able to pinpoint exactly what.

I added a failing test case to catch the existing failure mode. Removing
this trait allows that to pass.

https://www.pivotaltracker.com/story/show/52374563