Skip to content

Commit

Permalink
Merge pull request #7285 from readthedocs/humitos/apiv3-update-hidden
Browse files Browse the repository at this point in the history
  • Loading branch information
humitos authored Jul 23, 2020
2 parents 97124cf + b6f31ae commit dd1ba8c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions readthedocs/api/v3/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ class Meta:
model = Version
fields = [
'active',
'hidden',
]


Expand Down
1 change: 1 addition & 0 deletions readthedocs/api/v3/tests/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def setUp(self):
verbose_name='v1.0',
identifier='a1b2c3',
project=self.project,
hidden=False,
active=True,
built=True,
type=TAG,
Expand Down
30 changes: 30 additions & 0 deletions readthedocs/api/v3/tests/test_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,33 @@ def test_projects_versions_detail_unique(self):
),
)
self.assertEqual(response.status_code, 200)

def test_projects_versions_partial_update(self):
self.assertTrue(self.version.active)
self.assertFalse(self.version.hidden)
data = {
'active': False,
'hidden': True,
}

self.client.credentials(HTTP_AUTHORIZATION=f'Token {self.token.key}')
response = self.client.patch(
reverse(
'projects-versions-detail',
kwargs={
'parent_lookup_project__slug': self.project.slug,
'version_slug': self.version.slug,
},
),
data,
)
self.assertEqual(response.status_code, 204)

self.version.refresh_from_db()
self.assertEqual(self.version.verbose_name, 'v1.0')
self.assertEqual(self.version.slug, 'v1.0')
self.assertEqual(self.version.identifier, 'a1b2c3')
self.assertFalse(self.version.active)
self.assertTrue(self.version.hidden)
self.assertTrue(self.version.built)
self.assertEqual(self.version.type, TAG)

0 comments on commit dd1ba8c

Please sign in to comment.