BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
99e928f1
Commit
99e928f1
authored
Oct 14, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add restriction to number of permitted priorities per project label
parent
67314e95
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
1 deletion
+21
-1
project_label.rb
app/models/project_label.rb
+9
-0
project_label_spec.rb
spec/models/project_label_spec.rb
+12
-1
No files found.
app/models/project_label.rb
View file @
99e928f1
class
ProjectLabel
<
Label
NUMBER_OF_PRIORITIES
=
1
belongs_to
:project
validates
:project
,
presence:
true
validate
:permitted_numbers_of_priorities
validate
:title_must_not_exist_at_group_level
delegate
:group
,
to: :project
,
allow_nil:
true
...
...
@@ -20,4 +23,10 @@ class ProjectLabel < Label
errors
.
add
(
:title
,
:label_already_exists_at_group_level
,
group:
group
.
name
)
end
end
def
permitted_numbers_of_priorities
if
priorities
&&
priorities
.
size
>=
NUMBER_OF_PRIORITIES
errors
.
add
(
:priorities
,
'Number of permitted priorities exceeded'
)
end
end
end
spec/models/project_label_spec.rb
View file @
99e928f1
...
...
@@ -48,7 +48,18 @@ describe ProjectLabel, models: true do
project_label
.
valid?
expect
(
project_label
.
errors
[
:title
]).
to
be_empty
expect
(
project_label
.
errors
[
:title
]).
to
be_empty
end
end
context
'when attempting to add more than one priority to the project label'
do
it
'returns error'
do
subject
.
priorities
.
build
subject
.
priorities
.
build
subject
.
valid?
expect
(
subject
.
errors
[
:priorities
]).
to
include
'Number of permitted priorities exceeded'
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