diff options
author | Rémy Coutable <remy@rymai.me> | 2017-03-26 19:56:18 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-03-26 19:56:18 +0000 |
commit | c848735db6e77b7400ea88f9286bb12ff840a318 (patch) | |
tree | a41885e5ef64b1299dfdbe73b388212fd0b8ab11 | |
parent | 37b5b7a5e6907c364800f6f58d37b6c0412255da (diff) | |
parent | 7a1236031aabd900facdbe7bd4940e03175d477b (diff) | |
download | gitlab-ce-c848735db6e77b7400ea88f9286bb12ff840a318.tar.gz |
Merge branch '29116-maxint-error' into 'master'
Fix projects_limit RangeError on user create
Closes #29116
See merge request !10209
-rw-r--r-- | app/models/user.rb | 4 | ||||
-rw-r--r-- | app/views/admin/users/_access_levels.html.haml | 2 | ||||
-rw-r--r-- | changelogs/unreleased/29116-maxint-error.yml | 4 | ||||
-rw-r--r-- | spec/models/user_spec.rb | 1 |
4 files changed, 9 insertions, 2 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 5d19d873f43..1c2821bb91a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -115,7 +115,9 @@ class User < ActiveRecord::Base validates :notification_email, email: true, if: ->(user) { user.notification_email != user.email } validates :public_email, presence: true, uniqueness: true, email: true, allow_blank: true validates :bio, length: { maximum: 255 }, allow_blank: true - validates :projects_limit, presence: true, numericality: { greater_than_or_equal_to: 0 } + validates :projects_limit, + presence: true, + numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: Gitlab::Database::MAX_INT_VALUE } validates :username, namespace: true, presence: true, diff --git a/app/views/admin/users/_access_levels.html.haml b/app/views/admin/users/_access_levels.html.haml index 7855239dfe5..794aaec89bd 100644 --- a/app/views/admin/users/_access_levels.html.haml +++ b/app/views/admin/users/_access_levels.html.haml @@ -2,7 +2,7 @@ %legend Access .form-group = f.label :projects_limit, class: 'control-label' - .col-sm-10= f.number_field :projects_limit, min: 0, class: 'form-control' + .col-sm-10= f.number_field :projects_limit, min: 0, max: Gitlab::Database::MAX_INT_VALUE, class: 'form-control' .form-group = f.label :can_create_group, class: 'control-label' diff --git a/changelogs/unreleased/29116-maxint-error.yml b/changelogs/unreleased/29116-maxint-error.yml new file mode 100644 index 00000000000..06e976617d5 --- /dev/null +++ b/changelogs/unreleased/29116-maxint-error.yml @@ -0,0 +1,4 @@ +--- +title: Fix projects_limit RangeError on user create +merge_request: +author: Alexander Randa diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 90378179e32..570abd44dc6 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -81,6 +81,7 @@ describe User, models: true do it { is_expected.to validate_numericality_of(:projects_limit) } it { is_expected.to allow_value(0).for(:projects_limit) } it { is_expected.not_to allow_value(-1).for(:projects_limit) } + it { is_expected.not_to allow_value(Gitlab::Database::MAX_INT_VALUE + 1).for(:projects_limit) } it { is_expected.to validate_length_of(:bio).is_at_most(255) } |