Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
factories.Group
creator membership
When creating a group, the user `my_group.creator` should also be added as the first user in `my_group.members`. With `factories.Group` this currently works correctly as long as no `members` argument is passed to the factory: >>> group = factories.Group() >>> group.creator <User: cookekathleen__0> >>> group.members [<User: cookekathleen__0>] >>> user = factories.User() >>> group = factories.Group(creator=user) >>> group.creator <User: pmitchell__1> >>> group.members [<User: pmitchell__1>] But when a `members` argument is passed to the factory a group can be created with `group.creator` missing from `group.members`, which is abnormal: >>> group = factories.Group(members=[user]) >>> group.creator <User: arthurturner__2> >>> group.members [<User: pmitchell__1>] Fix `factories.Group` to ensure that `group.creator` is always added as the first user in `group.members` even if a `members` list that does not include the creator is passed to the factory. Tests of the new version: >>> group = factories.Group() >>> group.creator <User: abeasley__0> >>> group.members [<User: abeasley__0>] >>> user = factories.User() >>> group = factories.Group(members=[user]) >>> group.creator <User: kristinegutierrez__2> >>> group.members [<User: kristinegutierrez__2>, <User: kristina79__1>] >>> group = factories.Group(creator=user, members=[user]) >>> group.creator <User: kristina79__1> >>> group.members [<User: kristina79__1>]
- Loading branch information