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
Boxiang Sun
gitlab-ce
Commits
77a6ec22
Commit
77a6ec22
authored
Jul 25, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle maximum pages artifacts size correctly
parent
d95e6da0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
1 deletion
+75
-1
app/services/projects/update_pages_service.rb
app/services/projects/update_pages_service.rb
+3
-1
spec/services/projects/update_pages_service_spec.rb
spec/services/projects/update_pages_service_spec.rb
+72
-0
No files found.
app/services/projects/update_pages_service.rb
View file @
77a6ec22
...
...
@@ -130,7 +130,9 @@ module Projects
end
def
max_size
current_application_settings
.
max_pages_size
.
megabytes
||
MAX_SIZE
current_application_settings
.
max_pages_size
.
megabytes
.
tap
do
|
maximum
|
return
MAX_SIZE
if
maximum
.
zero?
||
maximum
>
MAX_SIZE
end
end
def
tmp_path
...
...
spec/services/projects/update_pages_service_spec.rb
View file @
77a6ec22
...
...
@@ -96,6 +96,78 @@ describe Projects::UpdatePagesService do
expect
(
execute
).
not_to
eq
(
:success
)
end
describe
'maximum pages artifacts size'
do
let
(
:metadata
)
{
spy
(
'metadata'
)
}
before
do
file
=
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/pages.zip'
)
metafile
=
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/pages.zip.meta'
)
build
.
update_attributes
(
artifacts_file:
file
)
build
.
update_attributes
(
artifacts_metadata:
metafile
)
allow
(
build
).
to
receive
(
:artifacts_metadata_entry
)
.
and_return
(
metadata
)
end
shared_examples
'pages size limit exceeded'
do
it
'limits the maximum size of gitlab pages'
do
subject
.
execute
expect
(
deploy_status
.
description
)
.
to
match
(
/artifacts for pages are too large/
)
end
end
context
'when maximum pages size is set to zero'
do
before
do
stub_application_setting
(
max_pages_size:
0
)
end
context
'when page size does not exceed internal maximum'
do
before
do
allow
(
metadata
).
to
receive
(
:total_size
).
and_return
(
200
.
megabytes
)
end
it
'updates pages correctly'
do
subject
.
execute
expect
(
deploy_status
.
description
).
not_to
be_present
end
end
context
'when pages size does exceed internal maximum'
do
before
do
allow
(
metadata
).
to
receive
(
:total_size
).
and_return
(
2
.
terabytes
)
end
it_behaves_like
'pages size limit exceeded'
end
end
context
'when pages size is greater than max size setting'
do
before
do
stub_application_setting
(
max_pages_size:
200
)
allow
(
metadata
).
to
receive
(
:total_size
).
and_return
(
201
.
megabytes
)
end
it_behaves_like
'pages size limit exceeded'
end
context
'when max size setting is greater than internal max size'
do
before
do
stub_application_setting
(
max_pages_size:
3
.
terabytes
/
1
.
megabyte
)
allow
(
metadata
).
to
receive
(
:total_size
).
and_return
(
2
.
terabytes
)
end
it_behaves_like
'pages size limit exceeded'
end
end
def
deploy_status
GenericCommitStatus
.
find_by
(
name:
'pages:deploy'
);
end
def
execute
subject
.
execute
[
:status
]
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