Skip to content

Commit

Permalink
fix: strip off the spaces in mktg url
Browse files Browse the repository at this point in the history
Marketing url of the program pages must not contain the leading
or trailing spaces.

PROD-3470
  • Loading branch information
uzairr committed Sep 12, 2023
1 parent cb7f526 commit b7de0b2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions course_discovery/apps/course_metadata/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3303,8 +3303,8 @@ def weeks_to_complete_max(self):
@property
def marketing_url(self):
if self.marketing_slug:
path = f'{self.type.slug.lower()}/{self.marketing_slug}'
return urljoin(self.partner.marketing_site_url_root, path)
path = f'{self.type.slug.lower().strip()}/{self.marketing_slug.strip()}'
return urljoin(self.partner.marketing_site_url_root.strip(), path)

return None

Expand Down
12 changes: 12 additions & 0 deletions course_discovery/apps/course_metadata/tests/test_models.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2454,6 +2454,18 @@ def test_search(self):
query = 'title:' + self.program.title
self.assertSetEqual({Program.search(query).first()}, {self.program})

def test_spaces_must_be_stripped_off_from_marketing_url(self):
"""
Validate that the spaces in the marketing slug must be stripped off while generating marketing url
"""
# updating the attrs with trailing spaces
self.program.marketing_slug = 'test-slug-0 '
self.program.type.slug = 'test '
site_root = self.program.partner.marketing_site_url_root
self.program.partner.marketing_site_url_root = site_root + ' '

assert self.program.marketing_url.find(' ') == -1

def test_subject_search(self):
"""
Verify that the program endpoint correctly handles elasticsearch queries on the subject uuid
Expand Down

0 comments on commit b7de0b2

Please sign in to comment.