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
e9be4b37
Commit
e9be4b37
authored
Nov 21, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cover ProjectMover with tests
parent
47234ab3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
6 deletions
+70
-6
lib/gitlab/project_mover.rb
lib/gitlab/project_mover.rb
+0
-1
spec/lib/project_mover_spec.rb
spec/lib/project_mover_spec.rb
+65
-0
spec/support/namespaces_stub.rb
spec/support/namespaces_stub.rb
+5
-5
No files found.
lib/gitlab/project_mover.rb
View file @
e9be4b37
...
...
@@ -32,7 +32,6 @@ module Gitlab
message
=
"Project
#{
project
.
name
}
cannot be moved from
#{
old_path
}
to
#{
new_path
}
"
log_info
"Error!
#{
message
}
"
raise
ProjectMoveError
.
new
(
message
)
false
end
end
...
...
spec/lib/project_mover_spec.rb
0 → 100644
View file @
e9be4b37
require
'spec_helper'
describe
Gitlab
::
ProjectMover
do
let
(
:base_path
)
{
Rails
.
root
.
join
(
'tmp'
,
'rspec-sandbox'
)
}
before
do
FileUtils
.
rm_rf
base_path
if
File
.
exists?
base_path
Gitlab
.
config
.
stub
(
git_base_path:
base_path
)
@project
=
create
(
:project
)
end
after
do
FileUtils
.
rm_rf
base_path
end
it
"should move project to subdir"
do
mk_dir
base_path
,
''
,
@project
.
path
mover
=
Gitlab
::
ProjectMover
.
new
(
@project
,
''
,
'opensource'
)
mover
.
execute
.
should
be_true
moved?
(
'opensource'
,
@project
.
path
).
should
be_true
end
it
"should move project from one subdir to another"
do
mk_dir
base_path
,
'vsizov'
,
@project
.
path
mover
=
Gitlab
::
ProjectMover
.
new
(
@project
,
'vsizov'
,
'randx'
)
mover
.
execute
.
should
be_true
moved?
(
'randx'
,
@project
.
path
).
should
be_true
end
it
"should move project from subdir to base"
do
mk_dir
base_path
,
'vsizov'
,
@project
.
path
mover
=
Gitlab
::
ProjectMover
.
new
(
@project
,
'vsizov'
,
''
)
mover
.
execute
.
should
be_true
moved?
(
''
,
@project
.
path
).
should
be_true
end
it
"should raise if destination exists"
do
mk_dir
base_path
,
''
,
@project
.
path
mk_dir
base_path
,
'vsizov'
,
@project
.
path
mover
=
Gitlab
::
ProjectMover
.
new
(
@project
,
'vsizov'
,
''
)
expect
{
mover
.
execute
}.
to
raise_error
(
Gitlab
::
ProjectMover
::
ProjectMoveError
)
end
it
"should raise if move failed"
do
mk_dir
base_path
mover
=
Gitlab
::
ProjectMover
.
new
(
@project
,
'vsizov'
,
''
)
expect
{
mover
.
execute
}.
to
raise_error
(
Gitlab
::
ProjectMover
::
ProjectMoveError
)
end
def
mk_dir
base_path
,
namespace
=
''
,
project_path
=
''
FileUtils
.
mkdir_p
File
.
join
(
base_path
,
namespace
,
project_path
+
".git"
)
end
def
moved?
namespace
,
path
File
.
exists?
(
File
.
join
(
base_path
,
namespace
,
path
+
'.git'
))
end
end
spec/support/namespaces_stub.rb
View file @
e9be4b37
...
...
@@ -11,8 +11,8 @@ class Namespace
end
end
class
Gitlab::ProjectMover
def
execute
true
end
end
#
class Gitlab::ProjectMover
#
def execute
#
true
#
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