Fixed 3578 - Can't create custom fields with name "type".
This commit is contained in:
parent
382291d0ae
commit
0fe81f4e0b
4 changed files with 21 additions and 2 deletions
|
@ -5,6 +5,9 @@ module HasObjectManagerAttributesValidation
|
|||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
# Disable table inheritance to allow columns with the name 'type'.
|
||||
self.inheritance_column = nil
|
||||
|
||||
validates_with ObjectManager::Attribute::Validation, on: %i[create update]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -89,8 +89,6 @@ class Ticket < ApplicationModel
|
|||
|
||||
association_attributes_ignored :flags, :mentions
|
||||
|
||||
self.inheritance_column = nil
|
||||
|
||||
attr_accessor :callback_loop
|
||||
|
||||
=begin
|
||||
|
|
|
@ -4,4 +4,20 @@ RSpec.shared_examples 'HasObjectManagerAttributesValidation' do
|
|||
it 'validates ObjectManager::Attributes' do
|
||||
expect(described_class.validators.map(&:class)).to include(ObjectManager::Attribute::Validation)
|
||||
end
|
||||
|
||||
context "when object attribute with name 'type' is used", db_strategy: :reset do
|
||||
before do
|
||||
skip('Skip context if a special type handling exists') if subject.try(:type_id)
|
||||
|
||||
if !ObjectManager::Attribute.exists?(object_lookup: ObjectLookup.find_by(name: described_class.name), name: 'type')
|
||||
create(:object_manager_attribute_text, name: 'type', object_name: described_class.name)
|
||||
ObjectManager::Attribute.migration_execute
|
||||
end
|
||||
end
|
||||
|
||||
it "check that the 'type' column can be updated" do
|
||||
expect { subject.reload.update(type: 'Example') }.not_to raise_error
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,6 +9,8 @@ require 'models/concerns/has_ticket_create_screen_impact_examples'
|
|||
require 'models/concerns/has_xss_sanitized_note_examples'
|
||||
|
||||
RSpec.describe Group, type: :model do
|
||||
subject(:group) { create(:group) }
|
||||
|
||||
it_behaves_like 'ApplicationModel'
|
||||
it_behaves_like 'CanBeImported'
|
||||
it_behaves_like 'HasObjectManagerAttributesValidation'
|
||||
|
|
Loading…
Reference in a new issue