Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
22fcdf7e24e4
Commit
22fcdf7e
authored
Jul 17, 2016
by
Stan Hu
Browse files
Allow a project import URL to be blank to prevent false positives
preventing settings from being saved
parent
2b61e1c60aa2
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/models/project.rb
View file @
22fcdf7e
...
...
@@ -162,7 +162,7 @@
validates
:namespace
,
presence:
true
validates_uniqueness_of
:name
,
scope: :namespace_id
validates_uniqueness_of
:path
,
scope: :namespace_id
validates
:import_url
,
addressable_url:
true
,
if:
:
import_url
validates
:import_url
,
addressable_url:
true
,
if:
"
import_url
.present?"
validates
:star_count
,
numericality:
{
greater_than_or_equal_to:
0
}
validate
:check_limit
,
on: :create
validate
:avatar_type
,
...
...
@@ -482,7 +482,7 @@
end
def
create_or_update_import_data
(
data:
nil
,
credentials:
nil
)
return
unless
valid_import_url?
return
unless
import_url
.
present?
&&
valid_import_url?
project_import_data
=
import_data
||
build_import_data
if
data
...
...
spec/models/project_spec.rb
View file @
22fcdf7e
...
...
@@ -142,6 +142,6 @@
expect
(
project2
).
to
be_valid
end
it
'
does not allow to introduce
an empty URI'
do
it
'
allows
an empty URI'
do
project2
=
build
(
:project
,
import_url:
''
)
...
...
@@ -146,6 +146,6 @@
project2
=
build
(
:project
,
import_url:
''
)
expect
(
project2
).
not_
to
be_valid
expect
(
project2
).
to
be_valid
end
it
'does not produce import data on an empty URI'
do
...
...
Write
Preview
Supports
Markdown
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