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
dda8f64e
Commit
dda8f64e
authored
Nov 19, 2020
by
Heinrich Lee Yu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update List models with iteration association
Also adds validations for iteration lists
parent
4b66d81b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
46 additions
and
5 deletions
+46
-5
app/models/list.rb
app/models/list.rb
+1
-1
ee/app/models/ee/list.rb
ee/app/models/ee/list.rb
+12
-4
ee/spec/models/ee/list_spec.rb
ee/spec/models/ee/list_spec.rb
+28
-0
lib/gitlab/import_export/project/import_export.yml
lib/gitlab/import_export/project/import_export.yml
+1
-0
locale/gitlab.pot
locale/gitlab.pot
+3
-0
spec/lib/gitlab/import_export/all_models.yml
spec/lib/gitlab/import_export/all_models.yml
+1
-0
No files found.
app/models/list.rb
View file @
dda8f64e
...
...
@@ -7,7 +7,7 @@ class List < ApplicationRecord
belongs_to
:label
has_many
:list_user_preferences
enum
list_type:
{
backlog:
0
,
label:
1
,
closed:
2
,
assignee:
3
,
milestone:
4
}
enum
list_type:
{
backlog:
0
,
label:
1
,
closed:
2
,
assignee:
3
,
milestone:
4
,
iteration:
5
}
validates
:board
,
:list_type
,
presence:
true
,
unless: :importing?
validates
:label
,
:position
,
presence:
true
,
if: :label?
...
...
ee/app/models/ee/list.rb
View file @
dda8f64e
...
...
@@ -19,11 +19,14 @@ module EE
base
.
belongs_to
:user
base
.
belongs_to
:milestone
base
.
belongs_to
:iteration
base
.
validates
:user
,
presence:
true
,
if: :assignee?
base
.
validates
:milestone
,
presence:
true
,
if: :milestone?
base
.
validates
:iteration
,
presence:
true
,
if: :iteration?
base
.
validates
:user_id
,
uniqueness:
{
scope: :board_id
},
if: :assignee?
base
.
validates
:milestone_id
,
uniqueness:
{
scope: :board_id
},
if: :milestone?
base
.
validates
:iteration_id
,
uniqueness:
{
scope: :board_id
},
if: :iteration?
base
.
validates
:max_issue_count
,
numericality:
{
only_integer:
true
,
greater_than_or_equal_to:
0
}
base
.
validates
:max_issue_weight
,
numericality:
{
only_integer:
true
,
greater_than_or_equal_to:
0
}
base
.
validates
:limit_metric
,
inclusion:
{
...
...
@@ -32,11 +35,14 @@ module EE
allow_nil:
true
}
base
.
validates
:list_type
,
exclusion:
{
in:
%w[assignee]
,
message:
_
(
'Assignee lists not available with your current license'
)
},
exclusion:
{
in:
%w[assignee]
,
message:
->
(
_object
,
_data
)
{
_
(
'Assignee lists not available with your current license'
)
}
},
unless:
->
{
board
&
.
resource_parent
&
.
feature_available?
(
:board_assignee_lists
)
}
base
.
validates
:list_type
,
exclusion:
{
in:
%w[milestone]
,
message:
_
(
'Milestone lists not available with your current license'
)
},
exclusion:
{
in:
%w[milestone]
,
message:
->
(
_object
,
_data
)
{
_
(
'Milestone lists not available with your current license'
)
}
},
unless:
->
{
board
&
.
resource_parent
&
.
feature_available?
(
:board_milestone_lists
)
}
base
.
validates
:list_type
,
exclusion:
{
in:
%w[iteration]
,
message:
->
(
_object
,
_data
)
{
_
(
'Iteration lists not available with your current license'
)
}
},
unless:
->
{
board
&
.
resource_parent
&
.
feature_available?
(
:iterations
)
}
base
.
scope
:without_types
,
->
(
list_types
)
{
where
.
not
(
list_type:
list_types
)
}
end
...
...
@@ -58,6 +64,8 @@ module EE
user
.
to_reference
when
'milestone'
milestone
.
title
when
'iteration'
iteration
.
title
else
super
end
...
...
@@ -78,11 +86,11 @@ module EE
module
ClassMethods
def
destroyable_types
super
+
[
:assignee
,
:milestone
]
super
+
[
:assignee
,
:milestone
,
:iteration
]
end
def
movable_types
super
+
[
:assignee
,
:milestone
]
super
+
[
:assignee
,
:milestone
,
:iteration
]
end
end
end
...
...
ee/spec/models/ee/list_spec.rb
View file @
dda8f64e
...
...
@@ -8,6 +8,7 @@ RSpec.describe List do
describe
'relationships'
do
it
{
is_expected
.
to
belong_to
(
:user
)
}
it
{
is_expected
.
to
belong_to
(
:milestone
)
}
it
{
is_expected
.
to
belong_to
(
:iteration
)
}
end
describe
'validations'
do
...
...
@@ -75,6 +76,33 @@ RSpec.describe List do
end
end
context
'when it is an iteration type'
do
let
(
:iteration
)
{
build
(
:iteration
,
title:
'awesome-iteration'
)
}
subject
{
described_class
.
new
(
list_type: :iteration
,
iteration:
iteration
,
board:
board
)
}
it
{
is_expected
.
to
be_destroyable
}
it
{
is_expected
.
to
be_movable
}
describe
'validations'
do
it
{
is_expected
.
to
validate_presence_of
(
:iteration
)
}
it
'is invalid when feature is not available'
do
stub_licensed_features
(
iterations:
false
)
expect
(
subject
).
to
be_invalid
expect
(
subject
.
errors
[
:list_type
])
.
to
contain_exactly
(
'Iteration lists not available with your current license'
)
end
end
describe
'#title'
do
it
'returns the iteration title'
do
expect
(
subject
.
title
).
to
eq
(
'awesome-iteration'
)
end
end
end
describe
'#wip_limits_available?'
do
let!
(
:project
)
{
create
(
:project
)
}
let!
(
:group
)
{
create
(
:group
)
}
...
...
lib/gitlab/import_export/project/import_export.yml
View file @
dda8f64e
...
...
@@ -347,6 +347,7 @@ excluded_attributes:
-
:board_id
-
:label_id
-
:milestone_id
-
:iteration_id
epic
:
-
:start_date_sourcing_milestone_id
-
:due_date_sourcing_milestone_id
...
...
locale/gitlab.pot
View file @
dda8f64e
...
...
@@ -15384,6 +15384,9 @@ msgstr ""
msgid "Iteration changed to"
msgstr ""
msgid "Iteration lists not available with your current license"
msgstr ""
msgid "Iteration removed"
msgstr ""
...
...
spec/lib/gitlab/import_export/all_models.yml
View file @
dda8f64e
...
...
@@ -656,6 +656,7 @@ boards:
lists
:
-
user
-
milestone
-
iteration
-
board
-
label
-
list_user_preferences
...
...
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