Add Project::BoardLimitExcedeed error class

parent c5ea58b6
...@@ -16,6 +16,8 @@ class Project < ActiveRecord::Base ...@@ -16,6 +16,8 @@ class Project < ActiveRecord::Base
extend Gitlab::ConfigHelper extend Gitlab::ConfigHelper
class BoardLimitExceeded < StandardError; end
NUMBER_OF_PERMITTED_BOARDS = 1 NUMBER_OF_PERMITTED_BOARDS = 1
UNKNOWN_IMPORT_URL = 'http://unknown.git' UNKNOWN_IMPORT_URL = 'http://unknown.git'
...@@ -1341,6 +1343,6 @@ class Project < ActiveRecord::Base ...@@ -1341,6 +1343,6 @@ class Project < ActiveRecord::Base
end end
def validate_board_limit(board) def validate_board_limit(board)
raise StandardError, 'Number of permitted boards exceeded' if boards.size >= NUMBER_OF_PERMITTED_BOARDS raise BoardLimitExceeded, 'Number of permitted boards exceeded' if boards.size >= NUMBER_OF_PERMITTED_BOARDS
end end
end end
...@@ -99,7 +99,7 @@ describe Project, models: true do ...@@ -99,7 +99,7 @@ describe Project, models: true do
it 'raises an error when attempting to add more than one board to the project' do it 'raises an error when attempting to add more than one board to the project' do
subject.boards.build subject.boards.build
expect { subject.boards.build }.to raise_error(StandardError, 'Number of permitted boards exceeded') expect { subject.boards.build }.to raise_error(Project::BoardLimitExceeded, 'Number of permitted boards exceeded')
expect(subject.boards.size).to eq 1 expect(subject.boards.size).to eq 1
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment