Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: follow replaces when building list for diff control #8234

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading