From 8add5b4e2286d970c6e6c40d0da5ac5965788a4d Mon Sep 17 00:00:00 2001 From: dandds Date: Tue, 21 May 2019 10:56:34 -0400 Subject: [PATCH] Filter deleted environment roles from top-level domain method. --- atst/domain/environment_roles.py | 1 + tests/domain/test_environment_roles.py | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/atst/domain/environment_roles.py b/atst/domain/environment_roles.py index bb8fdb85..f7ddda23 100644 --- a/atst/domain/environment_roles.py +++ b/atst/domain/environment_roles.py @@ -45,5 +45,6 @@ class EnvironmentRoles(object): .filter(EnvironmentRole.user_id == user_id) .filter(Application.id == application_id) .filter(EnvironmentRole.environment_id == Environment.id) + .filter(EnvironmentRole.deleted != True) .all() ) diff --git a/tests/domain/test_environment_roles.py b/tests/domain/test_environment_roles.py index de42d70e..83794852 100644 --- a/tests/domain/test_environment_roles.py +++ b/tests/domain/test_environment_roles.py @@ -14,3 +14,13 @@ def test_get_for_application_and_user(): assert len(roles) == 1 assert roles[0].environment == env1 assert roles[0].user == user + + +def test_get_for_application_and_user_does_not_return_deleted(): + user = UserFactory.create() + application = ApplicationFactory.create() + env1 = EnvironmentFactory.create(application=application) + EnvironmentRoleFactory.create(user=user, environment=env1, deleted=True) + + roles = EnvironmentRoles.get_for_application_and_user(user.id, application.id) + assert len(roles) == 0