Skip to content
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
17 changes: 15 additions & 2 deletions credentials/apps/credentials/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,19 @@ def test_sharing_bar_with_staff_user(self):

self.assertContains(response, "Print or share your certificate")

@responses.activate
def test_open_graph_metadata(self):
"""Verify that the anonymous view contains OpenGraph metadata."""
self.client.logout()
response = self._render_user_credential()

self.assertContains(response, "og:url")
self.assertContains(response, "og:title")
self.assertContains(response, "og:description")
self.assertContains(response, '"og:type" content="image/png"')
self.assertContains(response, self.user_credential.get_absolute_url())
self.assertContains(response, "I completed a course at ")

@responses.activate
def test_awarded_with_logged_in_user(self):
"""Verify that the view renders awarded certificates with sharing bar."""
Expand All @@ -160,7 +173,7 @@ def test_awarded_with_logged_in_user(self):
self.assertContains(response, "Print or share your certificate")
self.assertContains(response, "Print this certificate")

self.assertContains(response=response, text=self.PROGRAM_NAME, count=2)
self.assertContains(response=response, text=self.PROGRAM_NAME, count=3)
self.assertNotContains(response=response, text=self.CREDENTIAL_TITLE)

self.assertEqual(response_context_data["user_credential"], self.user_credential)
Expand Down Expand Up @@ -226,7 +239,7 @@ def test_awarded_with_custom_title(self):

self.assertContains(response, "Print or share your certificate")
self.assertNotContains(response=response, text=self.PROGRAM_NAME)
self.assertContains(response=response, text=self.CREDENTIAL_TITLE, count=2)
self.assertContains(response=response, text=self.CREDENTIAL_TITLE, count=3)

def test_revoked(self):
"""Verify that the view returns 404 when the uuid is valid but certificate status
Expand Down
5 changes: 5 additions & 0 deletions credentials/apps/credentials/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ def get_context_data(self, **kwargs):
"program_name": program_details.title,
"credential_title": program_details.credential_title,
"org_name_string": org_name_string,
"share_url": self.request.build_absolute_uri(),
"share_image_url": program_details.organizations[0].certificate_logo_image_url,
"share_text": _("I completed a course at {platform_name}.").format(
platform_name=self.site_configuration.platform_name
),
}
)
if program_details.hours_of_effort:
Expand Down
Binary file added credentials/conf/locale/en/LC_MESSAGES/django.mo
Binary file not shown.
Loading