Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project: use IntegerField for remote_repository from project form. #8176

Merged
merged 1 commit into from May 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions readthedocs/projects/forms.py
Expand Up @@ -9,7 +9,6 @@
from django.conf import settings
from django.contrib.auth.models import User
from django.template.loader import render_to_string
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
from textclassifier.validators import ClassifierValidator

Expand Down Expand Up @@ -86,7 +85,7 @@ class Meta:
model = Project
fields = ('name', 'repo', 'repo_type', 'default_branch')

remote_repository = forms.CharField(
remote_repository = forms.IntegerField(
widget=forms.HiddenInput(),
required=False,
)
Expand Down
14 changes: 14 additions & 0 deletions readthedocs/rtd_tests/tests/test_project_views.py
Expand Up @@ -158,6 +158,20 @@ def test_remote_repository_is_added(self):
self.assertIsNotNone(proj)
self.assertEqual(proj.remote_repository, remote_repo)

def test_remote_repository_invalid_type(self):
self.step_data['basics']['remote_repository'] = 'Invalid id'
resp = self.post_step('basics')
self.assertEqual(resp.status_code, 200)
form = resp.context_data['form']
self.assertIn('remote_repository', form.errors)

def test_remote_repository_invalid_id(self):
self.step_data['basics']['remote_repository'] = 9
resp = self.post_step('basics')
self.assertEqual(resp.status_code, 200)
form = resp.context_data['form']
self.assertIn('remote_repository', form.errors)

def test_remote_repository_is_not_added_for_wrong_user(self):
user = get(User)
remote_repo = get(RemoteRepository)
Expand Down