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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
95a5cc92
Commit
95a5cc92
authored
Oct 06, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restrict the number of permitted boards per project to one
parent
fb5a4202
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletion
+15
-1
app/models/project.rb
app/models/project.rb
+6
-1
spec/models/project_spec.rb
spec/models/project_spec.rb
+9
-0
No files found.
app/models/project.rb
View file @
95a5cc92
...
...
@@ -16,6 +16,7 @@ class Project < ActiveRecord::Base
extend
Gitlab
::
ConfigHelper
NUMBER_OF_PERMITTED_BOARDS
=
1
UNKNOWN_IMPORT_URL
=
'http://unknown.git'
cache_markdown_field
:description
,
pipeline: :description
...
...
@@ -65,7 +66,7 @@ class Project < ActiveRecord::Base
belongs_to
:namespace
has_one
:last_event
,
->
{
order
'events.created_at DESC'
},
class_name:
'Event'
,
foreign_key:
'project_id'
has_many
:boards
,
dependent: :destroy
has_many
:boards
,
before_add: :validate_board_limit
,
dependent: :destroy
# Project services
has_many
:services
...
...
@@ -1338,4 +1339,8 @@ class Project < ActiveRecord::Base
shared_projects
.
any?
end
def
validate_board_limit
(
board
)
raise
StandardError
,
'Number of permitted boards exceeded'
if
boards
.
size
>=
NUMBER_OF_PERMITTED_BOARDS
end
end
spec/models/project_spec.rb
View file @
95a5cc92
...
...
@@ -94,6 +94,15 @@ describe Project, models: true do
end
end
end
describe
'#boards'
do
it
'raises an error when attempting to add more than one board to the project'
do
subject
.
boards
.
build
expect
{
subject
.
boards
.
build
}.
to
raise_error
(
StandardError
,
'Number of permitted boards exceeded'
)
expect
(
subject
.
boards
.
size
).
to
eq
1
end
end
end
describe
'modules'
do
...
...
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