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
321b0a22
Commit
321b0a22
authored
Feb 18, 2022
by
Eugenia Grieff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change columns order
- Remove unecessary scopes - Test scopes in IssueLink
parent
01443314
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
35 deletions
+32
-35
db/migrate/20220211125954_create_related_epic_links.rb
db/migrate/20220211125954_create_related_epic_links.rb
+1
-1
db/structure.sql
db/structure.sql
+2
-2
ee/app/models/epic/related_epic_link.rb
ee/app/models/epic/related_epic_link.rb
+0
-3
ee/spec/models/epic/related_epic_link_spec.rb
ee/spec/models/epic/related_epic_link_spec.rb
+0
-29
spec/models/issue_link_spec.rb
spec/models/issue_link_spec.rb
+29
-0
No files found.
db/migrate/20220211125954_create_related_epic_links.rb
View file @
321b0a22
...
...
@@ -5,8 +5,8 @@ class CreateRelatedEpicLinks < Gitlab::Database::Migration[1.0]
create_table
:related_epic_links
do
|
t
|
t
.
references
:source
,
index:
true
,
foreign_key:
{
to_table: :epics
,
on_delete: :cascade
},
null:
false
t
.
references
:target
,
index:
true
,
foreign_key:
{
to_table: :epics
,
on_delete: :cascade
},
null:
false
t
.
integer
:link_type
,
null:
false
,
default:
0
,
limit:
2
t
.
timestamps_with_timezone
null:
false
t
.
integer
:link_type
,
null:
false
,
default:
0
,
limit:
2
t
.
index
[
:source_id
,
:target_id
],
unique:
true
end
...
...
db/structure.sql
View file @
321b0a22
...
...
@@ -19201,9 +19201,9 @@ CREATE TABLE related_epic_links (
id bigint NOT NULL,
source_id bigint NOT NULL,
target_id bigint NOT NULL,
link_type smallint DEFAULT 0 NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL
updated_at timestamp with time zone NOT NULL,
link_type smallint DEFAULT 0 NOT NULL
);
CREATE SEQUENCE related_epic_links_id_seq
ee/app/models/epic/related_epic_link.rb
View file @
321b0a22
...
...
@@ -8,9 +8,6 @@ class Epic::RelatedEpicLink < ApplicationRecord
self
.
table_name
=
'related_epic_links'
scope
:for_source_epic
,
->
(
epic
)
{
where
(
source_id:
epic
.
id
)
}
scope
:for_target_epic
,
->
(
epic
)
{
where
(
target_id:
epic
.
id
)
}
private
def
issuable_type
...
...
ee/spec/models/epic/related_epic_link_spec.rb
View file @
321b0a22
...
...
@@ -9,33 +9,4 @@ RSpec.describe Epic::RelatedEpicLink do
let
(
:issuable_class
)
{
'Epic'
}
let
(
:issuable_link_factory
)
{
:related_epic_link
}
end
describe
'Scopes'
do
let_it_be
(
:epic1
)
{
create
(
:epic
)
}
let_it_be
(
:epic2
)
{
create
(
:epic
)
}
describe
'.for_source_epic'
do
it
'includes related epics for source epic'
do
source_epic
=
create
(
:epic
)
related_epic_link_1
=
create
(
:related_epic_link
,
source:
source_epic
,
target:
epic1
)
related_epic_link_2
=
create
(
:related_epic_link
,
source:
source_epic
,
target:
epic2
)
result
=
described_class
.
for_source_epic
(
source_epic
)
expect
(
result
).
to
contain_exactly
(
related_epic_link_1
,
related_epic_link_2
)
end
end
describe
'.for_target_epic'
do
it
'includes related epics for target epic'
do
target_epic
=
create
(
:epic
)
related_epic_link_1
=
create
(
:related_epic_link
,
source:
epic1
,
target:
target_epic
)
related_epic_link_2
=
create
(
:related_epic_link
,
source:
epic2
,
target:
target_epic
)
result
=
described_class
.
for_target_epic
(
target_epic
)
expect
(
result
).
to
contain_exactly
(
related_epic_link_1
,
related_epic_link_2
)
end
end
end
end
spec/models/issue_link_spec.rb
View file @
321b0a22
...
...
@@ -9,4 +9,33 @@ RSpec.describe IssueLink do
let
(
:issuable_class
)
{
'Issue'
}
let
(
:issuable_link_factory
)
{
:issue_link
}
end
describe
'Scopes'
do
let_it_be
(
:issue1
)
{
create
(
:issue
)
}
let_it_be
(
:issue2
)
{
create
(
:issue
)
}
describe
'.for_source_issue'
do
it
'includes linked issues for source issue'
do
source_issue
=
create
(
:issue
)
issue_link_1
=
create
(
:issue_link
,
source:
source_issue
,
target:
issue1
)
issue_link_2
=
create
(
:issue_link
,
source:
source_issue
,
target:
issue2
)
result
=
described_class
.
for_source_issue
(
source_issue
)
expect
(
result
).
to
contain_exactly
(
issue_link_1
,
issue_link_2
)
end
end
describe
'.for_target_issue'
do
it
'includes linked issues for target issue'
do
target_issue
=
create
(
:issue
)
issue_link_1
=
create
(
:issue_link
,
source:
issue1
,
target:
target_issue
)
issue_link_2
=
create
(
:issue_link
,
source:
issue2
,
target:
target_issue
)
result
=
described_class
.
for_target_issue
(
target_issue
)
expect
(
result
).
to
contain_exactly
(
issue_link_1
,
issue_link_2
)
end
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