Skip to content

Commit

Permalink
Merge pull request #3368 from rtfd/deploy-stable-hotfix
Browse files Browse the repository at this point in the history
Revert "Merge pull request #3336 from rtfd/use-active-for-stable"
  • Loading branch information
ericholscher authored Dec 7, 2017
2 parents f20c985 + 5f6917c commit 3a6d64f
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 4 deletions.
2 changes: 1 addition & 1 deletion readthedocs/projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ def update_stable_version(self):
if current_stable:
identifier_updated = (
new_stable.identifier != current_stable.identifier)
if identifier_updated and current_stable.active:
if identifier_updated and current_stable.active and current_stable.machine:
log.info(
"Update stable version: {project}:{version}".format(
project=self.slug,
Expand Down
71 changes: 68 additions & 3 deletions readthedocs/rtd_tests/tests/test_sync_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,6 @@ def test_update_stable_version(self):
self.assertEqual(version_stable.identifier, '1.0.0')

def test_update_inactive_stable_version(self):
"""
Test that stable doesn't get updated when it isn't active
"""
version_post_data = {
'branches': [
{
Expand Down Expand Up @@ -471,3 +468,71 @@ def test_unicode(self):
content_type='application/json',
)
self.assertEqual(resp.status_code, 200)

def test_user_defined_stable_version_with_tags(self):

Version.objects.create(
project=self.pip,
identifier='0.8.3',
verbose_name='0.8.3',
active=True,
)

# A pre-existing active stable branch that was machine created
Version.objects.create(
project=self.pip,
identifier='foo',
type='branch',
verbose_name='stable',
active=True,
machine=True,
)

version_post_data = {
'branches': [
{
'identifier': 'origin/master',
'verbose_name': 'master',
},
# A new user-defined stable branch
{
'identifier': 'origin/stable',
'verbose_name': 'stable',
},
],
'tags': [
{
'identifier': '0.9',
'verbose_name': '0.9',
},
{
'identifier': '0.8.3',
'verbose_name': '0.8.3',
},
],
}

self.client.post(
'/api/v2/project/{}/sync_versions/'.format(self.pip.pk),
data=json.dumps(version_post_data),
content_type='application/json',
)

# Didn't update to newest tag
version_9 = Version.objects.get(slug='0.9')
self.assertFalse(version_9.active)

# Did update to user-defined stable version
version_stable = Version.objects.get(slug='stable')
self.assertFalse(version_stable.machine)
self.assertTrue(version_stable.active)
self.assertEqual('origin/stable', self.pip.get_stable_version().identifier)

# Check that posting again doesn't change anything from current state.
self.client.post(
'/api/v2/project/{}/sync_versions/'.format(self.pip.pk),
data=json.dumps(version_post_data),
content_type='application/json',
)

self.assertEqual('origin/stable', self.pip.get_stable_version().identifier)

0 comments on commit 3a6d64f

Please sign in to comment.