提交 1b31867e 编写于 作者: D Douwe Maan

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
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册