Skip to content

Commit

Permalink
Merge pull request #5034 from dojutsu-user/change-slug-to-identifier
Browse files Browse the repository at this point in the history
Change default_branch value from Version.slug to Version.identifier
  • Loading branch information
ericholscher authored Dec 26, 2018
2 parents 47ea3f3 + 2548b25 commit f7926c4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion readthedocs/projects/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def __init__(self, *args, **kwargs):

default_choice = (None, '-' * 9)
all_versions = self.instance.versions.values_list(
'slug', 'verbose_name'
'identifier', 'verbose_name'
)
self.fields['default_branch'].widget = forms.Select(
choices=[default_choice] + list(all_versions)
Expand Down
21 changes: 17 additions & 4 deletions readthedocs/rtd_tests/tests/test_project_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,34 +194,47 @@ def setUp(self):
slug='public-1',
active=True,
privacy_level=PUBLIC,
identifier='public-1',
)
get(
Version,
project=self.project,
slug='public-2',
active=True,
privacy_level=PUBLIC,
identifier='public-2',
)
get(
Version,
project=self.project,
slug='public-3',
active=False,
privacy_level=PROTECTED,
identifier='public-3',
)
get(
Version,
project=self.project,
slug='public-4',
active=False,
privacy_level=PUBLIC,
identifier='public/4'
)
get(
Version,
project=self.project,
slug='private',
active=True,
privacy_level=PRIVATE,
identifier='private',
)
get(
Version,
project=self.project,
slug='protected',
active=True,
privacy_level=PROTECTED,
identifier='protected',
)

def test_list_only_active_versions_on_default_version(self):
Expand All @@ -242,12 +255,12 @@ def test_list_all_versions_on_default_branch(self):
self.assertTrue(self.project.versions.filter(slug=LATEST).exists())
self.assertEqual(
set(
slug
for slug, _ in form.fields['default_branch'].widget.choices
identifier
for identifier, _ in form.fields['default_branch'].widget.choices
),
{
None, 'latest', 'public-1', 'public-2',
'public-3', 'protected', 'private'
None, 'master', 'public-1', 'public-2',
'public-3', 'public/4', 'protected', 'private'
},
)

Expand Down

0 comments on commit f7926c4

Please sign in to comment.