Skip to content

Commit

Permalink
signup: Copy enter_sends value when importing settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
hackerkid authored and timabbott committed Jun 16, 2018
1 parent b639778 commit 4da61e2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions zerver/lib/create_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def copy_user_settings(source_profile: UserProfile, target_profile: UserProfile)
setattr(target_profile, settings_name, value)

setattr(target_profile, "full_name", source_profile.full_name)
setattr(target_profile, "enter_sends", source_profile.enter_sends)
target_profile.save()

if source_profile.avatar_source == UserProfile.AVATAR_FROM_USER:
Expand Down
4 changes: 4 additions & 0 deletions zerver/tests/test_signup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2030,6 +2030,7 @@ def test_signup_without_user_settings_from_another_realm(self) -> None:
hamlet_in_zulip.default_language = "de"
hamlet_in_zulip.emojiset = "twitter"
hamlet_in_zulip.high_contrast_mode = True
hamlet_in_zulip.enter_sends = True
hamlet_in_zulip.tutorial_status = UserProfile.TUTORIAL_FINISHED
hamlet_in_zulip.save()

Expand All @@ -2049,6 +2050,7 @@ def test_signup_without_user_settings_from_another_realm(self) -> None:
self.assertEqual(hamlet.emojiset, "google")
self.assertEqual(hamlet.high_contrast_mode, False)
self.assertEqual(hamlet.enable_stream_sounds, False)
self.assertEqual(hamlet.enter_sends, False)
self.assertEqual(hamlet.tutorial_status, UserProfile.TUTORIAL_WAITING)

def test_signup_with_user_settings_from_another_realm(self) -> None:
Expand All @@ -2066,6 +2068,7 @@ def test_signup_with_user_settings_from_another_realm(self) -> None:
hamlet_in_zulip.default_language = "de"
hamlet_in_zulip.emojiset = "twitter"
hamlet_in_zulip.high_contrast_mode = True
hamlet_in_zulip.enter_sends = True
hamlet_in_zulip.tutorial_status = UserProfile.TUTORIAL_FINISHED
hamlet_in_zulip.save()

Expand All @@ -2084,6 +2087,7 @@ def test_signup_with_user_settings_from_another_realm(self) -> None:
self.assertEqual(hamlet_in_lear.default_language, "de")
self.assertEqual(hamlet_in_lear.emojiset, "twitter")
self.assertEqual(hamlet_in_lear.high_contrast_mode, True)
self.assertEqual(hamlet_in_lear.enter_sends, True)
self.assertEqual(hamlet_in_lear.enable_stream_sounds, False)
self.assertEqual(hamlet_in_lear.tutorial_status, UserProfile.TUTORIAL_FINISHED)
zulip_path_id = avatar_disk_path(hamlet_in_zulip)
Expand Down
5 changes: 5 additions & 0 deletions zerver/tests/test_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ def test_copy_user_settings(self) -> None:
cordelia.night_mode = True
cordelia.enable_offline_email_notifications = False
cordelia.enable_stream_push_notifications = True
cordelia.enter_sends = False
cordelia.save()

UserHotspot.objects.filter(user=cordelia).delete()
Expand Down Expand Up @@ -480,6 +481,10 @@ def test_copy_user_settings(self) -> None:
self.assertEqual(cordelia.enable_stream_push_notifications, True)
self.assertEqual(hamlet.enable_stream_push_notifications, False)

self.assertEqual(iago.enter_sends, False)
self.assertEqual(cordelia.enter_sends, False)
self.assertEqual(hamlet.enter_sends, True)

hotspots = list(UserHotspot.objects.filter(user=iago).values_list('hotspot', flat=True))
self.assertEqual(hotspots, hotspots_completed)

Expand Down

0 comments on commit 4da61e2

Please sign in to comment.