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
Kazuhiko Shiozaki
gitlab-ce
Commits
f4387917
Commit
f4387917
authored
Mar 02, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix import check for case sensetive namespaces
parent
2f4656b5
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
1 deletion
+16
-1
app/controllers/import/base_controller.rb
app/controllers/import/base_controller.rb
+1
-1
app/models/namespace.rb
app/models/namespace.rb
+5
-0
spec/models/namespace_spec.rb
spec/models/namespace_spec.rb
+10
-0
No files found.
app/controllers/import/base_controller.rb
View file @
f4387917
...
...
@@ -3,7 +3,7 @@ class Import::BaseController < ApplicationController
private
def
get_or_create_namespace
existing_namespace
=
Namespace
.
find_by
(
"path = ? OR name = ?"
,
@target_namespace
,
@target_namespace
)
existing_namespace
=
Namespace
.
find_by
_path_or_name
(
@target_namespace
)
if
existing_namespace
if
existing_namespace
.
owner
==
current_user
...
...
app/models/namespace.rb
View file @
f4387917
...
...
@@ -48,6 +48,11 @@ class Namespace < ActiveRecord::Base
where
(
'lower(path) = :value'
,
value:
path
.
downcase
).
first
end
# Case insensetive search for namespace by path or name
def
self
.
find_by_path_or_name
(
path
)
find_by
(
"lower(path) = :path OR lower(name) = :path"
,
path:
path
.
downcase
)
end
def
self
.
search
(
query
)
where
(
"name LIKE :query OR path LIKE :query"
,
query:
"%
#{
query
}
%"
)
end
...
...
spec/models/namespace_spec.rb
View file @
f4387917
...
...
@@ -75,4 +75,14 @@ describe Namespace do
expect
(
namespace
.
rm_dir
).
to
be_truthy
end
end
describe
:find_by_path_or_name
do
before
do
@namespace
=
create
(
:namespace
,
name:
'WoW'
,
path:
'woW'
)
end
it
{
expect
(
Namespace
.
find_by_path_or_name
(
'wow'
)).
to
eq
(
@namespace
)
}
it
{
expect
(
Namespace
.
find_by_path_or_name
(
'WOW'
)).
to
eq
(
@namespace
)
}
it
{
expect
(
Namespace
.
find_by_path_or_name
(
'unknown'
)).
to
eq
(
nil
)
}
end
end
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