Added new feature from issue #2469 - Add information "Ticket merged" to History
This commit is contained in:
parent
89385aaca6
commit
6d7480ab3f
4 changed files with 77 additions and 4 deletions
|
@ -634,6 +634,14 @@ class App.GenericHistory extends App.ControllerModal
|
|||
content = ''
|
||||
if item.type is 'notification' || item.type is 'email'
|
||||
content = "#{ @T( item.type ) } #{ @T( 'sent to' ) } '#{ item.value_to }'"
|
||||
else if item.type is 'received_merge'
|
||||
ticket = App.Ticket.find( item.id_from )
|
||||
ticket_link = "<a href=\"#ticket/zoom/#{ item.id_from }\">##{ ticket.number }</a>"
|
||||
content = "#{ @T( 'Ticket' ) } #{ ticket_link } #{ @T( 'was merged into this ticket' ) }"
|
||||
else if item.type is 'merged_into'
|
||||
ticket = App.Ticket.find( item.id_to )
|
||||
ticket_link = "<a href=\"#ticket/zoom/#{ item.id_to }\">##{ ticket.number }</a>"
|
||||
content = "#{ @T( 'This ticket was merged into' ) } #{ @T( 'ticket' ) } #{ ticket_link }"
|
||||
else
|
||||
content = "#{ @T( item.type ) } #{ @T(item.object) } "
|
||||
if item.attribute
|
||||
|
|
|
@ -310,7 +310,19 @@ returns
|
|||
# quiet update of reassign of articles
|
||||
Ticket::Article.where(ticket_id: id).update_all(['ticket_id = ?', data[:ticket_id]]) # rubocop:disable Rails/SkipsModelValidations
|
||||
|
||||
# update history
|
||||
# add merge event to both ticket's history (Issue #2469 - Add information "Ticket merged" to History)
|
||||
target_ticket.history_log(
|
||||
'received_merge',
|
||||
data[:user_id],
|
||||
id_to: target_ticket.id,
|
||||
id_from: id,
|
||||
)
|
||||
history_log(
|
||||
'merged_into',
|
||||
data[:user_id],
|
||||
id_to: target_ticket.id,
|
||||
id_from: id,
|
||||
)
|
||||
|
||||
# create new merge article
|
||||
Ticket::Article.create(
|
||||
|
@ -323,8 +335,6 @@ returns
|
|||
updated_by_id: data[:user_id],
|
||||
)
|
||||
|
||||
# add history to both
|
||||
|
||||
# reassign links to the new ticket
|
||||
# rubocop:disable Rails/SkipsModelValidations
|
||||
Link.where(
|
||||
|
|
|
@ -74,6 +74,35 @@ RSpec.describe Ticket, type: :model do
|
|||
.to raise_error("Can't merge ticket with it self!")
|
||||
end
|
||||
end
|
||||
|
||||
# Issue #2469 - Add information "Ticket merged" to History
|
||||
context 'when merging' do
|
||||
let(:merge_user) { create(:user) }
|
||||
|
||||
it 'creates history entries in both the origin ticket and the target ticket' do
|
||||
ticket.merge_to(ticket_id: target_ticket.id, user_id: merge_user.id)
|
||||
|
||||
expect(target_ticket.history_get.size).to eq 2
|
||||
|
||||
target_history = target_ticket.history_get.last
|
||||
expect(target_history['object']).to eq 'Ticket'
|
||||
expect(target_history['type']).to eq 'received_merge'
|
||||
expect(target_history['created_by_id']).to eq merge_user.id
|
||||
expect(target_history['o_id']).to eq target_ticket.id
|
||||
expect(target_history['id_to']).to eq target_ticket.id
|
||||
expect(target_history['id_from']).to eq ticket.id
|
||||
|
||||
expect(ticket.history_get.size).to eq 4
|
||||
|
||||
origin_history = ticket.reload.history_get[1]
|
||||
expect(origin_history['object']).to eq 'Ticket'
|
||||
expect(origin_history['type']).to eq 'merged_into'
|
||||
expect(origin_history['created_by_id']).to eq merge_user.id
|
||||
expect(origin_history['o_id']).to eq ticket.id
|
||||
expect(origin_history['id_to']).to eq target_ticket.id
|
||||
expect(origin_history['id_from']).to eq ticket.id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#perform_changes' do
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Ticket Create', type: :system do
|
||||
RSpec.describe 'Ticket Update', type: :system do
|
||||
|
||||
let(:group) { Group.find_by(name: 'Users') }
|
||||
|
||||
|
@ -22,4 +22,30 @@ RSpec.describe 'Ticket Create', type: :system do
|
|||
expect(ticket.reload.state.name).to eq('new')
|
||||
end
|
||||
end
|
||||
|
||||
# Issue #2469 - Add information "Ticket merged" to History
|
||||
context 'when merging tickets' do
|
||||
scenario 'tickets history of both tickets should show the merge event' do
|
||||
user = create :user
|
||||
origin_ticket = create :ticket, group: group
|
||||
target_ticket = create :ticket, group: group
|
||||
origin_ticket.merge_to(ticket_id: target_ticket.id, user_id: user.id)
|
||||
|
||||
visit "#ticket/zoom/#{origin_ticket.id}"
|
||||
click '.content.active .js-actions .dropdown-toggle'
|
||||
click '.content.active .js-actions .dropdown-menu [data-type="ticket-history"]'
|
||||
|
||||
modal = find('.content.active .modal')
|
||||
expect(modal).to have_content "This ticket was merged into ticket ##{target_ticket.number}"
|
||||
expect(modal).to have_link "##{target_ticket.number}", href: "#ticket/zoom/#{target_ticket.id}"
|
||||
|
||||
visit "#ticket/zoom/#{target_ticket.id}"
|
||||
click '.content.active .js-actions .dropdown-toggle'
|
||||
click '.content.active .js-actions .dropdown-menu [data-type="ticket-history"]'
|
||||
|
||||
modal = find('.content.active .modal')
|
||||
expect(modal).to have_content("Ticket ##{origin_ticket.number} was merged into this ticket")
|
||||
expect(modal).to have_link "##{origin_ticket.number}", href: "#ticket/zoom/#{origin_ticket.id}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue