Skip to content

Commit

Permalink
Fix a possible ordering bug in label test
Browse files Browse the repository at this point in the history
Instead of adding a key to a set (which has no order), and later testing
against that order, just use a list for deterministic tests.
  • Loading branch information
DavidCain committed May 18, 2022
1 parent 595f599 commit 4b2f70d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ws/tests/views/test_trips.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ def test_updates_on_stale_trips(self):
self.assertIn(
'To make updates to the trip, please load the page again.', warning
)
self.assertIn('Fields which differ: Description, Leaders', warning)
self.assertIn('Fields which differ: Leaders, Description', warning)

# No edit was made; we have form errors
trip.refresh_from_db()
Expand Down
6 changes: 3 additions & 3 deletions ws/views/trips.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,15 +368,15 @@ def _stale_revision_message(self, form, current_trip, new_trip) -> Optional[str]
if current_trip.edit_revision == new_trip.edit_revision:
return None

fields_with_difference = {
fields_with_difference = [
field
for name, field in form.fields.items()
if name != 'edit_revision'
and getattr(current_trip, name) != getattr(new_trip, name)
}
]
# (Account for the fact that we might have stripped `leaders`)
if 'leaders' in form.cleaned_data and self._leaders_changed(form):
fields_with_difference.add(form.fields['leaders'])
fields_with_difference.insert(0, form.fields['leaders'])

if current_trip.last_updated_by is None:
# This shouldn't ever happen, but the data model makes it possible
Expand Down

0 comments on commit 4b2f70d

Please sign in to comment.