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
Léo-Paul Géneau
gitlab-ce
Commits
02ddb9df
Commit
02ddb9df
authored
Sep 06, 2016
by
Patricio Cano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Syntax fixes and better tests for helper methods. Updated docs.
parent
d0279ccb
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
137 additions
and
26 deletions
+137
-26
CHANGELOG
CHANGELOG
+0
-1
app/controllers/admin/groups_controller.rb
app/controllers/admin/groups_controller.rb
+4
-4
app/controllers/groups_controller.rb
app/controllers/groups_controller.rb
+5
-5
app/helpers/groups_helper.rb
app/helpers/groups_helper.rb
+11
-10
app/views/admin/groups/_form.html.haml
app/views/admin/groups/_form.html.haml
+1
-1
app/views/groups/_group_lfs_settings.html.haml
app/views/groups/_group_lfs_settings.html.haml
+0
-0
app/views/groups/edit.html.haml
app/views/groups/edit.html.haml
+1
-1
doc/api/groups.md
doc/api/groups.md
+2
-2
lib/api/entities.rb
lib/api/entities.rb
+4
-2
spec/helpers/groups_helper_spec.rb
spec/helpers/groups_helper_spec.rb
+63
-0
spec/models/group_spec.rb
spec/models/group_spec.rb
+46
-0
No files found.
CHANGELOG
View file @
02ddb9df
...
@@ -75,7 +75,6 @@ v 8.12.0 (unreleased)
...
@@ -75,7 +75,6 @@ v 8.12.0 (unreleased)
- Add last commit time to repo view (ClemMakesApps)
- Add last commit time to repo view (ClemMakesApps)
- Fix accessibility and visibility of project list dropdown button !6140
- Fix accessibility and visibility of project list dropdown button !6140
- Fix missing flash messages on service edit page (airatshigapov)
- Fix missing flash messages on service edit page (airatshigapov)
- Added project specific enable/disable setting for LFS !5997
- Added project-specific enable/disable setting for LFS !5997
- Added project-specific enable/disable setting for LFS !5997
- Added group-specific enable/disable setting for LFS !6164
- Added group-specific enable/disable setting for LFS !6164
- Don't expose a user's token in the `/api/v3/user` API (!6047)
- Don't expose a user's token in the `/api/v3/user` API (!6047)
...
...
app/controllers/admin/groups_controller.rb
View file @
02ddb9df
...
@@ -61,13 +61,13 @@ class Admin::GroupsController < Admin::ApplicationController
...
@@ -61,13 +61,13 @@ class Admin::GroupsController < Admin::ApplicationController
def
group_params
def
group_params
params
.
require
(
:group
).
permit
(
params
.
require
(
:group
).
permit
(
:
name
,
:
avatar
,
:description
,
:description
,
:lfs_enabled
,
:name
,
:path
,
:path
,
:avatar
,
:visibility_level
,
:request_access_enabled
,
:request_access_enabled
,
:
lfs_enabled
:
visibility_level
)
)
end
end
end
end
app/controllers/groups_controller.rb
View file @
02ddb9df
...
@@ -122,15 +122,15 @@ class GroupsController < Groups::ApplicationController
...
@@ -122,15 +122,15 @@ class GroupsController < Groups::ApplicationController
def
group_params
def
group_params
params
.
require
(
:group
).
permit
(
params
.
require
(
:group
).
permit
(
:
name
,
:
avatar
,
:description
,
:description
,
:lfs_enabled
,
:name
,
:path
,
:path
,
:avatar
,
:public
,
:public
,
:visibility_level
,
:share_with_group_lock
,
:request_access_enabled
,
:request_access_enabled
,
:lfs_enabled
:share_with_group_lock
,
:visibility_level
)
)
end
end
...
...
app/helpers/groups_helper.rb
View file @
02ddb9df
...
@@ -24,19 +24,20 @@ module GroupsHelper
...
@@ -24,19 +24,20 @@ module GroupsHelper
end
end
end
end
def
projects_with_lfs_enabled
(
group
,
status
)
def
projects_lfs_status
(
group
)
if
status
lfs_status
=
lfs_status
=
group
.
projects
.
select
(
&
:lfs_enabled?
).
size
if
group
.
lfs_enabled?
group
.
projects
.
select
(
&
:lfs_enabled?
).
size
else
else
lfs_status
=
group
.
projects
.
select
{
|
p
|
!
p
.
lfs_enabled?
}
.
size
group
.
projects
.
reject
(
&
:lfs_enabled?
)
.
size
end
end
size
=
group
.
projects
.
size
size
=
group
.
projects
.
size
if
lfs_status
==
size
||
lfs_status
==
0
if
lfs_status
==
size
'
on
all projects'
'
for
all projects'
else
else
"
on
#{
lfs_status
}
out of
#{
size
}
projects
"
"
for
#{
lfs_status
}
out of
#{
pluralize
(
size
,
'project'
)
}
"
end
end
end
end
...
@@ -44,7 +45,7 @@ module GroupsHelper
...
@@ -44,7 +45,7 @@ module GroupsHelper
status
=
group
.
lfs_enabled?
?
'enabled'
:
'disabled'
status
=
group
.
lfs_enabled?
?
'enabled'
:
'disabled'
content_tag
(
:span
,
class:
"lfs-
#{
status
}
"
)
do
content_tag
(
:span
,
class:
"lfs-
#{
status
}
"
)
do
"
#{
status
.
humanize
}
#{
projects_
with_lfs_enabled
(
group
,
group
.
lfs_enabled?
)
}
"
"
#{
status
.
humanize
}
#{
projects_
lfs_status
(
group
)
}
"
end
end
end
end
end
end
app/views/admin/groups/_form.html.haml
View file @
02ddb9df
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
.col-sm-offset-2.col-sm-10
.col-sm-offset-2.col-sm-10
=
render
'shared/allow_request_access'
,
form:
f
=
render
'shared/allow_request_access'
,
form:
f
=
render
'
shared/
groups/group_lfs_settings'
,
f:
f
=
render
'groups/group_lfs_settings'
,
f:
f
-
if
@group
.
new_record?
-
if
@group
.
new_record?
.form-group
.form-group
...
...
app/views/
shared/
groups/_group_lfs_settings.html.haml
→
app/views/groups/_group_lfs_settings.html.haml
View file @
02ddb9df
File moved
app/views/groups/edit.html.haml
View file @
02ddb9df
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
.col-sm-offset-2.col-sm-10
.col-sm-offset-2.col-sm-10
=
render
'shared/allow_request_access'
,
form:
f
=
render
'shared/allow_request_access'
,
form:
f
=
render
'
shared/groups/
group_lfs_settings'
,
f:
f
=
render
'group_lfs_settings'
,
f:
f
.form-group
.form-group
%hr
%hr
...
...
doc/api/groups.md
View file @
02ddb9df
...
@@ -288,7 +288,7 @@ Parameters:
...
@@ -288,7 +288,7 @@ Parameters:
-
`path`
(required) - The path of the group
-
`path`
(required) - The path of the group
-
`description`
(optional) - The group's description
-
`description`
(optional) - The group's description
-
`visibility_level`
(optional) - The group's visibility. 0 for private, 10 for internal, 20 for public.
-
`visibility_level`
(optional) - The group's visibility. 0 for private, 10 for internal, 20 for public.
-
`lfs_enabled`
(optional) - Enable/disable L
FS
for the projects in this group
-
`lfs_enabled`
(optional) - Enable/disable L
arge File Storage (LFS)
for the projects in this group
## Transfer project to group
## Transfer project to group
...
@@ -318,7 +318,7 @@ PUT /groups/:id
...
@@ -318,7 +318,7 @@ PUT /groups/:id
|
`path`
| string | no | The path of the group |
|
`path`
| string | no | The path of the group |
|
`description`
| string | no | The description of the group |
|
`description`
| string | no | The description of the group |
|
`visibility_level`
| integer | no | The visibility level of the group. 0 for private, 10 for internal, 20 for public. |
|
`visibility_level`
| integer | no | The visibility level of the group. 0 for private, 10 for internal, 20 for public. |
|
`lfs_enabled`
(optional) | boolean | no | Enable/disable L
FS
for the projects in this group |
|
`lfs_enabled`
(optional) | boolean | no | Enable/disable L
arge File Storage (LFS)
for the projects in this group |
```
bash
```
bash
curl
--request
PUT
--header
"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK"
"https://gitlab.example.com/api/v3/groups/5?name=Experimental"
curl
--request
PUT
--header
"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK"
"https://gitlab.example.com/api/v3/groups/5?name=Experimental"
...
...
lib/api/entities.rb
View file @
02ddb9df
...
@@ -86,7 +86,8 @@ module API
...
@@ -86,7 +86,8 @@ module API
expose
(
:snippets_enabled
)
{
|
project
,
options
|
project
.
feature_available?
(
:snippets
,
options
[
:user
])
}
expose
(
:snippets_enabled
)
{
|
project
,
options
|
project
.
feature_available?
(
:snippets
,
options
[
:user
])
}
expose
:created_at
,
:last_activity_at
expose
:created_at
,
:last_activity_at
expose
:shared_runners_enabled
,
:lfs_enabled
expose
:shared_runners_enabled
expose
:lfs_enabled?
,
as: :lfs_enabled
expose
:creator_id
expose
:creator_id
expose
:namespace
expose
:namespace
expose
:forked_from_project
,
using:
Entities
::
BasicProjectDetails
,
if:
lambda
{
|
project
,
options
|
project
.
forked?
}
expose
:forked_from_project
,
using:
Entities
::
BasicProjectDetails
,
if:
lambda
{
|
project
,
options
|
project
.
forked?
}
...
@@ -120,7 +121,8 @@ module API
...
@@ -120,7 +121,8 @@ module API
end
end
class
Group
<
Grape
::
Entity
class
Group
<
Grape
::
Entity
expose
:id
,
:name
,
:path
,
:description
,
:visibility_level
,
:lfs_enabled
expose
:id
,
:name
,
:path
,
:description
,
:visibility_level
expose
:lfs_enabled?
,
as: :lfs_enabled
expose
:avatar_url
expose
:avatar_url
expose
:web_url
expose
:web_url
end
end
...
...
spec/helpers/groups_helper_spec.rb
View file @
02ddb9df
...
@@ -18,4 +18,67 @@ describe GroupsHelper do
...
@@ -18,4 +18,67 @@ describe GroupsHelper do
expect
(
group_icon
(
group
.
path
)).
to
match
(
'group_avatar.png'
)
expect
(
group_icon
(
group
.
path
)).
to
match
(
'group_avatar.png'
)
end
end
end
end
describe
'group_lfs_status'
do
let
(
:group
)
{
create
(
:group
)
}
let!
(
:project
)
{
create
(
:empty_project
,
namespace_id:
group
.
id
)
}
before
do
allow
(
Gitlab
.
config
.
lfs
).
to
receive
(
:enabled
).
and_return
(
true
)
end
context
'only one project in group'
do
before
do
group
.
update_attribute
(
:lfs_enabled
,
true
)
end
it
'returns all projects as enabled'
do
expect
(
group_lfs_status
(
group
)).
to
include
(
'Enabled for all projects'
)
end
it
'returns all projects as disabled'
do
project
.
update_attribute
(
:lfs_enabled
,
false
)
expect
(
group_lfs_status
(
group
)).
to
include
(
'Enabled for 0 out of 1 project'
)
end
end
context
'more than one project in group'
do
before
do
create
(
:empty_project
,
namespace_id:
group
.
id
)
end
context
'LFS enabled in group'
do
before
do
group
.
update_attribute
(
:lfs_enabled
,
true
)
end
it
'returns both projects as enabled'
do
expect
(
group_lfs_status
(
group
)).
to
include
(
'Enabled for all projects'
)
end
it
'returns only one as enabled'
do
project
.
update_attribute
(
:lfs_enabled
,
false
)
expect
(
group_lfs_status
(
group
)).
to
include
(
'Enabled for 1 out of 2 projects'
)
end
end
context
'LFS disabled in group'
do
before
do
group
.
update_attribute
(
:lfs_enabled
,
false
)
end
it
'returns both projects as disabled'
do
expect
(
group_lfs_status
(
group
)).
to
include
(
'Disabled for all projects'
)
end
it
'returns only one as disabled'
do
project
.
update_attribute
(
:lfs_enabled
,
true
)
expect
(
group_lfs_status
(
group
)).
to
include
(
'Disabled for 1 out of 2 projects'
)
end
end
end
end
end
end
spec/models/group_spec.rb
View file @
02ddb9df
...
@@ -187,6 +187,52 @@ describe Group, models: true do
...
@@ -187,6 +187,52 @@ describe Group, models: true do
it
{
expect
(
group
.
has_master?
(
@members
[
:requester
])).
to
be_falsey
}
it
{
expect
(
group
.
has_master?
(
@members
[
:requester
])).
to
be_falsey
}
end
end
describe
'#lfs_enabled?'
do
context
'LFS enabled globally'
do
before
do
allow
(
Gitlab
.
config
.
lfs
).
to
receive
(
:enabled
).
and_return
(
true
)
end
it
'returns true when nothing is set'
do
expect
(
group
.
lfs_enabled?
).
to
be_truthy
end
it
'returns false when set to false'
do
group
.
update_attribute
(
:lfs_enabled
,
false
)
expect
(
group
.
lfs_enabled?
).
to
be_falsey
end
it
'returns true when set to true'
do
group
.
update_attribute
(
:lfs_enabled
,
true
)
expect
(
group
.
lfs_enabled?
).
to
be_truthy
end
end
context
'LFS disabled globally'
do
before
do
allow
(
Gitlab
.
config
.
lfs
).
to
receive
(
:enabled
).
and_return
(
false
)
end
it
'returns false when nothing is set'
do
expect
(
group
.
lfs_enabled?
).
to
be_falsey
end
it
'returns false when set to false'
do
group
.
update_attribute
(
:lfs_enabled
,
false
)
expect
(
group
.
lfs_enabled?
).
to
be_falsey
end
it
'returns false when set to true'
do
group
.
update_attribute
(
:lfs_enabled
,
true
)
expect
(
group
.
lfs_enabled?
).
to
be_falsey
end
end
end
describe
'#owners'
do
describe
'#owners'
do
let
(
:owner
)
{
create
(
:user
)
}
let
(
:owner
)
{
create
(
:user
)
}
let
(
:developer
)
{
create
(
:user
)
}
let
(
:developer
)
{
create
(
:user
)
}
...
...
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