Commit 0d731566 authored by Dylan Griffith's avatar Dylan Griffith

Merge branch '346580-fix-validation-for-license' into 'master'

Check validation for license only if new record

See merge request gitlab-org/gitlab!75352
parents 70478c6c 42699a76
......@@ -262,7 +262,7 @@ class License < ApplicationRecord
validate :valid_license
validate :check_users_limit, if: :new_record?, unless: [:validate_with_trueup?, :reconciliation_completed?]
validate :check_trueup, unless: :reconciliation_completed?, if: [:new_record?, :validate_with_trueup?]
validate :check_restricted_user_count, if: :reconciliation_completed?
validate :check_restricted_user_count, if: [:new_record?, :reconciliation_completed?]
validate :not_expired, if: :new_record?
before_validation :reset_license, if: :data_changed?
......
......@@ -162,6 +162,14 @@ RSpec.describe License do
'During the year before this license started'
)
end
it 'validates only if the new record' do
expect(license.valid?).to be_falsey
license.save!(validate: false)
expect(license.valid?).to be_truthy
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