Skip to content

Commit

Permalink
Merge pull request #603 from SarahRK/602-extraneous-comma
Browse files Browse the repository at this point in the history
Fix #602: Remove extraneous comma from job location.
  • Loading branch information
ubernostrum committed Mar 8, 2015
2 parents bac9d2a + 5ca3254 commit a7f03a9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
8 changes: 3 additions & 5 deletions jobs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,9 @@ def display_description(self):

@property
def display_location(self):
location_parts = (self.city, self.region, self.country)
location_str = ''
for location_part in location_parts:
if location_part is not None:
location_str = ', '.join([location_str, location_part])
location_parts = [part for part in (self.city, self.region, self.country)
if part]
location_str = ', '.join(location_parts)
return location_str

@property
Expand Down
7 changes: 7 additions & 0 deletions jobs/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,10 @@ def test_region_optional(self):
self.assertEqual(job.city, "Memphis")
self.assertEqual(job.country, "USA")
self.assertIsNone(job.region)

def test_display_location(self):
job1 = self.create_job()
self.assertEqual(job1.display_location, 'Memphis, TN, USA')

job2 = self.create_job(region=None)
self.assertEqual(job2.display_location, 'Memphis, USA')

0 comments on commit a7f03a9

Please sign in to comment.