James Bennett avatar James Bennett committed daa764e

Restore the ability to disable email sending on creation of an account.

Comments (0)

Files changed (2)


                 return user
         return False
-    def create_inactive_user(self, username, email, password, site):
+    def create_inactive_user(self, username, email, password,
+                             site, send_email=True):
         Create a new, inactive ``User``, generate a
         ``RegistrationProfile`` and email its activation key to the
         ``User``, returning the new ``User``.
+        By default, an activation email will be sent to the new
+        user. To disable this, pass ``send_email=False``.
         new_user = User.objects.create_user(username, email, password)
         registration_profile = self.create_profile(new_user)
-        self.send_activation_email(registration_profile, site)
+        if send_email:
+            self.send_activation_email(registration_profile, site)
         return new_user
     create_inactive_user = transaction.commit_on_success(create_inactive_user)


         self.assertEqual(len(mail.outbox), 1)
+    def test_user_creation_no_email(self):
+        """
+        Passing ``send_email=False`` when creating a new user will not
+        send an activation email.
+        """
+        new_user = RegistrationProfile.objects.create_inactive_user(site=Site.objects.get_current(),
+                                                                    send_email=False,
+                                                                    **self.user_info)
+        self.assertEqual(len(mail.outbox), 0)
     def test_unexpired_account(self):
         ``RegistrationProfile.activation_key_expired()`` is ``False``
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.