File tree 2 files changed +17
-4
lines changed
2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -131,6 +131,10 @@ def clean_name(self):
131
131
132
132
return name
133
133
134
+ def clean_repo (self ):
135
+ repo = self .cleaned_data .get ('repo' , '' )
136
+ return repo .rstrip ('/' )
137
+
134
138
def clean_remote_repository (self ):
135
139
remote_repo = self .cleaned_data .get ('remote_repository' , None )
136
140
if not remote_repo :
Original file line number Diff line number Diff line change 1
- # -*- coding: utf-8 -*-
2
-
3
1
import mock
4
2
from django .contrib .auth .models import User
5
3
from django .test import TestCase
6
4
from django .test .utils import override_settings
7
5
from django_dynamic_fixture import get
8
6
from textclassifier .validators import ClassifierValidator
9
- from django .core .exceptions import ValidationError
10
7
11
8
from readthedocs .builds .constants import LATEST
12
9
from readthedocs .builds .models import Version
@@ -180,6 +177,18 @@ def test_length_of_tags(self):
180
177
error_msg = 'Length of each tag must be less than or equal to 100 characters.'
181
178
self .assertDictEqual (form .errors , {'tags' : [error_msg ]})
182
179
180
+ def test_strip_repo_url (self ):
181
+ form = ProjectBasicsForm ({
182
+ 'name' : 'foo' ,
183
+ 'repo_type' : 'git' ,
184
+ 'repo' : 'https://github.com/rtfd/readthedocs.org/'
185
+ })
186
+ self .assertTrue (form .is_valid ())
187
+ self .assertEqual (
188
+ form .cleaned_data ['repo' ],
189
+ 'https://github.com/rtfd/readthedocs.org'
190
+ )
191
+
183
192
184
193
class TestProjectAdvancedForm (TestCase ):
185
194
@@ -514,7 +523,7 @@ class TestNotificationForm(TestCase):
514
523
515
524
def setUp (self ):
516
525
self .project = get (Project )
517
-
526
+
518
527
def test_webhookform (self ):
519
528
self .assertEqual (self .project .webhook_notifications .all ().count (), 0 )
520
529
You can’t perform that action at this time.
0 commit comments