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
1501a4f5
Commit
1501a4f5
authored
Jul 04, 2017
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up the ForkedProjectLink specs
parent
75ac425c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
29 deletions
+35
-29
forked_project_link_spec.rb
spec/models/forked_project_link_spec.rb
+35
-29
No files found.
spec/models/forked_project_link_spec.rb
View file @
1501a4f5
...
...
@@ -2,53 +2,59 @@ require 'spec_helper'
describe
ForkedProjectLink
,
"add link on fork"
do
let
(
:project_from
)
{
create
(
:project
,
:repository
)
}
let
(
:project_to
)
{
fork_project
(
project_from
,
user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:namespace
)
{
user
.
namespace
}
before
do
create
(
:project_member
,
:reporter
,
user:
user
,
project:
project_from
)
@project_to
=
fork_project
(
project_from
,
user
)
project_from
.
add_reporter
(
user
)
end
it
'project_from knows its forks'
do
_
=
project_to
expect
(
project_from
.
forks
.
count
).
to
eq
(
1
)
end
it
"project_to knows it is forked"
do
expect
(
@
project_to
.
forked?
).
to
be_truthy
expect
(
project_to
.
forked?
).
to
be_truthy
end
it
"project knows who it is forked from"
do
expect
(
@
project_to
.
forked_from_project
).
to
eq
(
project_from
)
expect
(
project_to
.
forked_from_project
).
to
eq
(
project_from
)
end
end
describe
'#forked?'
do
let
(
:forked_project_link
)
{
build
(
:forked_project_link
)
}
let
(
:project_from
)
{
create
(
:project
,
:repository
)
}
let
(
:project_to
)
{
create
(
:project
,
forked_project_link:
forked_project_link
)
}
describe
'#forked?'
do
let
(
:project_to
)
{
create
(
:project
,
forked_project_link:
forked_project_link
)
}
let
(
:forked_project_link
)
{
build
(
:forked_project_link
)
}
before
:each
do
forked_project_link
.
forked_from_project
=
project_from
forked_project_link
.
forked_to_project
=
project_to
forked_project_link
.
save!
end
before
do
forked_project_link
.
forked_from_project
=
project_from
forked_project_link
.
forked_to_project
=
project_to
forked_project_link
.
save!
end
it
"project_to knows it is forked"
do
expect
(
project_to
.
forked?
).
to
be_truthy
end
it
"project_to knows it is forked"
do
expect
(
project_to
.
forked?
).
to
be_truthy
end
it
"project_from is not forked"
do
expect
(
project_from
.
forked?
).
to
be_falsey
end
it
"project_from is not forked"
do
expect
(
project_from
.
forked?
).
to
be_falsey
end
it
"project_to.destroy destroys fork_link"
do
expect
(
forked_project_link
).
to
receive
(
:destroy
)
project_to
.
destroy
it
"project_to.destroy destroys fork_link"
do
expect
(
forked_project_link
).
to
receive
(
:destroy
)
project_to
.
destroy
end
end
end
def
fork_project
(
from_project
,
user
)
shell
=
double
(
'gitlab_shell'
,
fork_repository:
true
)
def
fork_project
(
from_project
,
user
)
service
=
Projects
::
ForkService
.
new
(
from_project
,
user
)
shell
=
double
(
'gitlab_shell'
,
fork_repository:
true
)
service
=
Projects
::
ForkService
.
new
(
from_project
,
user
)
allow
(
service
).
to
receive
(
:gitlab_shell
).
and_return
(
shell
)
allow
(
service
).
to
receive
(
:gitlab_shell
).
and_return
(
shell
)
service
.
execute
service
.
execute
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