BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
3fd929fd
Commit
3fd929fd
authored
Aug 25, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'fork-star-bug' into 'master'
Fork star bug Fix
https://gitlab.com/gitlab-org/gitlab-ce/issues/523
See merge request !1039
parents
1a9b2a47
2e497d84
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
15 deletions
+15
-15
fork_service.rb
app/services/projects/fork_service.rb
+6
-1
fork_service_spec.rb
spec/services/projects/fork_service_spec.rb
+9
-14
No files found.
app/services/projects/fork_service.rb
View file @
3fd929fd
...
@@ -7,7 +7,12 @@ module Projects
...
@@ -7,7 +7,12 @@ module Projects
end
end
def
execute
def
execute
project
=
@from_project
.
dup
project_params
=
{
visibility_level:
@from_project
.
visibility_level
,
description:
@from_project
.
description
,
}
project
=
Project
.
new
(
project_params
)
project
.
name
=
@from_project
.
name
project
.
name
=
@from_project
.
name
project
.
path
=
@from_project
.
path
project
.
path
=
@from_project
.
path
project
.
namespace
=
current_user
.
namespace
project
.
namespace
=
current_user
.
namespace
...
...
spec/services/fork_service_spec.rb
→
spec/services/
projects/
fork_service_spec.rb
View file @
3fd929fd
...
@@ -5,44 +5,40 @@ describe Projects::ForkService do
...
@@ -5,44 +5,40 @@ describe Projects::ForkService do
before
do
before
do
@from_namespace
=
create
(
:namespace
)
@from_namespace
=
create
(
:namespace
)
@from_user
=
create
(
:user
,
namespace:
@from_namespace
)
@from_user
=
create
(
:user
,
namespace:
@from_namespace
)
@from_project
=
create
(
:project
,
creator_id:
@from_user
.
id
,
namespace:
@from_namespace
)
@from_project
=
create
(
:project
,
creator_id:
@from_user
.
id
,
namespace:
@from_namespace
,
star_count:
107
,
description:
'wow such project'
)
@to_namespace
=
create
(
:namespace
)
@to_namespace
=
create
(
:namespace
)
@to_user
=
create
(
:user
,
namespace:
@to_namespace
)
@to_user
=
create
(
:user
,
namespace:
@to_namespace
)
end
end
context
'fork project'
do
context
'fork project'
do
describe
"successfully creates project in the user namespace"
do
let
(
:to_project
)
{
fork_project
(
@from_project
,
@to_user
)
}
it
"successfully creates project in the user namespace"
do
it
{
to_project
.
owner
.
should
==
@to_user
}
@to_project
=
fork_project
(
@from_project
,
@to_user
)
it
{
to_project
.
namespace
.
should
==
@to_user
.
namespace
}
it
{
to_project
.
star_count
.
should
be_zero
}
@to_project
.
owner
.
should
==
@to_user
it
{
to_project
.
description
.
should
==
@from_project
.
description
}
@to_project
.
namespace
.
should
==
@to_user
.
namespace
end
end
end
end
context
'fork project failure'
do
context
'fork project failure'
do
it
"fails due to transaction failure"
do
it
"fails due to transaction failure"
do
# make the mock gitlab-shell fail
@to_project
=
fork_project
(
@from_project
,
@to_user
,
false
)
@to_project
=
fork_project
(
@from_project
,
@to_user
,
false
)
@to_project
.
errors
.
should_not
be_empty
@to_project
.
errors
.
should_not
be_empty
@to_project
.
errors
[
:base
].
should
include
(
"Fork transaction failed."
)
@to_project
.
errors
[
:base
].
should
include
(
"Fork transaction failed."
)
end
end
end
end
context
'project already exists'
do
context
'project already exists'
do
it
"should fail due to validation, not transaction failure"
do
it
"should fail due to validation, not transaction failure"
do
@existing_project
=
create
(
:project
,
creator_id:
@to_user
.
id
,
name:
@from_project
.
name
,
namespace:
@to_namespace
)
@existing_project
=
create
(
:project
,
creator_id:
@to_user
.
id
,
name:
@from_project
.
name
,
namespace:
@to_namespace
)
@to_project
=
fork_project
(
@from_project
,
@to_user
)
@to_project
=
fork_project
(
@from_project
,
@to_user
)
@existing_project
.
persisted?
.
should
be_true
@existing_project
.
persisted?
.
should
be_true
@to_project
.
errors
[
:base
].
should
include
(
"Invalid fork destination"
)
@to_project
.
errors
[
:base
].
should
include
(
"Invalid fork destination"
)
@to_project
.
errors
[
:base
].
should_not
include
(
"Fork transaction failed."
)
@to_project
.
errors
[
:base
].
should_not
include
(
"Fork transaction failed."
)
end
end
end
end
end
end
...
@@ -53,5 +49,4 @@ describe Projects::ForkService do
...
@@ -53,5 +49,4 @@ describe Projects::ForkService do
context
.
stub
(
gitlab_shell:
shell
)
context
.
stub
(
gitlab_shell:
shell
)
context
.
execute
context
.
execute
end
end
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