Fixed issue #2090 - Unable to create an overview with a new ticket file which is starting with number like "1_test".

This commit is contained in:
Martin Edenhofer 2018-06-19 19:32:28 +02:00
parent db82816f87
commit 0dbfcd0edf
2 changed files with 76 additions and 2 deletions

View file

@ -557,11 +557,11 @@ condition example
# get attributes # get attributes
attributes = attribute.split(/\./) attributes = attribute.split(/\./)
attribute = "#{attributes[0]}s.#{attributes[1]}" attribute = "#{ActiveRecord::Base.connection.quote_table_name("#{attributes[0]}s")}.#{ActiveRecord::Base.connection.quote_column_name(attributes[1])}"
# magic selectors # magic selectors
if attributes[0] == 'ticket' && attributes[1] == 'out_of_office_replacement_id' if attributes[0] == 'ticket' && attributes[1] == 'out_of_office_replacement_id'
attribute = "#{attributes[0]}s.owner_id" attribute = "#{ActiveRecord::Base.connection.quote_table_name("#{attributes[0]}s")}.#{ActiveRecord::Base.connection.quote_column_name('owner_id')}"
end end
if attributes[0] == 'ticket' && attributes[1] == 'tags' if attributes[0] == 'ticket' && attributes[1] == 'tags'

View file

@ -663,4 +663,78 @@ class ObjectManagerTest < ActiveSupport::TestCase
end end
test 'c object manager attribute - certain names' do
assert_equal(false, ObjectManager::Attribute.pending_migration?)
assert_equal(0, ObjectManager::Attribute.where(to_migrate: true).count)
assert_equal(0, ObjectManager::Attribute.migrations.count)
attribute1 = ObjectManager::Attribute.add(
object: 'Ticket',
name: '1_a_anfrage_status',
display: '1_a_anfrage_status',
data_type: 'input',
data_option: {
maxlength: 200,
type: 'text',
null: true,
},
active: true,
screens: {},
position: 20,
created_by_id: 1,
updated_by_id: 1,
)
assert(attribute1)
assert_equal(true, ObjectManager::Attribute.pending_migration?)
assert_equal(1, ObjectManager::Attribute.where(to_migrate: true).count)
assert_equal(1, ObjectManager::Attribute.migrations.count)
# execute migrations
assert(ObjectManager::Attribute.migration_execute)
assert_equal(false, ObjectManager::Attribute.pending_migration?)
assert_equal(0, ObjectManager::Attribute.where(to_migrate: true).count)
assert_equal(0, ObjectManager::Attribute.migrations.count)
# create example ticket
ticket1 = Ticket.create(
title: 'some attribute test3',
group: Group.lookup(name: 'Users'),
customer_id: 2,
state: Ticket::State.lookup(name: 'new'),
priority: Ticket::Priority.lookup(name: '2 normal'),
'1_a_anfrage_status': 'some attribute text',
updated_by_id: 1,
created_by_id: 1,
)
assert('ticket1 created', ticket1)
assert_equal('some attribute test3', ticket1.title)
assert_equal('Users', ticket1.group.name)
assert_equal('new', ticket1.state.name)
assert_equal('some attribute text', ticket1['1_a_anfrage_status'])
condition = {
'ticket.title' => {
operator: 'is',
value: 'some attribute test3',
},
}
ticket_count, tickets = Ticket.selectors(condition, 10)
assert_equal(ticket_count, 1)
assert_equal(tickets[0].id, ticket1.id)
condition = {
'ticket.1_a_anfrage_status' => {
operator: 'is',
value: 'some attribute text',
},
}
ticket_count, tickets = Ticket.selectors(condition, 10)
assert_equal(ticket_count, 1)
assert_equal(tickets[0].id, ticket1.id)
end
end end