Change how env_roles are updated

This change makes it so that when an env_role is updated to be None, the
role property on the env_role is changed to be None in addition to being
marked as deleted. This also adds in a check so that previously deleted
env_roles cannot be reassigned a role.
This commit is contained in:
leigh-mil
2019-10-25 10:40:38 -04:00
parent 3a1a996469
commit d40c11a8f6
4 changed files with 53 additions and 14 deletions

View File

@@ -91,3 +91,14 @@ def test_disable_completed(application_role, environment):
environment_role = EnvironmentRoles.disable(environment_role.id)
assert environment_role.status == EnvironmentRole.Status.DISABLED
def test_get_for_update():
app_role = ApplicationRoleFactory.create()
env = EnvironmentFactory.create(application=app_role.application)
EnvironmentRoleFactory.create(application_role=app_role, environment=env, deleted=True)
role = EnvironmentRoles.get_for_update(app_role.id, env.id)
assert role
assert role.application_role == app_role
assert role.environment == env
assert role.deleted