Skip to content

Commit

Permalink
Fix gravatar URL for Wagtail 6.4+
Browse files Browse the repository at this point in the history
  • Loading branch information
zerolab committed Dec 23, 2024
1 parent 92a09eb commit 81bfd17
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions wagtail_localize/tests/test_edit_translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
)
from rest_framework.settings import api_settings
from rest_framework.test import APITestCase
from wagtail import VERSION as WAGTAIL_VERSION
from wagtail.admin.panels import FieldPanel, TitleFieldPanel
from wagtail.blocks import StreamValue
from wagtail.documents.models import Document
Expand Down Expand Up @@ -110,12 +111,18 @@ def patched_translate_html(html):


class EditTranslationTestData(WagtailTestUtils):
@classmethod
def setUpTestData(cls):
cls.moderators_group = Group.objects.get(name="Moderators")

avatar_suffix = "mp" if WAGTAIL_VERSION >= (6, 4, 0, "alpha", 0) else "mm"
cls.avatar_url = f"//www.gravatar.com/avatar/93942e96f5acd83e2e047ad8fe03114d?s=50&d={ avatar_suffix }"

def setUp(self):
self.login()
self.user = get_user_model().objects.get()

# Convert the user into an editor
self.moderators_group = Group.objects.get(name="Moderators")
for permission in Permission.objects.filter(
content_type=ContentType.objects.get_for_model(TestSnippet)
):
Expand Down Expand Up @@ -2305,7 +2312,7 @@ def test_create_string_translation(self):
"error": None,
"comment": "Translated manually on 21 August 2020",
"last_translated_by": {
"avatar_url": "//www.gravatar.com/avatar/93942e96f5acd83e2e047ad8fe03114d?s=50&d=mm",
"avatar_url": self.avatar_url,
"full_name": "",
},
},
Expand Down Expand Up @@ -2353,7 +2360,7 @@ def test_update_string_translation(self):
"error": None,
"comment": "Translated manually on 21 August 2020",
"last_translated_by": {
"avatar_url": "//www.gravatar.com/avatar/93942e96f5acd83e2e047ad8fe03114d?s=50&d=mm",
"avatar_url": self.avatar_url,
"full_name": "",
},
},
Expand Down Expand Up @@ -2401,7 +2408,7 @@ def test_update_string_translation_with_bad_html(self):
"error": "<script> tag is not allowed. Strings can only contain standard HTML inline tags (such as <b>, <a>)",
"comment": "Translated manually on 21 August 2020",
"last_translated_by": {
"avatar_url": "//www.gravatar.com/avatar/93942e96f5acd83e2e047ad8fe03114d?s=50&d=mm",
"avatar_url": self.avatar_url,
"full_name": "",
},
},
Expand Down Expand Up @@ -2450,7 +2457,7 @@ def test_update_string_translation_with_unkown_links(self):
"error": "Unrecognised id found in an <a> tag: a42",
"comment": "Translated manually on 21 August 2020",
"last_translated_by": {
"avatar_url": "//www.gravatar.com/avatar/93942e96f5acd83e2e047ad8fe03114d?s=50&d=mm",
"avatar_url": self.avatar_url,
"full_name": "",
},
},
Expand Down

0 comments on commit 81bfd17

Please sign in to comment.