Skip to content

Commit

Permalink
fix: follow replaces when building list for diff control (#8234)
Browse files Browse the repository at this point in the history
  • Loading branch information
rjsparks authored Nov 19, 2024
1 parent fd816c4 commit 952bc90
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
14 changes: 14 additions & 0 deletions ietf/doc/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
import datetime
import io
from django.http import HttpRequest
import lxml
import bibtexparser
import mock
Expand Down Expand Up @@ -52,6 +53,7 @@
generate_idnits2_rfcs_obsoleted,
get_doc_email_aliases,
)
from ietf.doc.views_doc import get_diff_revisions
from ietf.group.models import Group, Role
from ietf.group.factories import GroupFactory, RoleFactory
from ietf.ipr.factories import HolderIprDisclosureFactory
Expand Down Expand Up @@ -1954,6 +1956,18 @@ def test_writeup(self):
self.assertContains(r, notes.text)
self.assertContains(r, rfced_note.text)

def test_diff_revisions(self):
ind_doc = IndividualDraftFactory(create_revisions=range(2))
wg_doc = WgDraftFactory(
relations=[("replaces", ind_doc)], create_revisions=range(2)
)
diff_revisions = get_diff_revisions(HttpRequest(), wg_doc.name, wg_doc)
self.assertEqual(len(diff_revisions), 4)
self.assertEqual(
[t[3] for t in diff_revisions],
[f"{n}-{v:02d}" for n in [wg_doc.name, ind_doc.name] for v in [1, 0]],
)

def test_history(self):
doc = IndividualDraftFactory()

Expand Down
8 changes: 4 additions & 4 deletions ietf/doc/views_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1133,10 +1133,10 @@ def get_diff_revisions(request, name, doc):

diff_documents = [doc]
diff_documents.extend(
Document.objects.filter(
relateddocument__source=doc,
relateddocument__relationship="replaces",
)
[
r.target
for r in RelatedDocument.objects.filter(source=doc, relationship="replaces")
]
)
if doc.came_from_draft():
diff_documents.append(doc.came_from_draft())
Expand Down

0 comments on commit 952bc90

Please sign in to comment.