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
a99b8c20
Commit
a99b8c20
authored
Sep 11, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
6561982b
d20ce7de
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
67 additions
and
18 deletions
+67
-18
app/controllers/projects/forks_controller.rb
app/controllers/projects/forks_controller.rb
+9
-6
app/views/projects/forks/index.html.haml
app/views/projects/forks/index.html.haml
+1
-1
app/views/shared/projects/_list.html.haml
app/views/shared/projects/_list.html.haml
+0
-6
spec/controllers/projects/forks_controller_spec.rb
spec/controllers/projects/forks_controller_spec.rb
+57
-4
spec/features/projects/fork_spec.rb
spec/features/projects/fork_spec.rb
+0
-1
No files found.
app/controllers/projects/forks_controller.rb
View file @
a99b8c20
...
...
@@ -2,6 +2,7 @@
class
Projects::ForksController
<
Projects
::
ApplicationController
include
ContinueParams
include
RendersMemberAccess
# Authorize
before_action
:whitelist_query_limiting
,
only:
[
:create
]
...
...
@@ -11,14 +12,16 @@ class Projects::ForksController < Projects::ApplicationController
# rubocop: disable CodeReuse/ActiveRecord
def
index
base_query
=
project
.
forks
.
includes
(
:creator
)
@total_forks_count
=
project
.
forks
.
size
@public_forks_count
=
project
.
forks
.
public_only
.
size
@private_forks_count
=
@total_forks_count
-
project
.
forks
.
public_and_internal_only
.
size
@internal_forks_count
=
@total_forks_count
-
@public_forks_count
-
@private_forks_count
forks
=
ForkProjectsFinder
.
new
(
project
,
params:
params
.
merge
(
search:
params
[
:filter_projects
]),
current_user:
current_user
).
execute
@total_forks_count
=
base_query
.
size
@private_forks_count
=
@total_forks_count
-
forks
.
size
@public_forks_count
=
@total_forks_count
-
@private_forks_count
@forks
=
ForkProjectsFinder
.
new
(
project
,
params:
params
.
merge
(
search:
params
[
:filter_projects
]),
current_user:
current_user
).
execute
@forks
=
@forks
.
includes
(
:route
,
:creator
,
:group
,
namespace:
[
:route
,
:owner
])
.
page
(
params
[
:page
])
@forks
=
forks
.
page
(
params
[
:page
]
)
prepare_projects_for_rendering
(
@forks
)
respond_to
do
|
format
|
format
.
html
...
...
app/views/projects/forks/index.html.haml
View file @
a99b8c20
.top-area
.nav-text
-
full_count_title
=
"
#{
@public_forks_count
}
public and
#{
@private_forks_count
}
private"
-
full_count_title
=
"
#{
@public_forks_count
}
public
,
#{
@internal_forks_count
}
internal,
and
#{
@private_forks_count
}
private"
#{
pluralize
(
@total_forks_count
,
'fork'
)
}
:
#{
full_count_title
}
.nav-controls
...
...
app/views/shared/projects/_list.html.haml
View file @
a99b8c20
...
...
@@ -42,12 +42,6 @@
avatar:
avatar
,
stars:
stars
,
css_class:
css_class
,
ci:
ci
,
use_creator_avatar:
use_creator_avatar
,
forks:
forks
,
show_last_commit_as_description:
show_last_commit_as_description
,
user:
user
,
merge_requests:
merge_requests
,
issues:
issues
,
pipeline_status:
pipeline_status
,
compact_mode:
compact_mode
-
if
@private_forks_count
&&
@private_forks_count
>
0
%li
.project-row.private-forks-notice
=
icon
(
'lock fw'
,
base:
'circle'
,
class:
'fa-lg private-fork-icon'
)
%strong
=
pluralize
(
@private_forks_count
,
'private fork'
)
%span
you have no access to.
=
paginate_collection
(
projects
,
remote:
remote
)
unless
skip_pagination
-
else
-
if
@contributed_projects
...
...
spec/controllers/projects/forks_controller_spec.rb
View file @
a99b8c20
...
...
@@ -5,7 +5,7 @@ require 'spec_helper'
describe
Projects
::
ForksController
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
:public
,
:repository
)
}
let
(
:forked_project
)
{
Projects
::
ForkService
.
new
(
project
,
user
).
execute
}
let
(
:forked_project
)
{
Projects
::
ForkService
.
new
(
project
,
user
,
name:
'Some name'
).
execute
}
let
(
:group
)
{
create
(
:group
)
}
before
do
...
...
@@ -13,11 +13,12 @@ describe Projects::ForksController do
end
describe
'GET index'
do
def
get_forks
def
get_forks
(
search:
nil
)
get
:index
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
project_id:
project
,
search:
search
}
end
...
...
@@ -31,6 +32,41 @@ describe Projects::ForksController do
expect
(
assigns
[
:forks
]).
to
be_present
end
it
'forks counts are correct'
do
get_forks
expect
(
assigns
[
:total_forks_count
]).
to
eq
(
1
)
expect
(
assigns
[
:public_forks_count
]).
to
eq
(
1
)
expect
(
assigns
[
:internal_forks_count
]).
to
eq
(
0
)
expect
(
assigns
[
:private_forks_count
]).
to
eq
(
0
)
end
context
'after search'
do
it
'forks counts are correct'
do
get_forks
(
search:
'Non-matching query'
)
expect
(
assigns
[
:total_forks_count
]).
to
eq
(
1
)
expect
(
assigns
[
:public_forks_count
]).
to
eq
(
1
)
expect
(
assigns
[
:internal_forks_count
]).
to
eq
(
0
)
expect
(
assigns
[
:private_forks_count
]).
to
eq
(
0
)
end
end
end
context
'when fork is internal'
do
before
do
forked_project
.
update
(
visibility_level:
Project
::
INTERNAL
,
group:
group
)
end
it
'forks counts are correct'
do
get_forks
expect
(
assigns
[
:total_forks_count
]).
to
eq
(
1
)
expect
(
assigns
[
:public_forks_count
]).
to
eq
(
0
)
expect
(
assigns
[
:internal_forks_count
]).
to
eq
(
1
)
expect
(
assigns
[
:private_forks_count
]).
to
eq
(
0
)
end
end
context
'when fork is private'
do
...
...
@@ -38,12 +74,25 @@ describe Projects::ForksController do
forked_project
.
update
(
visibility_level:
Project
::
PRIVATE
,
group:
group
)
end
it
'is not be visible for non logged in users'
do
shared_examples
'forks counts'
do
it
'forks counts are correct'
do
get_forks
expect
(
assigns
[
:total_forks_count
]).
to
eq
(
1
)
expect
(
assigns
[
:public_forks_count
]).
to
eq
(
0
)
expect
(
assigns
[
:internal_forks_count
]).
to
eq
(
0
)
expect
(
assigns
[
:private_forks_count
]).
to
eq
(
1
)
end
end
it
'is not visible for non logged in users'
do
get_forks
expect
(
assigns
[
:forks
]).
to
be_blank
end
include_examples
'forks counts'
context
'when user is logged in'
do
before
do
sign_in
(
project
.
creator
)
...
...
@@ -67,6 +116,8 @@ describe Projects::ForksController do
expect
(
assigns
[
:forks
]).
to
be_present
end
include_examples
'forks counts'
end
context
'when user is a member of the Group'
do
...
...
@@ -79,6 +130,8 @@ describe Projects::ForksController do
expect
(
assigns
[
:forks
]).
to
be_present
end
include_examples
'forks counts'
end
end
end
...
...
spec/features/projects/fork_spec.rb
View file @
a99b8c20
...
...
@@ -121,7 +121,6 @@ describe 'Project fork' do
end
expect
(
page
).
not_to
have_content
(
"
#{
another_project_fork
.
namespace
.
human_name
}
/
#{
another_project_fork
.
name
}
"
)
expect
(
page
).
to
have_content
(
"1 private fork"
)
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