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
36259857
Commit
36259857
authored
Jul 03, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
209b0cef
e555db6f
Changes
34
Hide whitespace changes
Inline
Side-by-side
Showing
34 changed files
with
302 additions
and
356 deletions
+302
-356
app/assets/javascripts/performance_bar/components/performance_bar_app.vue
...cripts/performance_bar/components/performance_bar_app.vue
+6
-9
app/assets/javascripts/performance_bar/components/simple_metric.vue
.../javascripts/performance_bar/components/simple_metric.vue
+0
-33
app/assets/javascripts/releases/components/release_block.vue
app/assets/javascripts/releases/components/release_block.vue
+4
-4
app/models/release.rb
app/models/release.rb
+9
-1
app/services/releases/concerns.rb
app/services/releases/concerns.rb
+4
-0
app/services/releases/create_service.rb
app/services/releases/create_service.rb
+1
-0
changelogs/unreleased/pre-releases-38105a.yml
changelogs/unreleased/pre-releases-38105a.yml
+5
-0
changelogs/unreleased/sh-improve-redis-peek.yml
changelogs/unreleased/sh-improve-redis-peek.yml
+5
-0
db/migrate/20190628185000_add_released_at_to_releases_table.rb
...grate/20190628185000_add_released_at_to_releases_table.rb
+11
-0
db/migrate/20190628185004_backfill_and_add_not_null_constraint_to_released_at_column_on_releases_table.rb
...ull_constraint_to_released_at_column_on_releases_table.rb
+18
-0
db/post_migrate/20180202111106_remove_project_labels_group_id.rb
..._migrate/20180202111106_remove_project_labels_group_id.rb
+0
-19
db/schema.rb
db/schema.rb
+2
-1
lib/api/entities.rb
lib/api/entities.rb
+2
-0
lib/api/releases.rb
lib/api/releases.rb
+2
-0
lib/gitlab/background_migration/migrate_system_uploads_to_new_folder.rb
...kground_migration/migrate_system_uploads_to_new_folder.rb
+0
-29
lib/gitlab/background_migration/move_personal_snippet_files.rb
...itlab/background_migration/move_personal_snippet_files.rb
+0
-82
lib/gitlab/legacy_github_import/release_formatter.rb
lib/gitlab/legacy_github_import/release_formatter.rb
+1
-0
lib/peek/views/redis.rb
lib/peek/views/redis.rb
+82
-0
spec/factories/releases.rb
spec/factories/releases.rb
+1
-0
spec/features/projects/releases/user_views_releases_spec.rb
spec/features/projects/releases/user_views_releases_spec.rb
+12
-0
spec/finders/releases_finder_spec.rb
spec/finders/releases_finder_spec.rb
+3
-3
spec/fixtures/api/schemas/public_api/v4/release.json
spec/fixtures/api/schemas/public_api/v4/release.json
+3
-1
spec/fixtures/api/schemas/public_api/v4/release/release_for_guest.json
.../api/schemas/public_api/v4/release/release_for_guest.json
+3
-1
spec/javascripts/performance_bar/components/simple_metric_spec.js
...ascripts/performance_bar/components/simple_metric_spec.js
+0
-47
spec/javascripts/releases/components/release_block_spec.js
spec/javascripts/releases/components/release_block_spec.js
+6
-6
spec/lib/gitlab/background_migration/migrate_system_uploads_to_new_folder_spec.rb
...nd_migration/migrate_system_uploads_to_new_folder_spec.rb
+0
-21
spec/lib/gitlab/background_migration/move_personal_snippet_files_spec.rb
.../background_migration/move_personal_snippet_files_spec.rb
+0
-74
spec/lib/gitlab/import_export/safe_model_attributes.yml
spec/lib/gitlab/import_export/safe_model_attributes.yml
+1
-0
spec/lib/gitlab/legacy_github_import/importer_spec.rb
spec/lib/gitlab/legacy_github_import/importer_spec.rb
+2
-0
spec/lib/gitlab/legacy_github_import/release_formatter_spec.rb
...lib/gitlab/legacy_github_import/release_formatter_spec.rb
+3
-1
spec/migrations/backfill_and_add_not_null_constraint_to_released_at_column_on_releases_table_spec.rb
...onstraint_to_released_at_column_on_releases_table_spec.rb
+28
-0
spec/migrations/remove_project_labels_group_id_spec.rb
spec/migrations/remove_project_labels_group_id_spec.rb
+0
-21
spec/models/release_spec.rb
spec/models/release_spec.rb
+10
-0
spec/requests/api/releases_spec.rb
spec/requests/api/releases_spec.rb
+78
-3
No files found.
app/assets/javascripts/performance_bar/components/performance_bar_app.vue
View file @
36259857
...
...
@@ -4,14 +4,12 @@ import { glEmojiTag } from '~/emoji';
import
detailedMetric
from
'
./detailed_metric.vue
'
;
import
requestSelector
from
'
./request_selector.vue
'
;
import
simpleMetric
from
'
./simple_metric.vue
'
;
import
{
s__
}
from
'
~/locale
'
;
export
default
{
components
:
{
detailedMetric
,
requestSelector
,
simpleMetric
,
},
props
:
{
store
:
{
...
...
@@ -43,8 +41,13 @@ export default {
details
:
'
details
'
,
keys
:
[
'
feature
'
,
'
request
'
],
},
{
metric
:
'
redis
'
,
header
:
'
Redis calls
'
,
details
:
'
details
'
,
keys
:
[
'
cmd
'
],
},
],
simpleMetrics
:
[
'
redis
'
],
data
()
{
return
{
currentRequestId
:
''
};
},
...
...
@@ -124,12 +127,6 @@ export default {
</button>
<a
v-else
:href=
"profileUrl"
>
{{
s__
(
'
PerformanceBar|profile
'
)
}}
</a>
</div>
<simple-metric
v-for=
"metric in $options.simpleMetrics"
:key=
"metric"
:current-request=
"currentRequest"
:metric=
"metric"
/>
<div
id=
"peek-view-gc"
class=
"view"
>
<span
v-if=
"currentRequest.details"
class=
"bold"
>
<span
title=
"Invoke Time"
>
{{
currentRequest
.
details
.
gc
.
gc_time
}}
</span
...
...
app/assets/javascripts/performance_bar/components/simple_metric.vue
deleted
100644 → 0
View file @
209b0cef
<
script
>
export
default
{
props
:
{
currentRequest
:
{
type
:
Object
,
required
:
true
,
},
metric
:
{
type
:
String
,
required
:
true
,
},
},
computed
:
{
duration
()
{
return
(
this
.
currentRequest
.
details
[
this
.
metric
]
&&
this
.
currentRequest
.
details
[
this
.
metric
].
duration
);
},
calls
()
{
return
(
this
.
currentRequest
.
details
[
this
.
metric
]
&&
this
.
currentRequest
.
details
[
this
.
metric
].
calls
);
},
},
};
</
script
>
<
template
>
<div
:id=
"`peek-view-$
{metric}`" class="view">
<span
v-if=
"currentRequest.details"
class=
"bold"
>
{{
duration
}}
/
{{
calls
}}
</span>
{{
metric
}}
</div>
</
template
>
app/assets/javascripts/releases/components/release_block.vue
View file @
36259857
...
...
@@ -28,7 +28,7 @@ export default {
computed
:
{
releasedTimeAgo
()
{
return
sprintf
(
__
(
'
released %{time}
'
),
{
time
:
this
.
timeFormated
(
this
.
release
.
creat
ed_at
),
time
:
this
.
timeFormated
(
this
.
release
.
releas
ed_at
),
});
},
userImageAltDescription
()
{
...
...
@@ -56,8 +56,8 @@ export default {
<div
class=
"card-body"
>
<h2
class=
"card-title mt-0"
>
{{
release
.
name
}}
<gl-badge
v-if=
"release.
pre
_release"
variant=
"warning"
class=
"align-middle"
>
{{
__
(
'
Pre-r
elease
'
)
<gl-badge
v-if=
"release.
upcoming
_release"
variant=
"warning"
class=
"align-middle"
>
{{
__
(
'
Upcoming R
elease
'
)
}}
</gl-badge>
</h2>
...
...
@@ -74,7 +74,7 @@ export default {
<div
class=
"append-right-4"
>
•
<span
v-gl-tooltip
.
bottom
:title=
"tooltipTitle(release.
creat
ed_at)"
>
<span
v-gl-tooltip
.
bottom
:title=
"tooltipTitle(release.
releas
ed_at)"
>
{{
releasedTimeAgo
}}
</span>
</div>
...
...
app/models/release.rb
View file @
36259857
...
...
@@ -12,12 +12,16 @@ class Release < ApplicationRecord
has_many
:links
,
class_name:
'Releases::Link'
default_value_for
:released_at
,
allows_nil:
false
do
Time
.
zone
.
now
end
accepts_nested_attributes_for
:links
,
allow_destroy:
true
validates
:description
,
:project
,
:tag
,
presence:
true
validates
:name
,
presence:
true
,
on: :create
scope
:sorted
,
->
{
order
(
creat
ed_at: :desc
)
}
scope
:sorted
,
->
{
order
(
releas
ed_at: :desc
)
}
delegate
:repository
,
to: :project
...
...
@@ -44,6 +48,10 @@ class Release < ApplicationRecord
end
end
def
upcoming_release?
released_at
.
present?
&&
released_at
>
Time
.
zone
.
now
end
private
def
actual_sha
...
...
app/services/releases/concerns.rb
View file @
36259857
...
...
@@ -22,6 +22,10 @@ module Releases
params
[
:description
]
end
def
released_at
params
[
:released_at
]
end
def
release
strong_memoize
(
:release
)
do
project
.
releases
.
find_by_tag
(
tag_name
)
...
...
app/services/releases/create_service.rb
View file @
36259857
...
...
@@ -58,6 +58,7 @@ module Releases
author:
current_user
,
tag:
tag
.
name
,
sha:
tag
.
dereferenced_target
.
sha
,
released_at:
released_at
,
links_attributes:
params
.
dig
(
:assets
,
'links'
)
||
[]
)
end
...
...
changelogs/unreleased/pre-releases-38105a.yml
0 → 100644
View file @
36259857
---
title
:
Show an Upcoming Status for Releases
merge_request
:
29577
author
:
type
:
added
changelogs/unreleased/sh-improve-redis-peek.yml
0 → 100644
View file @
36259857
---
title
:
Add Redis call details in Peek performance bar
merge_request
:
30191
author
:
type
:
changed
db/migrate/20190628185000_add_released_at_to_releases_table.rb
0 → 100644
View file @
36259857
# frozen_string_literal: true
class
AddReleasedAtToReleasesTable
<
ActiveRecord
::
Migration
[
5.1
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
def
change
add_column
(
:releases
,
:released_at
,
:datetime_with_timezone
)
end
end
db/migrate/20190628185004_backfill_and_add_not_null_constraint_to_released_at_column_on_releases_table.rb
0 → 100644
View file @
36259857
# frozen_string_literal: true
class
BackfillAndAddNotNullConstraintToReleasedAtColumnOnReleasesTable
<
ActiveRecord
::
Migration
[
5.1
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
up
update_column_in_batches
(
:releases
,
:released_at
,
Arel
.
sql
(
'created_at'
))
change_column_null
(
:releases
,
:released_at
,
false
)
end
def
down
change_column_null
(
:releases
,
:released_at
,
true
)
end
end
db/post_migrate/20180202111106_remove_project_labels_group_id.rb
deleted
100644 → 0
View file @
209b0cef
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class
RemoveProjectLabelsGroupId
<
ActiveRecord
::
Migration
[
4.2
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
up
update_column_in_batches
(
:labels
,
:group_id
,
nil
)
do
|
table
,
query
|
query
.
where
(
table
[
:type
].
eq
(
'ProjectLabel'
).
and
(
table
[
:group_id
].
not_eq
(
nil
)))
end
end
def
down
end
end
db/schema.rb
View file @
36259857
...
...
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
201906281
45246
)
do
ActiveRecord
::
Schema
.
define
(
version:
201906281
85004
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
@@ -2902,6 +2902,7 @@ ActiveRecord::Schema.define(version: 20190628145246) do
t
.
integer
"author_id"
t
.
string
"name"
t
.
string
"sha"
t
.
datetime_with_timezone
"released_at"
,
null:
false
t
.
index
[
"author_id"
],
name:
"index_releases_on_author_id"
,
using: :btree
t
.
index
[
"project_id"
,
"tag"
],
name:
"index_releases_on_project_id_and_tag"
,
using: :btree
t
.
index
[
"project_id"
],
name:
"index_releases_on_project_id"
,
using: :btree
...
...
lib/api/entities.rb
View file @
36259857
...
...
@@ -1186,8 +1186,10 @@ module API
MarkupHelper
.
markdown_field
(
entity
,
:description
)
end
expose
:created_at
expose
:released_at
expose
:author
,
using:
Entities
::
UserBasic
,
if:
->
(
release
,
_
)
{
release
.
author
.
present?
}
expose
:commit
,
using:
Entities
::
Commit
,
if:
lambda
{
|
_
,
_
|
can_download_code?
}
expose
:upcoming_release?
,
as: :upcoming_release
expose
:assets
do
expose
:assets_count
,
as: :count
do
|
release
,
_
|
...
...
lib/api/releases.rb
View file @
36259857
...
...
@@ -54,6 +54,7 @@ module API
requires
:url
,
type:
String
end
end
optional
:released_at
,
type:
DateTime
,
desc:
'The date when the release will be/was ready. Defaults to the current time.'
end
post
':id/releases'
do
authorize_create_release!
...
...
@@ -77,6 +78,7 @@ module API
requires
:tag_name
,
type:
String
,
desc:
'The name of the tag'
,
as: :tag
optional
:name
,
type:
String
,
desc:
'The name of the release'
optional
:description
,
type:
String
,
desc:
'Release notes with markdown support'
optional
:released_at
,
type:
DateTime
,
desc:
'The date when the release will be/was ready. Defaults to the current time.'
end
put
':id/releases/:tag_name'
,
requirements:
RELEASE_ENDPOINT_REQUIREMETS
do
authorize_update_release!
...
...
lib/gitlab/background_migration/migrate_system_uploads_to_new_folder.rb
deleted
100644 → 0
View file @
209b0cef
# frozen_string_literal: true
# rubocop:disable Style/Documentation
module
Gitlab
module
BackgroundMigration
class
MigrateSystemUploadsToNewFolder
include
Gitlab
::
Database
::
MigrationHelpers
attr_reader
:old_folder
,
:new_folder
class
Upload
<
ActiveRecord
::
Base
self
.
table_name
=
'uploads'
include
EachBatch
end
def
perform
(
old_folder
,
new_folder
)
replace_sql
=
replace_sql
(
uploads
[
:path
],
old_folder
,
new_folder
)
affected_uploads
=
Upload
.
where
(
uploads
[
:path
].
matches
(
"
#{
old_folder
}
%"
))
affected_uploads
.
each_batch
do
|
batch
|
batch
.
update_all
(
"path =
#{
replace_sql
}
"
)
end
end
def
uploads
Arel
::
Table
.
new
(
'uploads'
)
end
end
end
end
lib/gitlab/background_migration/move_personal_snippet_files.rb
deleted
100644 → 0
View file @
209b0cef
# frozen_string_literal: true
# rubocop:disable Style/Documentation
module
Gitlab
module
BackgroundMigration
class
MovePersonalSnippetFiles
delegate
:select_all
,
:execute
,
:quote_string
,
to: :connection
def
perform
(
relative_source
,
relative_destination
)
@source_relative_location
=
relative_source
@destination_relative_location
=
relative_destination
move_personal_snippet_files
end
def
move_personal_snippet_files
query
=
"SELECT uploads.path, uploads.model_id FROM uploads "
\
"INNER JOIN snippets ON snippets.id = uploads.model_id WHERE uploader = 'PersonalFileUploader'"
select_all
(
query
).
each
do
|
upload
|
secret
=
upload
[
'path'
].
split
(
'/'
)[
0
]
file_name
=
upload
[
'path'
].
split
(
'/'
)[
1
]
move_file
(
upload
[
'model_id'
],
secret
,
file_name
)
update_markdown
(
upload
[
'model_id'
],
secret
,
file_name
)
end
end
def
move_file
(
snippet_id
,
secret
,
file_name
)
source_dir
=
File
.
join
(
base_directory
,
@source_relative_location
,
snippet_id
.
to_s
,
secret
)
destination_dir
=
File
.
join
(
base_directory
,
@destination_relative_location
,
snippet_id
.
to_s
,
secret
)
source_file_path
=
File
.
join
(
source_dir
,
file_name
)
destination_file_path
=
File
.
join
(
destination_dir
,
file_name
)
unless
File
.
exist?
(
source_file_path
)
say
"Source file `
#{
source_file_path
}
` doesn't exist. Skipping."
return
end
say
"Moving file
#{
source_file_path
}
->
#{
destination_file_path
}
"
FileUtils
.
mkdir_p
(
destination_dir
)
FileUtils
.
move
(
source_file_path
,
destination_file_path
)
end
def
update_markdown
(
snippet_id
,
secret
,
file_name
)
source_markdown_path
=
File
.
join
(
@source_relative_location
,
snippet_id
.
to_s
,
secret
,
file_name
)
destination_markdown_path
=
File
.
join
(
@destination_relative_location
,
snippet_id
.
to_s
,
secret
,
file_name
)
source_markdown
=
"](
#{
source_markdown_path
}
)"
destination_markdown
=
"](
#{
destination_markdown_path
}
)"
quoted_source
=
quote_string
(
source_markdown
)
quoted_destination
=
quote_string
(
destination_markdown
)
execute
(
"UPDATE snippets "
\
"SET description = replace(snippets.description, '
#{
quoted_source
}
', '
#{
quoted_destination
}
'), description_html = NULL "
\
"WHERE id =
#{
snippet_id
}
"
)
query
=
"SELECT id, note FROM notes WHERE noteable_id =
#{
snippet_id
}
"
\
"AND noteable_type = 'Snippet' AND note IS NOT NULL"
select_all
(
query
).
each
do
|
note
|
text
=
note
[
'note'
].
gsub
(
source_markdown
,
destination_markdown
)
quoted_text
=
quote_string
(
text
)
execute
(
"UPDATE notes SET note = '
#{
quoted_text
}
', note_html = NULL WHERE id =
#{
note
[
'id'
]
}
"
)
end
end
def
base_directory
File
.
join
(
Rails
.
root
,
'public'
)
end
def
connection
ActiveRecord
::
Base
.
connection
end
def
say
(
message
)
Rails
.
logger
.
debug
(
message
)
end
end
end
end
lib/gitlab/legacy_github_import/release_formatter.rb
View file @
36259857
...
...
@@ -10,6 +10,7 @@ module Gitlab
name:
raw_data
.
name
,
description:
raw_data
.
body
,
created_at:
raw_data
.
created_at
,
released_at:
raw_data
.
published_at
,
updated_at:
raw_data
.
created_at
}
end
...
...
lib/peek/views/redis.rb
0 → 100644
View file @
36259857
# frozen_string_literal: true
require
'redis'
require
'peek-redis'
module
Gitlab
module
Peek
module
RedisInstrumented
def
call
(
*
args
,
&
block
)
start
=
Time
.
now
super
(
*
args
,
&
block
)
ensure
duration
=
(
Time
.
now
-
start
)
add_call_details
(
duration
,
args
)
end
private
def
add_call_details
(
duration
,
args
)
# redis-rb passes an array (e.g. [:get, key])
return
unless
args
.
length
==
1
detail_store
<<
{
cmd:
args
.
first
,
duration:
duration
,
backtrace:
Gitlab
::
Profiler
.
clean_backtrace
(
caller
)
}
end
def
detail_store
::
Gitlab
::
SafeRequestStore
[
'redis_call_details'
]
||=
[]
end
end
end
end
module
Peek
module
Views
module
RedisDetailed
def
results
super
.
merge
(
details:
details
)
end
def
details
detail_store
.
sort
{
|
a
,
b
|
b
[
:duration
]
<=>
a
[
:duration
]
}
.
map
(
&
method
(
:format_call_details
))
end
def
detail_store
::
Gitlab
::
SafeRequestStore
[
'redis_call_details'
]
||=
[]
end
def
format_call_details
(
call
)
call
.
merge
(
cmd:
format_command
(
call
[
:cmd
]),
duration:
(
call
[
:duration
]
*
1000
).
round
(
3
))
end
def
format_command
(
cmd
)
# Scrub out the value of the SET calls to avoid binary
# data or large data from spilling into the view
if
cmd
.
length
>=
2
&&
cmd
.
first
=~
/set/i
cmd
[
-
1
]
=
"<redacted>"
end
cmd
.
join
(
' '
)
end
end
end
end
class
Redis::Client
prepend
Gitlab
::
Peek
::
RedisInstrumented
end
module
Peek
module
Views
class
Redis
<
View
prepend
Peek
::
Views
::
RedisDetailed
end
end
end
spec/factories/releases.rb
View file @
36259857
...
...
@@ -6,6 +6,7 @@ FactoryBot.define do
description
"Awesome release"
project
author
released_at
{
Time
.
zone
.
parse
(
'2018-10-20T18:00:00Z'
)
}
trait
:legacy
do
sha
nil
...
...
spec/features/projects/releases/user_views_releases_spec.rb
View file @
36259857
...
...
@@ -16,6 +16,7 @@ describe 'User views releases', :js do
expect
(
page
).
to
have_content
(
release
.
name
)
expect
(
page
).
to
have_content
(
release
.
tag
)
expect
(
page
).
not_to
have_content
(
'Upcoming Release'
)
end
context
'when there is a link as an asset'
do
...
...
@@ -43,4 +44,15 @@ describe 'User views releases', :js do
end
end
end
context
'with an upcoming release'
do
let
(
:tomorrow
)
{
Time
.
zone
.
now
+
1
.
day
}
let!
(
:release
)
{
create
(
:release
,
project:
project
,
released_at:
tomorrow
)
}
it
'sees the upcoming tag'
do
visit
project_releases_path
(
project
)
expect
(
page
).
to
have_content
(
'Upcoming Release'
)
end
end
end
spec/finders/releases_finder_spec.rb
View file @
36259857
...
...
@@ -12,8 +12,8 @@ describe ReleasesFinder do
subject
{
described_class
.
new
(
project
,
user
)}
before
do
v1_0_0
.
update_attribute
(
:
creat
ed_at
,
2
.
days
.
ago
)
v1_1_0
.
update_attribute
(
:
creat
ed_at
,
1
.
day
.
ago
)
v1_0_0
.
update_attribute
(
:
releas
ed_at
,
2
.
days
.
ago
)
v1_1_0
.
update_attribute
(
:
releas
ed_at
,
1
.
day
.
ago
)
end
describe
'#execute'
do
...
...
@@ -30,7 +30,7 @@ describe ReleasesFinder do
project
.
add_developer
(
user
)
end
it
'sorts by
creation
date'
do
it
'sorts by
release
date'
do
releases
=
subject
.
execute
expect
(
releases
).
to
be_present
...
...
spec/fixtures/api/schemas/public_api/v4/release.json
View file @
36259857
{
"type"
:
"object"
,
"required"
:
[
"name"
,
"tag_name"
,
"commit"
],
"required"
:
[
"name"
,
"tag_name"
,
"commit"
,
"released_at"
],
"properties"
:
{
"name"
:
{
"type"
:
"string"
},
"tag_name"
:
{
"type"
:
"string"
},
"description"
:
{
"type"
:
"string"
},
"description_html"
:
{
"type"
:
"string"
},
"created_at"
:
{
"type"
:
"date"
},
"released_at"
:
{
"type"
:
"date"
},
"upcoming_release"
:
{
"type"
:
"boolean"
},
"commit"
:
{
"oneOf"
:
[{
"type"
:
"null"
},
{
"$ref"
:
"commit/basic.json"
}]
},
...
...
spec/fixtures/api/schemas/public_api/v4/release/release_for_guest.json
View file @
36259857
{
"type"
:
"object"
,
"required"
:
[
"name"
],
"required"
:
[
"name"
,
"released_at"
],
"properties"
:
{
"name"
:
{
"type"
:
"string"
},
"description"
:
{
"type"
:
"string"
},
"description_html"
:
{
"type"
:
"string"
},
"created_at"
:
{
"type"
:
"date"
},
"released_at"
:
{
"type"
:
"date"
},
"upcoming_release"
:
{
"type"
:
"boolean"
},
"author"
:
{
"oneOf"
:
[{
"type"
:
"null"
},
{
"$ref"
:
"../user/basic.json"
}]
},
...
...
spec/javascripts/performance_bar/components/simple_metric_spec.js
deleted
100644 → 0
View file @
209b0cef
import
Vue
from
'
vue
'
;
import
simpleMetric
from
'
~/performance_bar/components/simple_metric.vue
'
;
import
mountComponent
from
'
spec/helpers/vue_mount_component_helper
'
;
describe
(
'
simpleMetric
'
,
()
=>
{
let
vm
;
afterEach
(()
=>
{
vm
.
$destroy
();
});
describe
(
'
when the current request has no details
'
,
()
=>
{
beforeEach
(()
=>
{
vm
=
mountComponent
(
Vue
.
extend
(
simpleMetric
),
{
currentRequest
:
{},
metric
:
'
gitaly
'
,
});
});
it
(
'
does not display details
'
,
()
=>
{
expect
(
vm
.
$el
.
innerText
).
not
.
toContain
(
'
/
'
);
});
it
(
'
displays the metric name
'
,
()
=>
{
expect
(
vm
.
$el
.
innerText
).
toContain
(
'
gitaly
'
);
});
});
describe
(
'
when the current request has details
'
,
()
=>
{
beforeEach
(()
=>
{
vm
=
mountComponent
(
Vue
.
extend
(
simpleMetric
),
{
currentRequest
:
{
details
:
{
gitaly
:
{
duration
:
'
123ms
'
,
calls
:
'
456
'
}
},
},
metric
:
'
gitaly
'
,
});
});
it
(
'
diplays details
'
,
()
=>
{
expect
(
vm
.
$el
.
innerText
.
replace
(
/
\s
+/g
,
'
'
)).
toContain
(
'
123ms / 456
'
);
});
it
(
'
displays the metric name
'
,
()
=>
{
expect
(
vm
.
$el
.
innerText
).
toContain
(
'
gitaly
'
);
});
});
});
spec/javascripts/releases/components/release_block_spec.js
View file @
36259857
...
...
@@ -14,7 +14,7 @@ describe('Release block', () => {
description_html
:
'
<div><h2>changelog</h2><ul><li>line1</li<li>line 2</li></ul></div>
'
,
author_name
:
'
Release bot
'
,
author_email
:
'
release-bot@example.com
'
,
creat
ed_at
:
'
2012-05-28T05:00:00-07:00
'
,
releas
ed_at
:
'
2012-05-28T05:00:00-07:00
'
,
author
:
{
avatar_url
:
'
uploads/-/system/user/avatar/johndoe/avatar.png
'
,
id
:
482476
,
...
...
@@ -101,7 +101,7 @@ describe('Release block', () => {
});
it
(
'
renders release date
'
,
()
=>
{
expect
(
vm
.
$el
.
textContent
).
toContain
(
timeagoMixin
.
methods
.
timeFormated
(
release
.
creat
ed_at
));
expect
(
vm
.
$el
.
textContent
).
toContain
(
timeagoMixin
.
methods
.
timeFormated
(
release
.
releas
ed_at
));
});
it
(
'
renders number of assets provided
'
,
()
=>
{
...
...
@@ -152,13 +152,13 @@ describe('Release block', () => {
});
});
describe
(
'
with
pre
_release flag
'
,
()
=>
{
describe
(
'
with
upcoming
_release flag
'
,
()
=>
{
beforeEach
(()
=>
{
vm
=
factory
(
Object
.
assign
({},
release
,
{
pre
_release
:
true
}));
vm
=
factory
(
Object
.
assign
({},
release
,
{
upcoming
_release
:
true
}));
});
it
(
'
renders
pre-
release badge
'
,
()
=>
{
expect
(
vm
.
$el
.
textContent
).
toContain
(
'
Pre-r
elease
'
);
it
(
'
renders
upcoming
release badge
'
,
()
=>
{
expect
(
vm
.
$el
.
textContent
).
toContain
(
'
Upcoming R
elease
'
);
});
});
});
spec/lib/gitlab/background_migration/migrate_system_uploads_to_new_folder_spec.rb
deleted
100644 → 0
View file @
209b0cef
require
'spec_helper'
# rubocop:disable RSpec/FactoriesInMigrationSpecs
describe
Gitlab
::
BackgroundMigration
::
MigrateSystemUploadsToNewFolder
,
:delete
do
let
(
:migration
)
{
described_class
.
new
}
before
do
allow
(
migration
).
to
receive
(
:logger
).
and_return
(
Logger
.
new
(
nil
))
end
describe
'#perform'
do
it
'renames the path of system-uploads'
do
upload
=
create
(
:upload
,
model:
create
(
:project
),
path:
'uploads/system/project/avatar.jpg'
)
migration
.
perform
(
'uploads/system/'
,
'uploads/-/system/'
)
expect
(
upload
.
reload
.
path
).
to
eq
(
'uploads/-/system/project/avatar.jpg'
)
end
end
end
# rubocop:enable RSpec/FactoriesInMigrationSpecs
spec/lib/gitlab/background_migration/move_personal_snippet_files_spec.rb
deleted
100644 → 0
View file @
209b0cef
require
'spec_helper'
# rubocop:disable RSpec/FactoriesInMigrationSpecs
describe
Gitlab
::
BackgroundMigration
::
MovePersonalSnippetFiles
do
let
(
:test_dir
)
{
File
.
join
(
Rails
.
root
,
'tmp'
,
'tests'
,
'move_snippet_files_test'
)
}
let
(
:old_uploads_dir
)
{
File
.
join
(
'uploads'
,
'system'
,
'personal_snippet'
)
}
let
(
:new_uploads_dir
)
{
File
.
join
(
'uploads'
,
'-'
,
'system'
,
'personal_snippet'
)
}
let
(
:snippet
)
do
snippet
=
create
(
:personal_snippet
)
create_upload_for_snippet
(
snippet
)
snippet
.
update!
(
description:
markdown_linking_file
(
snippet
))
snippet
end
let
(
:migration
)
{
described_class
.
new
}
before
do
allow
(
migration
).
to
receive
(
:base_directory
)
{
test_dir
}
end
describe
'#perform'
do
it
'moves the file on the disk'
do
expected_path
=
File
.
join
(
test_dir
,
new_uploads_dir
,
snippet
.
id
.
to_s
,
"secret
#{
snippet
.
id
}
"
,
'upload.txt'
)
migration
.
perform
(
old_uploads_dir
,
new_uploads_dir
)
expect
(
File
.
exist?
(
expected_path
)).
to
be_truthy
end
it
'updates the markdown of the snippet'
do
expected_path
=
File
.
join
(
new_uploads_dir
,
snippet
.
id
.
to_s
,
"secret
#{
snippet
.
id
}
"
,
'upload.txt'
)
expected_markdown
=
"[an upload](
#{
expected_path
}
)"
migration
.
perform
(
old_uploads_dir
,
new_uploads_dir
)
expect
(
snippet
.
reload
.
description
).
to
eq
(
expected_markdown
)
end
it
'updates the markdown of notes'
do
expected_path
=
File
.
join
(
new_uploads_dir
,
snippet
.
id
.
to_s
,
"secret
#{
snippet
.
id
}
"
,
'upload.txt'
)
expected_markdown
=
"with [an upload](
#{
expected_path
}
)"
note
=
create
(
:note_on_personal_snippet
,
noteable:
snippet
,
note:
"with
#{
markdown_linking_file
(
snippet
)
}
"
)
migration
.
perform
(
old_uploads_dir
,
new_uploads_dir
)
expect
(
note
.
reload
.
note
).
to
eq
(
expected_markdown
)
end
end
def
create_upload_for_snippet
(
snippet
)
snippet_path
=
path_for_file_in_snippet
(
snippet
)
path
=
File
.
join
(
old_uploads_dir
,
snippet
.
id
.
to_s
,
snippet_path
)
absolute_path
=
File
.
join
(
test_dir
,
path
)
FileUtils
.
mkdir_p
(
File
.
dirname
(
absolute_path
))
FileUtils
.
touch
(
absolute_path
)
create
(
:upload
,
model:
snippet
,
path:
snippet_path
,
uploader:
PersonalFileUploader
)
end
def
path_for_file_in_snippet
(
snippet
)
secret
=
"secret
#{
snippet
.
id
}
"
filename
=
'upload.txt'
File
.
join
(
secret
,
filename
)
end
def
markdown_linking_file
(
snippet
)
path
=
File
.
join
(
old_uploads_dir
,
snippet
.
id
.
to_s
,
path_for_file_in_snippet
(
snippet
))
"[an upload](
#{
path
}
)"
end
end
# rubocop:enable RSpec/FactoriesInMigrationSpecs
spec/lib/gitlab/import_export/safe_model_attributes.yml
View file @
36259857
...
...
@@ -123,6 +123,7 @@ Release:
-
project_id
-
created_at
-
updated_at
-
released_at
Releases::Link:
-
id
-
release_id
...
...
spec/lib/gitlab/legacy_github_import/importer_spec.rb
View file @
36259857
...
...
@@ -132,6 +132,7 @@ describe Gitlab::LegacyGithubImport::Importer do
body:
'Release v1.0.0'
,
draft:
false
,
created_at:
created_at
,
published_at:
created_at
,
updated_at:
updated_at
,
url:
"
#{
api_root
}
/repos/octocat/Hello-World/releases/1"
)
...
...
@@ -144,6 +145,7 @@ describe Gitlab::LegacyGithubImport::Importer do
body:
nil
,
draft:
false
,
created_at:
created_at
,
published_at:
created_at
,
updated_at:
updated_at
,
url:
"
#{
api_root
}
/repos/octocat/Hello-World/releases/2"
)
...
...
spec/lib/gitlab/legacy_github_import/release_formatter_spec.rb
View file @
36259857
...
...
@@ -4,6 +4,7 @@ describe Gitlab::LegacyGithubImport::ReleaseFormatter do
let!
(
:project
)
{
create
(
:project
,
namespace:
create
(
:namespace
,
path:
'octocat'
))
}
let
(
:octocat
)
{
double
(
id:
123456
,
login:
'octocat'
)
}
let
(
:created_at
)
{
DateTime
.
strptime
(
'2011-01-26T19:01:12Z'
)
}
let
(
:published_at
)
{
DateTime
.
strptime
(
'2011-01-26T20:00:00Z'
)
}
let
(
:base_data
)
do
{
...
...
@@ -11,7 +12,7 @@ describe Gitlab::LegacyGithubImport::ReleaseFormatter do
name:
'First release'
,
draft:
false
,
created_at:
created_at
,
published_at:
creat
ed_at
,
published_at:
publish
ed_at
,
body:
'Release v1.0.0'
}
end
...
...
@@ -28,6 +29,7 @@ describe Gitlab::LegacyGithubImport::ReleaseFormatter do
name:
'First release'
,
description:
'Release v1.0.0'
,
created_at:
created_at
,
released_at:
published_at
,
updated_at:
created_at
}
...
...
spec/migrations/backfill_and_add_not_null_constraint_to_released_at_column_on_releases_table_spec.rb
0 → 100644
View file @
36259857
# frozen_string_literal: true
require
'spec_helper'
require
Rails
.
root
.
join
(
'db'
,
'migrate'
,
'20190628185004_backfill_and_add_not_null_constraint_to_released_at_column_on_releases_table.rb'
)
describe
BackfillAndAddNotNullConstraintToReleasedAtColumnOnReleasesTable
,
:migration
do
let
(
:releases
)
{
table
(
:releases
)
}
let
(
:namespaces
)
{
table
(
:namespaces
)
}
let
(
:projects
)
{
table
(
:projects
)
}
subject
(
:migration
)
{
described_class
.
new
}
it
'fills released_at with the value of created_at'
do
created_at_a
=
Time
.
zone
.
parse
(
'2019-02-10T08:00:00Z'
)
created_at_b
=
Time
.
zone
.
parse
(
'2019-03-10T18:00:00Z'
)
namespace
=
namespaces
.
create
(
name:
'foo'
,
path:
'foo'
)
project
=
projects
.
create!
(
namespace_id:
namespace
.
id
)
release_a
=
releases
.
create!
(
project_id:
project
.
id
,
created_at:
created_at_a
)
release_b
=
releases
.
create!
(
project_id:
project
.
id
,
created_at:
created_at_b
)
disable_migrations_output
{
migration
.
up
}
release_a
.
reload
release_b
.
reload
expect
(
release_a
.
released_at
).
to
eq
(
created_at_a
)
expect
(
release_b
.
released_at
).
to
eq
(
created_at_b
)
end
end
spec/migrations/remove_project_labels_group_id_spec.rb
deleted
100644 → 0
View file @
209b0cef
# encoding: utf-8
require
'spec_helper'
require
Rails
.
root
.
join
(
'db'
,
'post_migrate'
,
'20180202111106_remove_project_labels_group_id.rb'
)
describe
RemoveProjectLabelsGroupId
,
:delete
do
let
(
:migration
)
{
described_class
.
new
}
let
(
:group
)
{
create
(
:group
)
}
# rubocop:disable RSpec/FactoriesInMigrationSpecs
let!
(
:project_label
)
{
create
(
:label
,
group_id:
group
.
id
)
}
# rubocop:disable RSpec/FactoriesInMigrationSpecs
let!
(
:group_label
)
{
create
(
:group_label
)
}
# rubocop:disable RSpec/FactoriesInMigrationSpecs
describe
'#up'
do
it
'updates the project labels group ID'
do
expect
{
migration
.
up
}.
to
change
{
project_label
.
reload
.
group_id
}.
to
(
nil
)
end
it
'keeps the group labels group ID'
do
expect
{
migration
.
up
}.
not_to
change
{
group_label
.
reload
.
group_id
}
end
end
end
spec/models/release_spec.rb
View file @
36259857
...
...
@@ -64,4 +64,14 @@ RSpec.describe Release do
is_expected
.
to
all
(
be_a
(
Releases
::
Source
))
end
end
describe
'#upcoming_release?'
do
context
'during the backfill migration when released_at could be nil'
do
it
'handles a nil released_at value and returns false'
do
allow
(
release
).
to
receive
(
:released_at
).
and_return
nil
expect
(
release
.
upcoming_release?
).
to
eq
(
false
)
end
end
end
end
spec/requests/api/releases_spec.rb
View file @
36259857
...
...
@@ -24,7 +24,7 @@ describe API::Releases do
project:
project
,
tag:
'v0.1'
,
author:
maintainer
,
creat
ed_at:
2
.
days
.
ago
)
releas
ed_at:
2
.
days
.
ago
)
end
let!
(
:release_2
)
do
...
...
@@ -32,7 +32,7 @@ describe API::Releases do
project:
project
,
tag:
'v0.2'
,
author:
maintainer
,
creat
ed_at:
1
.
day
.
ago
)
releas
ed_at:
1
.
day
.
ago
)
end
it
'returns 200 HTTP status'
do
...
...
@@ -41,7 +41,7 @@ describe API::Releases do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
it
'returns releases ordered by
creat
ed_at'
do
it
'returns releases ordered by
releas
ed_at'
do
get
api
(
"/projects/
#{
project
.
id
}
/releases"
,
maintainer
)
expect
(
json_response
.
count
).
to
eq
(
2
)
...
...
@@ -56,6 +56,26 @@ describe API::Releases do
end
end
it
'returns an upcoming_release status for a future release'
do
tomorrow
=
Time
.
now
.
utc
+
1
.
day
create
(
:release
,
project:
project
,
tag:
'v0.1'
,
author:
maintainer
,
released_at:
tomorrow
)
get
api
(
"/projects/
#{
project
.
id
}
/releases"
,
maintainer
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
.
first
[
'upcoming_release'
]).
to
eq
(
true
)
end
it
'returns an upcoming_release status for a past release'
do
yesterday
=
Time
.
now
.
utc
-
1
.
day
create
(
:release
,
project:
project
,
tag:
'v0.1'
,
author:
maintainer
,
released_at:
yesterday
)
get
api
(
"/projects/
#{
project
.
id
}
/releases"
,
maintainer
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
.
first
[
'upcoming_release'
]).
to
eq
(
false
)
end
context
'when tag does not exist in git repository'
do
let!
(
:release
)
{
create
(
:release
,
project:
project
,
tag:
'v1.1.5'
)
}
...
...
@@ -316,6 +336,51 @@ describe API::Releases do
expect
(
project
.
releases
.
last
.
description
).
to
eq
(
'Super nice release'
)
end
it
'sets the released_at to the current time if the released_at parameter is not provided'
do
now
=
Time
.
zone
.
parse
(
'2015-08-25 06:00:00Z'
)
Timecop
.
freeze
(
now
)
do
post
api
(
"/projects/
#{
project
.
id
}
/releases"
,
maintainer
),
params:
params
expect
(
project
.
releases
.
last
.
released_at
).
to
eq
(
now
)
end
end
it
'sets the released_at to the value in the parameters if specified'
do
params
=
{
name:
'New release'
,
tag_name:
'v0.1'
,
description:
'Super nice release'
,
released_at:
'2019-03-20T10:00:00Z'
}
post
api
(
"/projects/
#{
project
.
id
}
/releases"
,
maintainer
),
params:
params
expect
(
project
.
releases
.
last
.
released_at
).
to
eq
(
'2019-03-20T10:00:00Z'
)
end
it
'assumes the utc timezone for released_at if the timezone is not provided'
do
params
=
{
name:
'New release'
,
tag_name:
'v0.1'
,
description:
'Super nice release'
,
released_at:
'2019-03-25 10:00:00'
}
post
api
(
"/projects/
#{
project
.
id
}
/releases"
,
maintainer
),
params:
params
expect
(
project
.
releases
.
last
.
released_at
).
to
eq
(
'2019-03-25T10:00:00Z'
)
end
it
'allows specifying a released_at with a local time zone'
do
params
=
{
name:
'New release'
,
tag_name:
'v0.1'
,
description:
'Super nice release'
,
released_at:
'2019-03-25T10:00:00+09:00'
}
post
api
(
"/projects/
#{
project
.
id
}
/releases"
,
maintainer
),
params:
params
expect
(
project
.
releases
.
last
.
released_at
).
to
eq
(
'2019-03-25T01:00:00Z'
)
end
context
'when description is empty'
do
let
(
:params
)
do
{
...
...
@@ -540,6 +605,7 @@ describe API::Releases do
project:
project
,
tag:
'v0.1'
,
name:
'New release'
,
released_at:
'2018-03-01T22:00:00Z'
,
description:
'Super nice release'
)
end
...
...
@@ -560,6 +626,7 @@ describe API::Releases do
expect
(
project
.
releases
.
last
.
tag
).
to
eq
(
'v0.1'
)
expect
(
project
.
releases
.
last
.
name
).
to
eq
(
'New release'
)
expect
(
project
.
releases
.
last
.
released_at
).
to
eq
(
'2018-03-01T22:00:00Z'
)
end
it
'matches response schema'
do
...
...
@@ -568,6 +635,14 @@ describe API::Releases do
expect
(
response
).
to
match_response_schema
(
'public_api/v4/release'
)
end
it
'updates released_at'
do
params
=
{
released_at:
'2015-10-10T05:00:00Z'
}
put
api
(
"/projects/
#{
project
.
id
}
/releases/v0.1"
,
maintainer
),
params:
params
expect
(
project
.
releases
.
last
.
released_at
).
to
eq
(
'2015-10-10T05:00:00Z'
)
end
context
'when user tries to update sha'
do
let
(
:params
)
{
{
sha:
'xxx'
}
}
...
...
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