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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
81605504
Commit
81605504
authored
Sep 30, 2017
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove membership from fork network when unlinking
parent
df7f530d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
8 deletions
+23
-8
app/services/projects/unlink_fork_service.rb
app/services/projects/unlink_fork_service.rb
+1
-0
spec/services/projects/unlink_fork_service_spec.rb
spec/services/projects/unlink_fork_service_spec.rb
+22
-8
No files found.
app/services/projects/unlink_fork_service.rb
View file @
81605504
...
@@ -16,6 +16,7 @@ module Projects
...
@@ -16,6 +16,7 @@ module Projects
refresh_forks_count
(
@project
.
forked_from_project
)
refresh_forks_count
(
@project
.
forked_from_project
)
@project
.
forked_project_link
.
destroy
@project
.
forked_project_link
.
destroy
@project
.
fork_network_member
.
destroy
end
end
def
refresh_forks_count
(
project
)
def
refresh_forks_count
(
project
)
...
...
spec/services/projects/unlink_fork_service_spec.rb
View file @
81605504
require
'spec_helper'
require
'spec_helper'
describe
Projects
::
UnlinkForkService
do
describe
Projects
::
UnlinkForkService
do
subject
{
described_class
.
new
(
fork_project
,
user
)
}
include
ProjectForksHelper
let
(
:fork_link
)
{
create
(
:forked_project_link
)
}
subject
{
described_class
.
new
(
forked_project
,
user
)
}
let
(
:fork_project
)
{
fork_link
.
forked_to_project
}
let
(
:fork_link
)
{
forked_project
.
forked_project_link
}
let
(
:project
)
{
create
(
:project
,
:public
)
}
let
(
:forked_project
)
{
fork_project
(
project
,
user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
context
'with opened merge request on the source project'
do
context
'with opened merge request on the source project'
do
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
fork_project
,
target_project:
fork_link
.
forked_from_project
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
fork
ed
_project
,
target_project:
fork_link
.
forked_from_project
)
}
let
(
:mr_close_service
)
{
MergeRequests
::
CloseService
.
new
(
fork_project
,
user
)
}
let
(
:mr_close_service
)
{
MergeRequests
::
CloseService
.
new
(
fork
ed
_project
,
user
)
}
before
do
before
do
allow
(
MergeRequests
::
CloseService
).
to
receive
(
:new
)
allow
(
MergeRequests
::
CloseService
).
to
receive
(
:new
)
.
with
(
fork_project
,
user
)
.
with
(
fork
ed
_project
,
user
)
.
and_return
(
mr_close_service
)
.
and_return
(
mr_close_service
)
end
end
...
@@ -25,13 +28,24 @@ describe Projects::UnlinkForkService do
...
@@ -25,13 +28,24 @@ describe Projects::UnlinkForkService do
end
end
it
'remove fork relation'
do
it
'remove fork relation'
do
expect
(
fork_project
.
forked_project_link
).
to
receive
(
:destroy
)
expect
(
forked_project
.
forked_project_link
).
to
receive
(
:destroy
)
subject
.
execute
end
it
'removes the link to the fork network'
do
expect
(
forked_project
.
fork_network_member
).
to
be_present
expect
(
forked_project
.
fork_network
).
to
be_present
subject
.
execute
subject
.
execute
forked_project
.
reload
expect
(
forked_project
.
fork_network_member
).
to
be_nil
expect
(
forked_project
.
reload
.
fork_network
).
to
be_nil
end
end
it
'refreshes the forks count cache of the source project'
do
it
'refreshes the forks count cache of the source project'
do
source
=
fork_project
.
forked_from_project
source
=
fork
ed
_project
.
forked_from_project
expect
(
source
.
forks_count
).
to
eq
(
1
)
expect
(
source
.
forks_count
).
to
eq
(
1
)
...
...
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