|
6 | 6 |
|
7 | 7 | from readthedocs.integrations.models import Integration
|
8 | 8 | from readthedocs.invitations.models import Invitation
|
| 9 | +from readthedocs.oauth.models import RemoteRepository |
9 | 10 | from readthedocs.organizations.models import Organization
|
10 | 11 | from readthedocs.projects.constants import (
|
11 | 12 | DOWNLOADABLE_MEDIA_TYPES,
|
12 | 13 | MEDIA_TYPE_HTMLZIP,
|
| 14 | + PRIVATE, |
13 | 15 | PUBLIC,
|
14 | 16 | )
|
15 | 17 | from readthedocs.projects.models import Project
|
@@ -108,6 +110,28 @@ def test_gitlab_integration(self):
|
108 | 110 | )
|
109 | 111 | )
|
110 | 112 |
|
| 113 | + @override_settings(ALLOW_PRIVATE_REPOS=True) |
| 114 | + def test_privacy_level_pr_previews_match_remote_repository(self): |
| 115 | + remote_repository = get(RemoteRepository, private=False) |
| 116 | + self.project.remote_repository = remote_repository |
| 117 | + self.project.save() |
| 118 | + |
| 119 | + resp = self.client.get(self.url) |
| 120 | + field = resp.context["form"].fields["external_builds_privacy_level"] |
| 121 | + self.assertTrue(field.disabled) |
| 122 | + self.assertIn("We have detected that this project is public", field.help_text) |
| 123 | + self.assertEqual(self.project.external_builds_privacy_level, PUBLIC) |
| 124 | + |
| 125 | + remote_repository.private = True |
| 126 | + remote_repository.save() |
| 127 | + self.project.save() |
| 128 | + |
| 129 | + resp = self.client.get(self.url) |
| 130 | + field = resp.context["form"].fields["external_builds_privacy_level"] |
| 131 | + self.assertTrue(field.disabled) |
| 132 | + self.assertIn("We have detected that this project is private", field.help_text) |
| 133 | + self.assertEqual(self.project.external_builds_privacy_level, PRIVATE) |
| 134 | + |
111 | 135 |
|
112 | 136 | @override_settings(RTD_ALLOW_ORGANIZATIONS=True)
|
113 | 137 | class TestExternalBuildOptionWithOrganizations(TestExternalBuildOption):
|
|
0 commit comments