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
c8861da7
Commit
c8861da7
authored
Aug 30, 2016
by
Tomasz Maczukin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update specs - add mocks to simulate old versions
parent
e2e8ec60
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
133 additions
and
119 deletions
+133
-119
app/controllers/application_controller.rb
app/controllers/application_controller.rb
+0
-4
app/controllers/projects/builds_controller.rb
app/controllers/projects/builds_controller.rb
+2
-2
app/models/ci/build.rb
app/models/ci/build.rb
+9
-1
public/410.html
public/410.html
+0
-65
spec/features/projects/builds_spec.rb
spec/features/projects/builds_spec.rb
+90
-24
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+32
-23
No files found.
app/controllers/application_controller.rb
View file @
c8861da7
...
...
@@ -117,10 +117,6 @@ class ApplicationController < ActionController::Base
render
file:
Rails
.
root
.
join
(
"public"
,
"404"
),
layout:
false
,
status:
"404"
end
def
render_410
render
file:
Rails
.
root
.
join
(
"public"
,
"410"
),
layout:
false
,
status:
"410"
end
def
no_cache_headers
response
.
headers
[
"Cache-Control"
]
=
"no-cache, no-store, max-age=0, must-revalidate"
response
.
headers
[
"Pragma"
]
=
"no-cache"
...
...
app/controllers/projects/builds_controller.rb
View file @
c8861da7
...
...
@@ -79,9 +79,9 @@ class Projects::BuildsController < Projects::ApplicationController
def
raw
if
@build
.
has_trace_file?
send_file
@build
.
path_to_trace
,
type:
'text/plain; charset=utf-8'
,
disposition:
'inline'
send_file
@build
.
trace_file_path
,
type:
'text/plain; charset=utf-8'
,
disposition:
'inline'
else
render_4
10
render_4
04
end
end
...
...
app/models/ci/build.rb
View file @
c8861da7
...
...
@@ -217,7 +217,7 @@ module Ci
end
def
raw_trace
if
File
.
file
?
(
path_to_trace
)
if
File
.
exist
?
(
path_to_trace
)
File
.
read
(
path_to_trace
)
elsif
has_old_trace_file?
# Temporary fix for build trace data integrity
...
...
@@ -274,6 +274,14 @@ module Ci
end
end
def
trace_file_path
if
has_old_trace_file?
old_path_to_trace
else
path_to_trace
end
end
def
dir_to_trace
File
.
join
(
Settings
.
gitlab_ci
.
builds_path
,
...
...
public/410.html
deleted
100644 → 0
View file @
e2e8ec60
<!DOCTYPE html>
<html>
<head>
<meta
content=
"width=device-width, initial-scale=1, maximum-scale=1"
name=
"viewport"
>
<title>
The page you're looking for is gone (410)
</title>
<style>
body
{
color
:
#666
;
text-align
:
center
;
font-family
:
"Helvetica Neue"
,
Helvetica
,
Arial
,
sans-serif
;
margin
:
auto
;
font-size
:
14px
;
}
h1
{
font-size
:
56px
;
line-height
:
100px
;
font-weight
:
normal
;
color
:
#456
;
}
h2
{
font-size
:
24px
;
color
:
#666
;
line-height
:
1.5em
;
}
h3
{
color
:
#456
;
font-size
:
20px
;
font-weight
:
normal
;
line-height
:
28px
;
}
hr
{
max-width
:
800px
;
margin
:
18px
auto
;
border
:
0
;
border-top
:
1px
solid
#EEE
;
border-bottom
:
1px
solid
white
;
}
img
{
max-width
:
40vw
;
}
.container
{
margin
:
auto
20px
;
}
</style>
</head>
<body>
<h1>
<img
src=
"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEwIiBoZWlnaHQ9IjIxMCIgdmlld0JveD0iMCAwIDIxMCAyMTAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgPHBhdGggZD0iTTEwNS4wNjE0IDIwMy42NTVsMzguNjQtMTE4LjkyMWgtNzcuMjhsMzguNjQgMTE4LjkyMXoiIGZpbGw9IiNlMjQzMjkiLz4KICA8cGF0aCBkPSJNMTA1LjA2MTQgMjAzLjY1NDhsLTM4LjY0LTExOC45MjFoLTU0LjE1M2w5Mi43OTMgMTE4LjkyMXoiIGZpbGw9IiNmYzZkMjYiLz4KICA8cGF0aCBkPSJNMTIuMjY4NSA4NC43MzQxbC0xMS43NDIgMzYuMTM5Yy0xLjA3MSAzLjI5Ni4xMDIgNi45MDcgMi45MDYgOC45NDRsMTAxLjYyOSA3My44MzgtOTIuNzkzLTExOC45MjF6IiBmaWxsPSIjZmNhMzI2Ii8+CiAgPHBhdGggZD0iTTEyLjI2ODUgODQuNzM0Mmg1NC4xNTNsLTIzLjI3My03MS42MjVjLTEuMTk3LTMuNjg2LTYuNDExLTMuNjg1LTcuNjA4IDBsLTIzLjI3MiA3MS42MjV6IiBmaWxsPSIjZTI0MzI5Ii8+CiAgPHBhdGggZD0iTTEwNS4wNjE0IDIwMy42NTQ4bDM4LjY0LTExOC45MjFoNTQuMTUzbC05Mi43OTMgMTE4LjkyMXoiIGZpbGw9IiNmYzZkMjYiLz4KICA8cGF0aCBkPSJNMTk3Ljg1NDQgODQuNzM0MWwxMS43NDIgMzYuMTM5YzEuMDcxIDMuMjk2LS4xMDIgNi45MDctMi45MDYgOC45NDRsLTEwMS42MjkgNzMuODM4IDkyLjc5My0xMTguOTIxeiIgZmlsbD0iI2ZjYTMyNiIvPgogIDxwYXRoIGQ9Ik0xOTcuODU0NCA4NC43MzQyaC01NC4xNTNsMjMuMjczLTcxLjYyNWMxLjE5Ny0zLjY4NiA2LjQxMS0zLjY4NSA3LjYwOCAwbDIzLjI3MiA3MS42MjV6IiBmaWxsPSIjZTI0MzI5Ii8+Cjwvc3ZnPgo="
alt=
"GitLab Logo"
/><br
/>
410
</h1>
<div
class=
"container"
>
<h3>
The page you're looking for is gone.
</h3>
<hr
/>
<p>
Make sure the address is correct and that the page hasn't moved.
</p>
<p>
Please contact your GitLab administrator if you think this is a mistake.
</p>
</div>
</body>
</html>
spec/features/projects/builds_spec.rb
View file @
c8861da7
require
'spec_helper'
require
'tempfile'
describe
"Builds"
do
let
(
:artifacts_file
)
{
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/banana_sample.gif'
,
'image/gif'
)
}
...
...
@@ -6,7 +7,7 @@ describe "Builds" do
before
do
login_as
(
:user
)
@commit
=
FactoryGirl
.
create
:ci_pipeline
@build
=
FactoryGirl
.
create
:ci_build
,
pipeline:
@commit
@build
=
FactoryGirl
.
create
:ci_build
,
:trace
,
pipeline:
@commit
@build2
=
FactoryGirl
.
create
:ci_build
@project
=
@commit
.
project
@project
.
team
<<
[
@user
,
:developer
]
...
...
@@ -156,7 +157,6 @@ describe "Builds" do
context
'Build raw trace'
do
before
do
@build
.
run!
@build
.
trace
=
'BUILD TRACE'
visit
namespace_project_build_path
(
@project
.
namespace
,
@project
,
@build
)
end
...
...
@@ -255,35 +255,101 @@ describe "Builds" do
end
end
describe
"GET /:project/builds/:id/raw"
do
context
"Build from project"
do
before
do
Capybara
.
current_session
.
driver
.
header
(
'X-Sendfile-Type'
,
'X-Sendfile'
)
@build
.
run!
@build
.
trace
=
'BUILD TRACE'
visit
namespace_project_build_path
(
@project
.
namespace
,
@project
,
@build
)
page
.
within
(
'.js-build-sidebar'
)
{
click_link
'Raw'
}
describe
'GET /:project/builds/:id/raw'
do
context
'access source'
do
context
'build from project'
do
before
do
Capybara
.
current_session
.
driver
.
header
(
'X-Sendfile-Type'
,
'X-Sendfile'
)
@build
.
run!
visit
namespace_project_build_path
(
@project
.
namespace
,
@project
,
@build
)
page
.
within
(
'.js-build-sidebar'
)
{
click_link
'Raw'
}
end
it
'sends the right headers'
do
expect
(
page
.
status_code
).
to
eq
(
200
)
expect
(
page
.
response_headers
[
'Content-Type'
]).
to
eq
(
'text/plain; charset=utf-8'
)
expect
(
page
.
response_headers
[
'X-Sendfile'
]).
to
eq
(
@build
.
path_to_trace
)
end
end
it
'sends the right headers'
do
expect
(
page
.
status_code
).
to
eq
(
200
)
expect
(
page
.
response_headers
[
'Content-Type'
]).
to
eq
(
'text/plain; charset=utf-8'
)
expect
(
page
.
response_headers
[
'X-Sendfile'
]).
to
eq
(
@build
.
path_to_trace
)
context
'build from other project'
do
before
do
Capybara
.
current_session
.
driver
.
header
(
'X-Sendfile-Type'
,
'X-Sendfile'
)
@build2
.
run!
visit
raw_namespace_project_build_path
(
@project
.
namespace
,
@project
,
@build2
)
end
it
'sends the right headers'
do
expect
(
page
.
status_code
).
to
eq
(
404
)
end
end
end
context
"Build from other project"
do
before
do
Capybara
.
current_session
.
driver
.
header
(
'X-Sendfile-Type'
,
'X-Sendfile'
)
@build2
.
run!
@build2
.
trace
=
'BUILD TRACE'
visit
raw_namespace_project_build_path
(
@project
.
namespace
,
@project
,
@build2
)
puts
page
.
status_code
puts
current_url
context
'storage form'
do
let
(
:existing_file
)
{
Tempfile
.
new
(
'existing-trace-file'
).
path
}
let
(
:non_existing_file
)
do
file
=
Tempfile
.
new
(
'non-existing-trace-file'
)
path
=
file
.
path
file
.
unlink
path
end
it
'sends the right headers'
do
expect
(
page
.
status_code
).
to
eq
(
404
)
context
'when build has trace in file'
do
before
do
Capybara
.
current_session
.
driver
.
header
(
'X-Sendfile-Type'
,
'X-Sendfile'
)
@build
.
run!
visit
namespace_project_build_path
(
@project
.
namespace
,
@project
,
@build
)
allow_any_instance_of
(
Project
).
to
receive
(
:ci_id
).
and_return
(
nil
)
allow_any_instance_of
(
Ci
::
Build
).
to
receive
(
:path_to_trace
).
and_return
(
existing_file
)
allow_any_instance_of
(
Ci
::
Build
).
to
receive
(
:old_path_to_trace
).
and_return
(
non_existing_file
)
page
.
within
(
'.js-build-sidebar'
)
{
click_link
'Raw'
}
end
it
'sends the right headers'
do
expect
(
page
.
status_code
).
to
eq
(
200
)
expect
(
page
.
response_headers
[
'Content-Type'
]).
to
eq
(
'text/plain; charset=utf-8'
)
expect
(
page
.
response_headers
[
'X-Sendfile'
]).
to
eq
(
existing_file
)
end
end
context
'when build has trace in old file'
do
before
do
Capybara
.
current_session
.
driver
.
header
(
'X-Sendfile-Type'
,
'X-Sendfile'
)
@build
.
run!
visit
namespace_project_build_path
(
@project
.
namespace
,
@project
,
@build
)
allow_any_instance_of
(
Project
).
to
receive
(
:ci_id
).
and_return
(
999
)
allow_any_instance_of
(
Ci
::
Build
).
to
receive
(
:path_to_trace
).
and_return
(
non_existing_file
)
allow_any_instance_of
(
Ci
::
Build
).
to
receive
(
:old_path_to_trace
).
and_return
(
existing_file
)
page
.
within
(
'.js-build-sidebar'
)
{
click_link
'Raw'
}
end
it
'sends the right headers'
do
expect
(
page
.
status_code
).
to
eq
(
200
)
expect
(
page
.
response_headers
[
'Content-Type'
]).
to
eq
(
'text/plain; charset=utf-8'
)
expect
(
page
.
response_headers
[
'X-Sendfile'
]).
to
eq
(
existing_file
)
end
end
context
'when build has trace in DB'
do
before
do
Capybara
.
current_session
.
driver
.
header
(
'X-Sendfile-Type'
,
'X-Sendfile'
)
@build
.
run!
visit
namespace_project_build_path
(
@project
.
namespace
,
@project
,
@build
)
allow_any_instance_of
(
Project
).
to
receive
(
:ci_id
).
and_return
(
nil
)
allow_any_instance_of
(
Ci
::
Build
).
to
receive
(
:path_to_trace
).
and_return
(
non_existing_file
)
allow_any_instance_of
(
Ci
::
Build
).
to
receive
(
:old_path_to_trace
).
and_return
(
non_existing_file
)
page
.
within
(
'.js-build-sidebar'
)
{
click_link
'Raw'
}
end
it
'sends the right headers'
do
expect
(
page
.
status_code
).
to
eq
(
404
)
end
end
end
end
...
...
spec/models/ci/build_spec.rb
View file @
c8861da7
...
...
@@ -28,41 +28,30 @@ describe Ci::Build, models: true do
context
'when there is a trace'
do
context
'when trace is stored in file'
do
before
do
build
.
trace
=
test_trace
build
.
save
end
let
(
:build_with_trace
)
{
create
(
:ci_build
,
:trace
)
}
it
{
expect
(
build
.
has_trace_file?
).
to
be_truthy
}
it
{
expect
(
build
.
trace
).
to
eq
(
test_trace
)
}
it
{
expect
(
build
_with_trace
.
has_trace_file?
).
to
be_truthy
}
it
{
expect
(
build
_with_trace
.
trace
).
to
eq
(
'BUILD TRACE'
)
}
end
context
'when trace is stored in old file'
do
before
do
build
.
trace
=
test_trace
build
.
save
build
.
project
.
ci_id
=
999
build
.
project
.
save
FileUtils
.
mkdir_p
(
build
.
old_dir_to_trace
)
FileUtils
.
mv
(
build
.
path_to_trace
,
build
.
old_path_to_trace
)
allow
(
build
.
project
).
to
receive
(
:ci_id
).
and_return
(
999
)
allow
(
File
).
to
receive
(
:exist?
).
with
(
build
.
path_to_trace
).
and_return
(
false
)
allow
(
File
).
to
receive
(
:exist?
).
with
(
build
.
old_path_to_trace
).
and_return
(
true
)
allow
(
File
).
to
receive
(
:read
).
with
(
build
.
old_path_to_trace
).
and_return
(
test_trace
)
end
it
{
expect
(
build
.
has_trace_file?
).
to
be_truthy
}
it
{
expect
(
build
.
trace
).
to
eq
(
test_trace
)
}
end
context
'when there is stored in DB'
do
class
Ci::Build
def
write_db_trace
=
(
trace
)
write_attribute
:trace
,
trace
end
end
context
'when trace is stored in DB'
do
before
do
build
.
write_db_trace
=
test_trace
build
.
save
allow
(
build
.
project
).
to
receive
(
:ci_id
).
and_return
(
nil
)
allow
(
build
).
to
receive
(
:read_attribute
).
with
(
:trace
).
and_return
(
test_trace
)
allow
(
File
).
to
receive
(
:exist?
).
with
(
build
.
path_to_trace
).
and_return
(
false
)
allow
(
File
).
to
receive
(
:exist?
).
with
(
build
.
old_path_to_trace
).
and_return
(
false
)
end
it
{
expect
(
build
.
has_trace_file?
).
to
be_falsey
}
...
...
@@ -70,4 +59,24 @@ describe Ci::Build, models: true do
end
end
end
describe
'#trace_file_path'
do
context
'when trace is stored in file'
do
before
do
allow
(
build
).
to
receive
(
:has_trace_file?
).
and_return
(
true
)
allow
(
build
).
to
receive
(
:has_old_trace_file?
).
and_return
(
false
)
end
it
{
expect
(
build
.
trace_file_path
).
to
eq
(
build
.
path_to_trace
)
}
end
context
'when trace is stored in old file'
do
before
do
allow
(
build
).
to
receive
(
:has_trace_file?
).
and_return
(
true
)
allow
(
build
).
to
receive
(
:has_old_trace_file?
).
and_return
(
true
)
end
it
{
expect
(
build
.
trace_file_path
).
to
eq
(
build
.
old_path_to_trace
)
}
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