Fixes #3089 - Domain based assignment can be enabled without domain being filled in
This commit is contained in:
parent
37a6a748c9
commit
cbf5359589
2 changed files with 28 additions and 1 deletions
|
@ -20,6 +20,7 @@ class Organization < ApplicationModel
|
||||||
before_update :domain_cleanup
|
before_update :domain_cleanup
|
||||||
|
|
||||||
validates :name, presence: true
|
validates :name, presence: true
|
||||||
|
validates :domain, presence: { message: 'required when Domain Based Assignment is enabled' }, if: :domain_assignment
|
||||||
|
|
||||||
activity_stream_permission 'admin.role'
|
activity_stream_permission 'admin.role'
|
||||||
|
|
||||||
|
|
|
@ -41,4 +41,30 @@ RSpec.describe Organization, type: :model do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#domain_assignment' do
|
||||||
|
it 'fails if enabled and domain is missing' do
|
||||||
|
organization.domain_assignment = true
|
||||||
|
organization.domain = nil
|
||||||
|
organization.valid?
|
||||||
|
|
||||||
|
expect(organization.errors[:domain]).to be_present
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'succeeds if enabled and domain is present' do
|
||||||
|
organization.domain_assignment = true
|
||||||
|
organization.domain = 'example.org'
|
||||||
|
organization.valid?
|
||||||
|
|
||||||
|
expect(organization.errors[:domain]).to be_empty
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'succeeds if disabled and domain is missing' do
|
||||||
|
organization.domain_assignment = false
|
||||||
|
organization.domain = nil
|
||||||
|
organization.valid?
|
||||||
|
|
||||||
|
expect(organization.errors[:domain]).to be_empty
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue