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
389ffbc5
Commit
389ffbc5
authored
Jun 03, 2020
by
Maxime Orefice
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add JSON schema validation for DailyBuildGroupReportResult
parent
747b0afb
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
0 deletions
+34
-0
app/models/ci/daily_build_group_report_result.rb
app/models/ci/daily_build_group_report_result.rb
+2
-0
app/validators/json_schemas/daily_build_group_report_result_data.json
...rs/json_schemas/daily_build_group_report_result_data.json
+8
-0
spec/models/ci/daily_build_group_report_result_spec.rb
spec/models/ci/daily_build_group_report_result_spec.rb
+24
-0
No files found.
app/models/ci/daily_build_group_report_result.rb
View file @
389ffbc5
...
...
@@ -9,6 +9,8 @@ module Ci
belongs_to
:last_pipeline
,
class_name:
'Ci::Pipeline'
,
foreign_key: :last_pipeline_id
belongs_to
:project
validates
:data
,
json_schema:
{
filename:
"daily_build_group_report_result_data"
}
def
self
.
upsert_reports
(
data
)
upsert_all
(
data
,
unique_by: :index_daily_build_group_report_results_unique_columns
)
if
data
.
any?
end
...
...
app/validators/json_schemas/daily_build_group_report_result_data.json
0 → 100644
View file @
389ffbc5
{
"description"
:
"Daily build group report result data"
,
"type"
:
"object"
,
"properties"
:
{
"coverage"
:
{
"type"
:
"float"
}
},
"additionalProperties"
:
false
}
spec/models/ci/daily_build_group_report_result_spec.rb
View file @
389ffbc5
...
...
@@ -3,6 +3,30 @@
require
'spec_helper'
describe
Ci
::
DailyBuildGroupReportResult
do
let
(
:daily_build_group_report_result
)
{
build
(
:ci_daily_build_group_report_result
)}
describe
'associations'
do
it
{
is_expected
.
to
belong_to
(
:last_pipeline
)
}
it
{
is_expected
.
to
belong_to
(
:project
)
}
end
describe
'validations'
do
context
'when attributes are valid'
do
it
'returns no errors'
do
expect
(
daily_build_group_report_result
).
to
be_valid
end
end
context
'when data is invalid'
do
it
'returns errors'
do
daily_build_group_report_result
.
data
=
{
invalid:
'data'
}
expect
(
daily_build_group_report_result
).
to
be_invalid
expect
(
daily_build_group_report_result
.
errors
.
full_messages
).
to
eq
([
"Data must be a valid json schema"
])
end
end
end
describe
'.upsert_reports'
do
let!
(
:rspec_coverage
)
do
create
(
...
...
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