Skip to content

Commit

Permalink
fix: make is_active_for_user consider when everyone is False
Browse files Browse the repository at this point in the history
fixes #401
  • Loading branch information
chess-octane committed Feb 20, 2024
1 parent 63444d6 commit 6314e06
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions waffle/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ def is_active_for_user(self, user: AbstractBaseUser) -> bool | None:
if self.everyone:
return True

if self.everyone is False:
return False

if self.authenticated and user.is_authenticated:
return True

Expand Down
7 changes: 6 additions & 1 deletion waffle/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,9 @@ def test_flag_is_not_active_for_none_requests(self):
def test_is_active_for_user_when_everyone_is_active(self):
flag = get_waffle_flag_model().objects.create(name='test-flag')
flag.everyone = True
self.assertEqual(flag.is_active_for_user(User()), True)
self.assertEqual(flag.is_active_for_user(User()), True)

def test_is_active_for_user_when_everyone_is_disabled(self):
flag = get_waffle_flag_model().objects.create(name='test-flag')
flag.everyone = False
self.assertEqual(flag.is_active_for_user(User()), False)

0 comments on commit 6314e06

Please sign in to comment.