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
930b098c
Commit
930b098c
authored
Jan 19, 2017
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Save repository size limit as Bytes before saving it
parent
3b8daba1
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
107 additions
and
0 deletions
+107
-0
app/models/application_setting.rb
app/models/application_setting.rb
+1
-0
app/models/concerns/repository_size_limit.rb
app/models/concerns/repository_size_limit.rb
+13
-0
app/models/group.rb
app/models/group.rb
+1
-0
app/models/project.rb
app/models/project.rb
+1
-0
spec/models/concerns/repository_size_limit_spec.rb
spec/models/concerns/repository_size_limit_spec.rb
+91
-0
No files found.
app/models/application_setting.rb
View file @
930b098c
...
@@ -2,6 +2,7 @@ class ApplicationSetting < ActiveRecord::Base
...
@@ -2,6 +2,7 @@ class ApplicationSetting < ActiveRecord::Base
include
CacheMarkdownField
include
CacheMarkdownField
include
TokenAuthenticatable
include
TokenAuthenticatable
prepend
EE
::
ApplicationSetting
prepend
EE
::
ApplicationSetting
include
RepositorySizeLimit
add_authentication_token_field
:runners_registration_token
add_authentication_token_field
:runners_registration_token
add_authentication_token_field
:health_check_access_token
add_authentication_token_field
:health_check_access_token
...
...
app/models/concerns/repository_size_limit.rb
0 → 100644
View file @
930b098c
module
RepositorySizeLimit
extend
ActiveSupport
::
Concern
included
do
before_save
:convert_from_megabytes_to_bytes
,
if: :repository_size_limit_changed?
end
private
def
convert_from_megabytes_to_bytes
self
.
repository_size_limit
=
(
repository_size_limit
*
1
.
megabyte
)
if
repository_size_limit
.
present?
end
end
app/models/group.rb
View file @
930b098c
...
@@ -9,6 +9,7 @@ class Group < Namespace
...
@@ -9,6 +9,7 @@ class Group < Namespace
include
AccessRequestable
include
AccessRequestable
include
Referable
include
Referable
include
SelectForProjectAuthorization
include
SelectForProjectAuthorization
include
RepositorySizeLimit
prepend
EE
::
GeoAwareAvatar
prepend
EE
::
GeoAwareAvatar
has_many
:group_members
,
->
{
where
(
requested_at:
nil
)
},
dependent: :destroy
,
as: :source
has_many
:group_members
,
->
{
where
(
requested_at:
nil
)
},
dependent: :destroy
,
as: :source
...
...
app/models/project.rb
View file @
930b098c
...
@@ -17,6 +17,7 @@ class Project < ActiveRecord::Base
...
@@ -17,6 +17,7 @@ class Project < ActiveRecord::Base
include
ProjectFeaturesCompatibility
include
ProjectFeaturesCompatibility
include
SelectForProjectAuthorization
include
SelectForProjectAuthorization
include
Routable
include
Routable
include
RepositorySizeLimit
prepend
EE
::
GeoAwareAvatar
prepend
EE
::
GeoAwareAvatar
prepend
EE
::
Project
prepend
EE
::
Project
...
...
spec/models/concerns/repository_size_limit_spec.rb
0 → 100644
View file @
930b098c
require
'spec_helper'
describe
RepositorySizeLimit
do
context
Project
do
context
'callback'
do
describe
'#convert_from_megabyte_to_byte'
do
let
(
:project
)
{
build
(
:empty_project
,
repository_size_limit:
10
)
}
before
do
project
.
update!
(
repository_size_limit:
repository_size_limit
)
project
.
reload
end
context
'when repository_size_limit is present and have changed'
do
let
(
:repository_size_limit
)
{
20
}
it
{
expect
(
project
.
repository_size_limit
).
to
eql
(
20
*
1
.
megabyte
)
}
end
context
'when repository_size_limit is present but have not changed'
do
let
(
:repository_size_limit
)
{
10
}
it
{
expect
(
project
.
repository_size_limit
).
to
eql
(
10
*
1
.
megabyte
)
}
end
context
'when repository_size_limit is not present'
do
let
(
:repository_size_limit
)
{
nil
}
it
{
expect
(
project
.
repository_size_limit
).
to
be_nil
}
end
end
end
end
context
Group
do
context
'callback'
do
describe
'#convert_from_megabyte_to_byte'
do
let
(
:group
)
{
build
(
:group
,
repository_size_limit:
10
)
}
before
do
group
.
update!
(
repository_size_limit:
repository_size_limit
)
group
.
reload
end
context
'when repository_size_limit is present and have changed'
do
let
(
:repository_size_limit
)
{
20
}
it
{
expect
(
group
.
repository_size_limit
).
to
eql
(
20
*
1
.
megabyte
)
}
end
context
'when repository_size_limit is present but have not changed'
do
let
(
:repository_size_limit
)
{
10
}
it
{
expect
(
group
.
repository_size_limit
).
to
eql
(
10
*
1
.
megabyte
)
}
end
context
'when repository_size_limit is not present'
do
let
(
:repository_size_limit
)
{
nil
}
it
{
expect
(
group
.
repository_size_limit
).
to
be_nil
}
end
end
end
end
context
ApplicationSetting
do
context
'callback'
do
describe
'#convert_from_megabyte_to_byte'
do
let
(
:setting
)
{
ApplicationSetting
.
create_from_defaults
}
before
do
setting
.
update!
(
repository_size_limit:
10
)
setting
.
update!
(
repository_size_limit:
repository_size_limit
)
setting
.
reload
end
context
'when repository_size_limit is present and have changed'
do
let
(
:repository_size_limit
)
{
20
}
it
{
expect
(
setting
.
repository_size_limit
).
to
eql
(
20
*
1
.
megabyte
)
}
end
context
'when repository_size_limit is present but have not changed'
do
let
(
:repository_size_limit
)
{
10
}
it
{
expect
(
setting
.
repository_size_limit
).
to
eql
(
10
*
1
.
megabyte
)
}
end
end
end
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