Show list of customer/org tickets in created_at order (fixes #2296)
This commit is contained in:
parent
bbabae7c2c
commit
66e8d58f29
2 changed files with 35 additions and 0 deletions
|
@ -8,6 +8,8 @@ module TicketStats
|
||||||
limit: limit,
|
limit: limit,
|
||||||
condition: condition,
|
condition: condition,
|
||||||
current_user: current_user,
|
current_user: current_user,
|
||||||
|
sort_by: 'created_at',
|
||||||
|
order_by: 'desc',
|
||||||
)
|
)
|
||||||
assets_of_tickets(tickets, assets)
|
assets_of_tickets(tickets, assets)
|
||||||
end
|
end
|
||||||
|
|
|
@ -2079,4 +2079,37 @@ RSpec.describe 'Ticket', type: :request do
|
||||||
expect(json_response['tickets']).to eq([ticket2.id, ticket1.id])
|
expect(json_response['tickets']).to eq([ticket2.id, ticket1.id])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'stats' do
|
||||||
|
let(:ticket1) { create(:ticket, customer: customer, organization: organization) }
|
||||||
|
let(:ticket2) { create(:ticket, customer: customer, organization: organization) }
|
||||||
|
let(:ticket3) { create(:ticket, customer: customer, organization: organization) }
|
||||||
|
let(:customer) { create(:customer_user, organization: organization) }
|
||||||
|
let(:organization) { create(:organization, shared: false) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
authenticated_as(admin_user)
|
||||||
|
|
||||||
|
ticket1
|
||||||
|
travel 2.minutes
|
||||||
|
ticket2
|
||||||
|
travel 2.minutes
|
||||||
|
ticket3
|
||||||
|
travel 2.minutes
|
||||||
|
ticket2.touch # rubocop:disable Rails/SkipsModelValidations
|
||||||
|
end
|
||||||
|
|
||||||
|
# https://github.com/zammad/zammad/issues/2296
|
||||||
|
it 'orders tickets by created_at desc (#2296)' do
|
||||||
|
get '/api/v1/ticket_stats', params: { organization_id: organization.id, user_id: customer.id }, as: :json
|
||||||
|
|
||||||
|
expect(response).to have_http_status(200)
|
||||||
|
expect(json_response)
|
||||||
|
.to be_a_kind_of(Hash)
|
||||||
|
.and include('user' => hash_including('open_ids' => [ticket3.id, ticket2.id, ticket1.id]))
|
||||||
|
.and include('organization' => hash_including('open_ids' => [ticket3.id, ticket2.id, ticket1.id]))
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue