Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add restriction non negative partner quota #4658

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/partner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Partner < ApplicationRecord
validates :email, presence: true, uniqueness: { case_sensitive: false },
format: { with: URI::MailTo::EMAIL_REGEXP, on: :create }

validates :quota, numericality: true, allow_blank: true
validates :quota, numericality: { greater_than_or_equal_to: 0 }, allow_blank: true

validate :correct_document_mime_type

Expand Down
6 changes: 6 additions & 0 deletions spec/models/partner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@
end

it { should validate_numericality_of(:quota).allow_nil }

it "validates that the quota is greater than or equal to 0" do
expect(build(:partner, quota: -1)).not_to be_valid
expect(build(:partner, quota: 0)).to be_valid
expect(build(:partner, quota: 1)).to be_valid
end
end

context "callbacks" do
Expand Down