Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
3657eb76
Commit
3657eb76
authored
Dec 22, 2015
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add helper methods to JS validation spec for invalid branch names
parent
23b436dc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
92 additions
and
87 deletions
+92
-87
spec/javascripts/new_branch_spec.js.coffee
spec/javascripts/new_branch_spec.js.coffee
+92
-87
No files found.
spec/javascripts/new_branch_spec.js.coffee
View file @
3657eb76
...
@@ -5,151 +5,156 @@ describe 'Branch', ->
...
@@ -5,151 +5,156 @@ describe 'Branch', ->
describe
'create a new branch'
,
->
describe
'create a new branch'
,
->
fixture
.
preload
(
'new_branch.html'
)
fixture
.
preload
(
'new_branch.html'
)
fillNameWith
=
(
value
)
->
$
(
'.js-branch-name'
).
val
(
value
).
trigger
(
'blur'
)
expectToHaveError
=
(
error
)
->
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
error
)
beforeEach
->
beforeEach
->
fixture
.
load
(
'new_branch.html'
)
fixture
.
load
(
'new_branch.html'
)
$
(
'form'
).
on
'submit'
,
(
e
)
->
e
.
preventDefault
()
$
(
'form'
).
on
'submit'
,
(
e
)
->
e
.
preventDefault
()
@
form
=
new
NewBranchForm
(
$
(
'.js-create-branch-form'
),
[])
@
form
=
new
NewBranchForm
(
$
(
'.js-create-branch-form'
),
[])
@
name
=
$
(
'.js-branch-name'
)
it
"can't start with a dot"
,
->
it
"can't start with a dot"
,
->
@
name
.
val
(
'.foo'
).
trigger
(
'blur'
)
fillNameWith
'.foo'
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't start with '.'"
)
expect
ToHaveError
"can't start with '.'"
it
"can't start with a slash"
,
->
it
"can't start with a slash"
,
->
@
name
.
val
(
'/foo'
).
trigger
(
'blur'
)
fillNameWith
'/foo'
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't start with '/'"
)
expect
ToHaveError
"can't start with '/'"
it
"can't have two consecutive dots"
,
->
it
"can't have two consecutive dots"
,
->
@
name
.
val
(
'foo..bar'
).
trigger
(
'blur'
)
fillNameWith
'foo..bar'
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't contain '..'"
)
expect
ToHaveError
"can't contain '..'"
it
"can't have spaces anywhere"
,
->
it
"can't have spaces anywhere"
,
->
@
name
.
val
(
' foo'
).
trigger
(
'blur'
)
fillNameWith
' foo'
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't contain spaces"
)
expect
ToHaveError
"can't contain spaces"
@
name
.
val
(
'foo bar'
).
trigger
(
'blur'
)
fillNameWith
'foo bar'
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't contain spaces"
)
expect
ToHaveError
"can't contain spaces"
@
name
.
val
(
'foo '
).
trigger
(
'blur'
)
fillNameWith
'foo '
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't contain spaces"
)
expect
ToHaveError
"can't contain spaces"
it
"can't have ~ anywhere"
,
->
it
"can't have ~ anywhere"
,
->
@
name
.
val
(
'~foo'
).
trigger
(
'blur'
)
fillNameWith
'~foo'
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't contain '~'"
)
expect
ToHaveError
"can't contain '~'"
@
name
.
val
(
'foo~bar'
).
trigger
(
'blur'
)
fillNameWith
'foo~bar'
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't contain '~'"
)
expect
ToHaveError
"can't contain '~'"
@
name
.
val
(
'foo~'
).
trigger
(
'blur'
)
fillNameWith
'foo~'
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't contain '~'"
)
expect
ToHaveError
"can't contain '~'"
it
"can't have tilde anwhere"
,
->
it
"can't have tilde anwhere"
,
->
@
name
.
val
(
'~foo'
).
trigger
(
'blur'
)
fillNameWith
'~foo'
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't contain '~'"
)
expect
ToHaveError
"can't contain '~'"
@
name
.
val
(
'foo~bar'
).
trigger
(
'blur'
)
fillNameWith
'foo~bar'
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't contain '~'"
)
expect
ToHaveError
"can't contain '~'"
@
name
.
val
(
'foo~'
).
trigger
(
'blur'
)
fillNameWith
'foo~'
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't contain '~'"
)
expect
ToHaveError
"can't contain '~'"
it
"can't have caret anywhere"
,
->
it
"can't have caret anywhere"
,
->
@
name
.
val
(
'^foo'
).
trigger
(
'blur'
)
fillNameWith
'^foo'
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't contain '^'"
)
expect
ToHaveError
"can't contain '^'"
@
name
.
val
(
'foo^bar'
).
trigger
(
'blur'
)
fillNameWith
'foo^bar'
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't contain '^'"
)
expect
ToHaveError
"can't contain '^'"
@
name
.
val
(
'foo^'
).
trigger
(
'blur'
)
fillNameWith
'foo^'
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't contain '^'"
)
expect
ToHaveError
"can't contain '^'"
it
"can't have : anywhere"
,
->
it
"can't have : anywhere"
,
->
@
name
.
val
(
':foo'
).
trigger
(
'blur'
)
fillNameWith
':foo'
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't contain ':'"
)
expect
ToHaveError
"can't contain ':'"
@
name
.
val
(
'foo:bar'
).
trigger
(
'blur'
)
fillNameWith
'foo:bar'
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't contain ':'"
)
expect
ToHaveError
"can't contain ':'"
@
name
.
val
(
':foo'
).
trigger
(
'blur'
)
fillNameWith
':foo'
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't contain ':'"
)
expect
ToHaveError
"can't contain ':'"
it
"can't have question mark anywhere"
,
->
it
"can't have question mark anywhere"
,
->
@
name
.
val
(
'?foo'
).
trigger
(
'blur'
)
fillNameWith
'?foo'
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't contain '?'"
)
expect
ToHaveError
"can't contain '?'"
@
name
.
val
(
'foo?bar'
).
trigger
(
'blur'
)
fillNameWith
'foo?bar'
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't contain '?'"
)
expect
ToHaveError
"can't contain '?'"
@
name
.
val
(
'foo?'
).
trigger
(
'blur'
)
fillNameWith
'foo?'
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't contain '?'"
)
expect
ToHaveError
"can't contain '?'"
it
"can't have asterisk anywhere"
,
->
it
"can't have asterisk anywhere"
,
->
@
name
.
val
(
'*foo'
).
trigger
(
'blur'
)
fillNameWith
'*foo'
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't contain '*'"
)
expect
ToHaveError
"can't contain '*'"
@
name
.
val
(
'foo*bar'
).
trigger
(
'blur'
)
fillNameWith
'foo*bar'
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't contain '*'"
)
expect
ToHaveError
"can't contain '*'"
@
name
.
val
(
'foo*'
).
trigger
(
'blur'
)
fillNameWith
'foo*'
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't contain '*'"
)
expect
ToHaveError
"can't contain '*'"
it
"can't have open bracket anywhere"
,
->
it
"can't have open bracket anywhere"
,
->
@
name
.
val
(
'[foo'
).
trigger
(
'blur'
)
fillNameWith
'[foo'
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't contain '['"
)
expect
ToHaveError
"can't contain '['"
@
name
.
val
(
'foo[bar'
).
trigger
(
'blur'
)
fillNameWith
'foo[bar'
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't contain '['"
)
expect
ToHaveError
"can't contain '['"
@
name
.
val
(
'foo['
).
trigger
(
'blur'
)
fillNameWith
'foo['
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't contain '['"
)
expect
ToHaveError
"can't contain '['"
it
"can't have a backslash anywhere"
,
->
it
"can't have a backslash anywhere"
,
->
@
name
.
val
(
'
\\
foo'
).
trigger
(
'blur'
)
fillNameWith
'
\\
foo'
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't contain '
\\
'"
)
expect
ToHaveError
"can't contain '
\\
'"
@
name
.
val
(
'foo
\\
bar'
).
trigger
(
'blur'
)
fillNameWith
'foo
\\
bar'
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't contain '
\\
'"
)
expect
ToHaveError
"can't contain '
\\
'"
@
name
.
val
(
'foo
\\
'
).
trigger
(
'blur'
)
fillNameWith
'foo
\\
'
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't contain '
\\
'"
)
expect
ToHaveError
"can't contain '
\\
'"
it
"can't contain a sequence @{ anywhere"
,
->
it
"can't contain a sequence @{ anywhere"
,
->
@
name
.
val
(
'@{foo'
).
trigger
(
'blur'
)
fillNameWith
'@{foo'
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't contain '@{'"
)
expect
ToHaveError
"can't contain '@{'"
@
name
.
val
(
'foo@{bar'
).
trigger
(
'blur'
)
fillNameWith
'foo@{bar'
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't contain '@{'"
)
expect
ToHaveError
"can't contain '@{'"
@
name
.
val
(
'foo@{'
).
trigger
(
'blur'
)
fillNameWith
'foo@{'
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't contain '@{'"
)
expect
ToHaveError
"can't contain '@{'"
it
"can't have consecutive slashes"
,
->
it
"can't have consecutive slashes"
,
->
@
name
.
val
(
'foo//bar'
).
trigger
(
'blur'
)
fillNameWith
'foo//bar'
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't contain consecutive slashes"
)
expect
ToHaveError
"can't contain consecutive slashes"
it
"can't end with a slash"
,
->
it
"can't end with a slash"
,
->
@
name
.
val
(
'foo/'
).
trigger
(
'blur'
)
fillNameWith
'foo/'
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't end in '/'"
)
expect
ToHaveError
"can't end in '/'"
it
"can't end with a dot"
,
->
it
"can't end with a dot"
,
->
@
name
.
val
(
'foo.'
).
trigger
(
'blur'
)
fillNameWith
'foo.'
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't end in '.'"
)
expect
ToHaveError
"can't end in '.'"
it
"can't end with .lock"
,
->
it
"can't end with .lock"
,
->
@
name
.
val
(
'foo.lock'
).
trigger
(
'blur'
)
fillNameWith
'foo.lock'
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't end in '.lock'"
)
expect
ToHaveError
"can't end in '.lock'"
it
"can't be the single character @"
,
->
it
"can't be the single character @"
,
->
@
name
.
val
(
'@'
).
trigger
(
'blur'
)
fillNameWith
'@'
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't be '@'"
)
expect
ToHaveError
"can't be '@'"
it
"concatenates all error messages"
,
->
it
"concatenates all error messages"
,
->
@
name
.
val
(
'/foo bar?~.'
).
trigger
(
'blur'
)
fillNameWith
'/foo bar?~.'
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't start with '/', can't contain spaces, '?', '~', can't end in '.'"
)
expect
ToHaveError
"can't start with '/', can't contain spaces, '?', '~', can't end in '.'"
it
"doesn't duplicate error messages"
,
->
it
"doesn't duplicate error messages"
,
->
@
name
.
val
(
'?foo?bar?zoo?'
).
trigger
(
'blur'
)
fillNameWith
'?foo?bar?zoo?'
expect
(
$
(
'.js-branch-name-error span'
).
text
()).
toEqual
(
"can't contain '?'"
)
expect
ToHaveError
"can't contain '?'"
it
"removes the error message when is a valid name"
,
->
it
"removes the error message when is a valid name"
,
->
@
name
.
val
(
'foo?bar'
).
trigger
(
'blur'
)
fillNameWith
'foo?bar'
expect
(
$
(
'.js-branch-name-error span'
).
length
).
toEqual
(
1
)
expect
(
$
(
'.js-branch-name-error span'
).
length
).
toEqual
(
1
)
@
name
.
val
(
'foobar'
).
trigger
(
'blur'
)
fillNameWith
'foobar'
expect
(
$
(
'.js-branch-name-error span'
).
length
).
toEqual
(
0
)
expect
(
$
(
'.js-branch-name-error span'
).
length
).
toEqual
(
0
)
it
"can have dashes anywhere"
,
->
it
"can have dashes anywhere"
,
->
@
name
.
val
(
'-foo-bar-zoo-'
).
trigger
(
'blur'
)
fillNameWith
'-foo-bar-zoo-'
expect
(
$
(
'.js-branch-name-error span'
).
length
).
toEqual
(
0
)
expect
(
$
(
'.js-branch-name-error span'
).
length
).
toEqual
(
0
)
it
"can have underscores anywhere"
,
->
it
"can have underscores anywhere"
,
->
@
name
.
val
(
'_foo_bar_zoo_'
).
trigger
(
'blur'
)
fillNameWith
'_foo_bar_zoo_'
expect
(
$
(
'.js-branch-name-error span'
).
length
).
toEqual
(
0
)
expect
(
$
(
'.js-branch-name-error span'
).
length
).
toEqual
(
0
)
it
"can have numbers anywhere"
,
->
it
"can have numbers anywhere"
,
->
@
name
.
val
(
'1foo2bar3zoo4'
).
trigger
(
'blur'
)
fillNameWith
'1foo2bar3zoo4'
expect
(
$
(
'.js-branch-name-error span'
).
length
).
toEqual
(
0
)
expect
(
$
(
'.js-branch-name-error span'
).
length
).
toEqual
(
0
)
it
"can be only letters"
,
->
it
"can be only letters"
,
->
@
name
.
val
(
'foo'
).
trigger
(
'blur'
)
fillNameWith
'foo'
expect
(
$
(
'.js-branch-name-error span'
).
length
).
toEqual
(
0
)
expect
(
$
(
'.js-branch-name-error span'
).
length
).
toEqual
(
0
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment