summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2016-10-20 18:42:51 +0000
committerDouwe Maan <douwe@gitlab.com>2016-10-20 18:42:51 +0000
commit1b31867ec053dfcb03043c4be7dff104d8977898 (patch)
tree4db47046c3e3682c06cc7a224e31c34755253430
parent672ab77bf42383a3fa90905d05b303fbe34263e8 (diff)
parentfab393984a4685164886c974747d312da21e1798 (diff)
downloadgitlab-ce-1b31867ec053dfcb03043c4be7dff104d8977898.tar.gz
Merge branch 'fix/validate-board-limit' into 'master'
[ci skip] Add a comment explaining validate_board_limit callback ## What are the relevant issue numbers? https://gitlab.com/gitlab-org/gitlab-ee/issues/929 See merge request !7023
-rw-r--r--app/models/project.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 6685baab699..af117f0acb0 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -1339,6 +1339,13 @@ class Project < ActiveRecord::Base
shared_projects.any?
end
+ # Similar to the normal callbacks that hook into the life cycle of an
+ # Active Record object, you can also define callbacks that get triggered
+ # when you add an object to an association collection. If any of these
+ # callbacks throw an exception, the object will not be added to the
+ # collection. Before you add a new board to the boards collection if you
+ # already have 1, 2, or n it will fail, but it if you have 0 that is lower
+ # than the number of permitted boards per project it won't fail.
def validate_board_limit(board)
raise BoardLimitExceeded, 'Number of permitted boards exceeded' if boards.size >= NUMBER_OF_PERMITTED_BOARDS
end