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
Jérome Perrin
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
Hide 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)
- Add last commit time to repo view (ClemMakesApps)
- Fix accessibility and visibility of project list dropdown button !6140
- 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 group-specific enable/disable setting for LFS !6164
- 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
def
group_params
params
.
require
(
:group
).
permit
(
:
name
,
:
avatar
,
:description
,
:lfs_enabled
,
:name
,
:path
,
:avatar
,
:visibility_level
,
:request_access_enabled
,
:
lfs_enabled
:
visibility_level
)
end
end
app/controllers/groups_controller.rb
View file @
02ddb9df
...
...
@@ -122,15 +122,15 @@ class GroupsController < Groups::ApplicationController
def
group_params
params
.
require
(
:group
).
permit
(
:
name
,
:
avatar
,
:description
,
:lfs_enabled
,
:name
,
:path
,
:avatar
,
:public
,
:visibility_level
,
:share_with_group_lock
,
:request_access_enabled
,
:lfs_enabled
:share_with_group_lock
,
:visibility_level
)
end
...
...
app/helpers/groups_helper.rb
View file @
02ddb9df
...
...
@@ -24,19 +24,20 @@ module GroupsHelper
end
end
def
projects_with_lfs_enabled
(
group
,
status
)
if
status
lfs_status
=
group
.
projects
.
select
(
&
:lfs_enabled?
).
size
else
lfs_status
=
group
.
projects
.
select
{
|
p
|
!
p
.
lfs_enabled?
}.
size
end
def
projects_lfs_status
(
group
)
lfs_status
=
if
group
.
lfs_enabled?
group
.
projects
.
select
(
&
:lfs_enabled?
).
size
else
group
.
projects
.
reject
(
&
:lfs_enabled?
).
size
end
size
=
group
.
projects
.
size
if
lfs_status
==
size
||
lfs_status
==
0
'
on
all projects'
if
lfs_status
==
size
'
for
all projects'
else
"
on
#{
lfs_status
}
out of
#{
size
}
projects
"
"
for
#{
lfs_status
}
out of
#{
pluralize
(
size
,
'project'
)
}
"
end
end
...
...
@@ -44,7 +45,7 @@ module GroupsHelper
status
=
group
.
lfs_enabled?
?
'enabled'
:
'disabled'
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
app/views/admin/groups/_form.html.haml
View file @
02ddb9df
...
...
@@ -13,7 +13,7 @@
.col-sm-offset-2.col-sm-10
=
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?
.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 @@
.col-sm-offset-2.col-sm-10
=
render
'shared/allow_request_access'
,
form:
f
=
render
'
shared/groups/
group_lfs_settings'
,
f:
f
=
render
'group_lfs_settings'
,
f:
f
.form-group
%hr
...
...
doc/api/groups.md
View file @
02ddb9df
...
...
@@ -288,7 +288,7 @@ Parameters:
-
`path`
(required) - The path of the group
-
`description`
(optional) - The group's description
-
`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
...
...
@@ -318,7 +318,7 @@ PUT /groups/:id
|
`path`
| string | no | The path 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. |
|
`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
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
expose
(
:snippets_enabled
)
{
|
project
,
options
|
project
.
feature_available?
(
:snippets
,
options
[
:user
])
}
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
:namespace
expose
:forked_from_project
,
using:
Entities
::
BasicProjectDetails
,
if:
lambda
{
|
project
,
options
|
project
.
forked?
}
...
...
@@ -120,7 +121,8 @@ module API
end
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
:web_url
end
...
...
spec/helpers/groups_helper_spec.rb
View file @
02ddb9df
...
...
@@ -18,4 +18,67 @@ describe GroupsHelper do
expect
(
group_icon
(
group
.
path
)).
to
match
(
'group_avatar.png'
)
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
spec/models/group_spec.rb
View file @
02ddb9df
...
...
@@ -187,6 +187,52 @@ describe Group, models: true do
it
{
expect
(
group
.
has_master?
(
@members
[
:requester
])).
to
be_falsey
}
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
let
(
:owner
)
{
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