Fixed follow up for issue #2090 with order/group overviews - 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-28 12:33:07 +02:00
parent 05adf9a534
commit 5c4c41db6f
2 changed files with 55 additions and 3 deletions

View file

@ -99,7 +99,7 @@ returns
'created_at'
end
end
order_by = "tickets.#{order_by}"
order_by = "#{ActiveRecord::Base.connection.quote_table_name('tickets')}.#{ActiveRecord::Base.connection.quote_column_name(order_by)}"
# check if group by exists
if overview.group_by.present?
@ -110,7 +110,7 @@ returns
end
end
if group_by
order_by = "tickets.#{group_by}, #{order_by}"
order_by = "#{ActiveRecord::Base.connection.quote_table_name('tickets')}.#{ActiveRecord::Base.connection.quote_column_name(group_by)}, #{order_by}"
end
end

View file

@ -698,7 +698,7 @@ class ObjectManagerTest < ActiveSupport::TestCase
assert_equal(0, ObjectManager::Attribute.migrations.count)
# create example ticket
ticket1 = Ticket.create(
ticket1 = Ticket.create!(
title: 'some attribute test3',
group: Group.lookup(name: 'Users'),
customer_id: 2,
@ -735,5 +735,57 @@ class ObjectManagerTest < ActiveSupport::TestCase
assert_equal(ticket_count, 1)
assert_equal(tickets[0].id, ticket1.id)
agent1 = User.create_or_update(
login: 'agent1@example.com',
firstname: 'Notification',
lastname: 'Agent1',
email: 'agent1@example.com',
password: 'agentpw',
active: true,
roles: Role.where(name: 'Agent'),
groups: Group.all,
updated_by_id: 1,
created_by_id: 1,
)
overview1 = Overview.create!(
name: 'Overview1',
link: 'my_overview',
roles: Role.all,
condition: {
'ticket.1_a_anfrage_status' => {
operator: 'is',
value: 'some attribute text',
},
},
order: {
by: '1_a_anfrage_status',
direction: 'DESC',
},
group_by: '1_a_anfrage_status',
view: {
d: %w[title customer state created_at],
s: %w[number title customer state created_at],
m: %w[number title customer state created_at],
view_mode_default: 's',
},
prio: 1,
updated_by_id: 1,
created_by_id: 1,
)
result = Ticket::Overviews.index(agent1)
overview = nil
result.each do |local_overview|
next if local_overview[:overview][:name] != 'Overview1'
overview = local_overview
break
end
assert(overview)
assert_equal(1, overview[:tickets].count)
assert_equal(1, overview[:count])
assert_equal(ticket1.id, overview[:tickets][0][:id])
end
end