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
72dd387a
Commit
72dd387a
authored
May 11, 2020
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create test reports table and model
Create requirements management test report model and table.
parent
23193ed0
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
155 additions
and
0 deletions
+155
-0
db/migrate/20200511181027_create_test_reports.rb
db/migrate/20200511181027_create_test_reports.rb
+18
-0
db/migrate/20200511191027_add_author_foreign_key_to_test_reports.rb
.../20200511191027_add_author_foreign_key_to_test_reports.rb
+19
-0
db/migrate/20200511208012_add_pipeline_foreign_key_to_test_reports.rb
...0200511208012_add_pipeline_foreign_key_to_test_reports.rb
+19
-0
db/structure.sql
db/structure.sql
+41
-0
ee/app/models/ee/user.rb
ee/app/models/ee/user.rb
+1
-0
ee/app/models/requirements_management.rb
ee/app/models/requirements_management.rb
+7
-0
ee/app/models/requirements_management/requirement.rb
ee/app/models/requirements_management/requirement.rb
+2
-0
ee/app/models/requirements_management/test_report.rb
ee/app/models/requirements_management/test_report.rb
+13
-0
ee/changelogs/unreleased/issue_215506.yml
ee/changelogs/unreleased/issue_215506.yml
+5
-0
ee/spec/factories/requirements_management/test_reports.rb
ee/spec/factories/requirements_management/test_reports.rb
+10
-0
ee/spec/models/requirements_management/test_report_spec.rb
ee/spec/models/requirements_management/test_report_spec.rb
+20
-0
No files found.
db/migrate/20200511181027_create_test_reports.rb
0 → 100644
View file @
72dd387a
# frozen_string_literal: true
class
CreateTestReports
<
ActiveRecord
::
Migration
[
6.0
]
DOWNTIME
=
false
def
change
create_table
:requirements_management_test_reports
do
|
t
|
t
.
datetime_with_timezone
:created_at
,
null:
false
t
.
references
:requirement
,
null:
false
,
foreign_key:
{
on_delete: :cascade
}
t
.
bigint
:pipeline_id
t
.
bigint
:author_id
t
.
integer
:state
,
null:
false
,
limit:
2
t
.
index
:pipeline_id
t
.
index
:author_id
end
end
end
db/migrate/20200511191027_add_author_foreign_key_to_test_reports.rb
0 → 100644
View file @
72dd387a
# frozen_string_literal: true
class
AddAuthorForeignKeyToTestReports
<
ActiveRecord
::
Migration
[
6.0
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
def
up
with_lock_retries
do
add_foreign_key
:requirements_management_test_reports
,
:users
,
column: :author_id
,
on_delete: :nullify
# rubocop:disable Migration/AddConcurrentForeignKey
end
end
def
down
with_lock_retries
do
remove_foreign_key
:requirements_management_test_reports
,
column: :author_id
end
end
end
db/migrate/20200511208012_add_pipeline_foreign_key_to_test_reports.rb
0 → 100644
View file @
72dd387a
# frozen_string_literal: true
class
AddPipelineForeignKeyToTestReports
<
ActiveRecord
::
Migration
[
6.0
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
def
up
with_lock_retries
do
add_foreign_key
:requirements_management_test_reports
,
:ci_pipelines
,
column: :pipeline_id
,
on_delete: :nullify
# rubocop:disable Migration/AddConcurrentForeignKey
end
end
def
down
with_lock_retries
do
remove_foreign_key
:requirements_management_test_reports
,
column: :pipeline_id
end
end
end
db/structure.sql
View file @
72dd387a
...
...
@@ -5773,6 +5773,24 @@ CREATE SEQUENCE public.requirements_id_seq
ALTER
SEQUENCE
public
.
requirements_id_seq
OWNED
BY
public
.
requirements
.
id
;
CREATE
TABLE
public
.
requirements_management_test_reports
(
id
bigint
NOT
NULL
,
created_at
timestamp
with
time
zone
NOT
NULL
,
requirement_id
bigint
NOT
NULL
,
pipeline_id
bigint
,
author_id
bigint
,
state
smallint
NOT
NULL
);
CREATE
SEQUENCE
public
.
requirements_management_test_reports_id_seq
START
WITH
1
INCREMENT
BY
1
NO
MINVALUE
NO
MAXVALUE
CACHE
1
;
ALTER
SEQUENCE
public
.
requirements_management_test_reports_id_seq
OWNED
BY
public
.
requirements_management_test_reports
.
id
;
CREATE
TABLE
public
.
resource_label_events
(
id
bigint
NOT
NULL
,
action
integer
NOT
NULL
,
...
...
@@ -7777,6 +7795,8 @@ ALTER TABLE ONLY public.remote_mirrors ALTER COLUMN id SET DEFAULT nextval('publ
ALTER
TABLE
ONLY
public
.
requirements
ALTER
COLUMN
id
SET
DEFAULT
nextval
(
'public.requirements_id_seq'
::
regclass
);
ALTER
TABLE
ONLY
public
.
requirements_management_test_reports
ALTER
COLUMN
id
SET
DEFAULT
nextval
(
'public.requirements_management_test_reports_id_seq'
::
regclass
);
ALTER
TABLE
ONLY
public
.
resource_label_events
ALTER
COLUMN
id
SET
DEFAULT
nextval
(
'public.resource_label_events_id_seq'
::
regclass
);
ALTER
TABLE
ONLY
public
.
resource_milestone_events
ALTER
COLUMN
id
SET
DEFAULT
nextval
(
'public.resource_milestone_events_id_seq'
::
regclass
);
...
...
@@ -8709,6 +8729,9 @@ ALTER TABLE ONLY public.releases
ALTER
TABLE
ONLY
public
.
remote_mirrors
ADD
CONSTRAINT
remote_mirrors_pkey
PRIMARY
KEY
(
id
);
ALTER
TABLE
ONLY
public
.
requirements_management_test_reports
ADD
CONSTRAINT
requirements_management_test_reports_pkey
PRIMARY
KEY
(
id
);
ALTER
TABLE
ONLY
public
.
requirements
ADD
CONSTRAINT
requirements_pkey
PRIMARY
KEY
(
id
);
...
...
@@ -10504,6 +10527,12 @@ CREATE INDEX index_remote_mirrors_on_project_id ON public.remote_mirrors USING b
CREATE
UNIQUE
INDEX
index_repository_languages_on_project_and_languages_id
ON
public
.
repository_languages
USING
btree
(
project_id
,
programming_language_id
);
CREATE
INDEX
index_requirements_management_test_reports_on_author_id
ON
public
.
requirements_management_test_reports
USING
btree
(
author_id
);
CREATE
INDEX
index_requirements_management_test_reports_on_pipeline_id
ON
public
.
requirements_management_test_reports
USING
btree
(
pipeline_id
);
CREATE
INDEX
index_requirements_management_test_reports_on_requirement_id
ON
public
.
requirements_management_test_reports
USING
btree
(
requirement_id
);
CREATE
INDEX
index_requirements_on_author_id
ON
public
.
requirements
USING
btree
(
author_id
);
CREATE
INDEX
index_requirements_on_created_at
ON
public
.
requirements
USING
btree
(
created_at
);
...
...
@@ -11729,6 +11758,9 @@ ALTER TABLE ONLY public.service_desk_settings
ALTER
TABLE
ONLY
public
.
group_custom_attributes
ADD
CONSTRAINT
fk_rails_246e0db83a
FOREIGN
KEY
(
group_id
)
REFERENCES
public
.
namespaces
(
id
)
ON
DELETE
CASCADE
;
ALTER
TABLE
ONLY
public
.
requirements_management_test_reports
ADD
CONSTRAINT
fk_rails_24cecc1e68
FOREIGN
KEY
(
pipeline_id
)
REFERENCES
public
.
ci_pipelines
(
id
)
ON
DELETE
SET
NULL
;
ALTER
TABLE
ONLY
public
.
group_wiki_repositories
ADD
CONSTRAINT
fk_rails_26f867598c
FOREIGN
KEY
(
group_id
)
REFERENCES
public
.
namespaces
(
id
)
ON
DELETE
CASCADE
;
...
...
@@ -12470,6 +12502,9 @@ ALTER TABLE ONLY public.subscriptions
ALTER
TABLE
ONLY
public
.
operations_strategies
ADD
CONSTRAINT
fk_rails_d183b6e6dd
FOREIGN
KEY
(
feature_flag_id
)
REFERENCES
public
.
operations_feature_flags
(
id
)
ON
DELETE
CASCADE
;
ALTER
TABLE
ONLY
public
.
requirements_management_test_reports
ADD
CONSTRAINT
fk_rails_d1e8b498bf
FOREIGN
KEY
(
author_id
)
REFERENCES
public
.
users
(
id
)
ON
DELETE
SET
NULL
;
ALTER
TABLE
ONLY
public
.
pool_repositories
ADD
CONSTRAINT
fk_rails_d2711daad4
FOREIGN
KEY
(
source_project_id
)
REFERENCES
public
.
projects
(
id
)
ON
DELETE
SET
NULL
;
...
...
@@ -12614,6 +12649,9 @@ ALTER TABLE ONLY public.merge_trains
ALTER
TABLE
ONLY
public
.
ci_runner_namespaces
ADD
CONSTRAINT
fk_rails_f9d9ed3308
FOREIGN
KEY
(
namespace_id
)
REFERENCES
public
.
namespaces
(
id
)
ON
DELETE
CASCADE
;
ALTER
TABLE
ONLY
public
.
requirements_management_test_reports
ADD
CONSTRAINT
fk_rails_fb3308ad55
FOREIGN
KEY
(
requirement_id
)
REFERENCES
public
.
requirements
(
id
)
ON
DELETE
CASCADE
;
ALTER
TABLE
ONLY
public
.
board_project_recent_visits
ADD
CONSTRAINT
fk_rails_fb6fc419cb
FOREIGN
KEY
(
user_id
)
REFERENCES
public
.
users
(
id
)
ON
DELETE
CASCADE
;
...
...
@@ -13854,6 +13892,9 @@ COPY "schema_migrations" (version) FROM STDIN;
20200511145545
20200511162057
20200511162115
20200511181027
20200511191027
20200511208012
20200511220023
20200512085150
20200512164334
...
...
ee/app/models/ee/user.rb
View file @
72dd387a
...
...
@@ -35,6 +35,7 @@ module EE
has_many
:reviews
,
foreign_key: :author_id
,
inverse_of: :author
has_many
:epics
,
foreign_key: :author_id
has_many
:requirements
,
foreign_key: :author_id
,
inverse_of: :author
,
class_name:
'RequirementsManagement::Requirement'
has_many
:test_reports
,
foreign_key: :author_id
,
inverse_of: :author
,
class_name:
'RequirementsManagement::TestReport'
has_many
:assigned_epics
,
foreign_key: :assignee_id
,
class_name:
"Epic"
has_many
:path_locks
,
dependent: :destroy
# rubocop: disable Cop/ActiveRecordDependent
has_many
:vulnerability_feedback
,
foreign_key: :author_id
,
class_name:
'Vulnerabilities::Feedback'
...
...
ee/app/models/requirements_management.rb
0 → 100644
View file @
72dd387a
# frozen_string_literal: true
module
RequirementsManagement
def
self
.
table_name_prefix
'requirements_management_'
end
end
ee/app/models/requirements_management/requirement.rb
View file @
72dd387a
...
...
@@ -19,6 +19,8 @@ module RequirementsManagement
belongs_to
:author
,
inverse_of: :requirements
,
class_name:
'User'
belongs_to
:project
,
inverse_of: :requirements
has_many
:test_reports
,
inverse_of: :requirements
has_internal_id
:iid
,
scope: :project
,
init:
->
(
s
)
{
s
&
.
project
&
.
requirements
&
.
maximum
(
:iid
)
}
validates
:author
,
:project
,
:title
,
presence:
true
...
...
ee/app/models/requirements_management/test_report.rb
0 → 100644
View file @
72dd387a
# frozen_string_literal: true
module
RequirementsManagement
class
TestReport
<
ApplicationRecord
belongs_to
:requirement
,
inverse_of: :test_reports
belongs_to
:author
,
inverse_of: :test_reports
,
class_name:
'User'
belongs_to
:pipeline
,
class_name:
'Ci::Pipeline'
validates
:requirement
,
:state
,
presence:
true
enum
state:
{
passed:
1
}
end
end
ee/changelogs/unreleased/issue_215506.yml
0 → 100644
View file @
72dd387a
---
title
:
Create test reports table
merge_request
:
31643
author
:
type
:
added
ee/spec/factories/requirements_management/test_reports.rb
0 → 100644
View file @
72dd387a
# frozen_string_literal: true
FactoryBot
.
define
do
factory
:test_report
,
class:
'RequirementsManagement::TestReport'
do
author
requirement
pipeline
factory: :ci_pipeline
state
{
:passed
}
end
end
ee/spec/models/requirements_management/test_report_spec.rb
0 → 100644
View file @
72dd387a
# frozen_string_literal: true
require
'spec_helper'
describe
RequirementsManagement
::
TestReport
do
describe
'associations'
do
subject
{
build
(
:test_report
)
}
it
{
is_expected
.
to
belong_to
(
:author
).
class_name
(
'User'
)
}
it
{
is_expected
.
to
belong_to
(
:requirement
)
}
it
{
is_expected
.
to
belong_to
(
:pipeline
)
}
end
describe
'validations'
do
subject
{
build
(
:test_report
)
}
it
{
is_expected
.
to
validate_presence_of
(
:requirement
)
}
it
{
is_expected
.
to
validate_presence_of
(
:state
)
}
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