Fixes #3811 - Able to create custom fields for existing relation (e. g. ticket.state) - will lead to non bootable Zammad.
This commit is contained in:
parent
6de1053d4b
commit
cb48cd2dcd
2 changed files with 17 additions and 1 deletions
|
@ -820,7 +820,7 @@ is certain attribute used by triggers, overviews or schedulers
|
|||
end
|
||||
|
||||
record = object_lookup.name.constantize.new
|
||||
if record.respond_to?(name.to_sym) && record.attributes.key?(name) && new_record?
|
||||
if new_record? && (record.respond_to?(name.to_sym) || record.attributes.key?(name))
|
||||
errors.add(:name, "#{name} already exists!")
|
||||
end
|
||||
|
||||
|
|
|
@ -76,6 +76,22 @@ RSpec.describe ObjectManager::Attribute, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
%w[title tags].each do |not_editable_attribute|
|
||||
it "rejects '#{not_editable_attribute}' which is used" do
|
||||
expect do
|
||||
described_class.add attributes_for :object_manager_attribute_text, name: not_editable_attribute
|
||||
end.to raise_error(ActiveRecord::RecordInvalid, 'Validation failed: Name Attribute not editable!')
|
||||
end
|
||||
end
|
||||
|
||||
%w[priority state note number].each do |existing_attribute|
|
||||
it "rejects '#{existing_attribute}' which is used" do
|
||||
expect do
|
||||
described_class.add attributes_for :object_manager_attribute_text, name: existing_attribute
|
||||
end.to raise_error(ActiveRecord::RecordInvalid, "Validation failed: Name #{existing_attribute} already exists!")
|
||||
end
|
||||
end
|
||||
|
||||
it 'rejects duplicate attribute name of conflicting types' do
|
||||
attribute = attributes_for :object_manager_attribute_text
|
||||
described_class.add attribute
|
||||
|
|
Loading…
Reference in a new issue