From da40255179609f384ba2a74314a83b6cb6d67fa3 Mon Sep 17 00:00:00 2001 From: Valentin Rigal <rigal@teklia.com> Date: Tue, 15 Dec 2020 15:17:33 +0100 Subject: [PATCH] Add a test case --- arkindex/project/tests/test_acl_mixin.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arkindex/project/tests/test_acl_mixin.py b/arkindex/project/tests/test_acl_mixin.py index d63d47b98e..e713bfa321 100644 --- a/arkindex/project/tests/test_acl_mixin.py +++ b/arkindex/project/tests/test_acl_mixin.py @@ -227,3 +227,18 @@ class TestACLMixin(FixtureTestCase): [(c.name, c.max_level) for c in corpora], [(c.name, Role.Guest.value) for c in Corpus.objects.filter(public=True)] ) + + def test_corpus_right_and_public(self): + # User specific rigths should be returned instead of the the defaults access for public rigths + Right.objects.create(user=self.user3, content_object=self.corpus, level=42) + corpus_acl_mixin = NewCorpusACLMixin(self.user3) + with self.assertNumQueries(1): + corpora = list(corpus_acl_mixin.readable_corpora) + self.assertCountEqual( + [(c.id, c.max_level) for c in corpora], + [ + (self.corpus1.id, 100), + (self.corpus2.id, 75), + (self.corpus.id, 42) + ] + ) -- GitLab