trabajo-afectivo/spec/models/ticket_spec.rb

36 lines
1.2 KiB
Ruby
Raw Normal View History

require 'rails_helper'
RSpec.describe Ticket do
describe '.merge_to' do
it 'reassigns all links to the target ticket after merge' do
source_ticket = create(:ticket)
target_ticket = create(:ticket)
important_ticket1 = create(:ticket)
important_ticket2 = create(:ticket)
important_ticket3 = create(:ticket)
create(:link, link_object_source_value: source_ticket.id, link_object_target_value: important_ticket1.id)
create(:link, link_object_source_value: source_ticket.id, link_object_target_value: important_ticket2.id)
create(:link, link_object_source_value: source_ticket.id, link_object_target_value: important_ticket3.id)
source_ticket.merge_to(
ticket_id: target_ticket.id,
user_id: 1,
)
links = Link.list(
link_object: 'Ticket',
link_object_value: target_ticket.id,
)
expected_ticket_ids = [source_ticket.id, important_ticket1.id, important_ticket2.id, important_ticket3.id ]
check_ticket_ids = links.collect { |link| link['link_object_value'] }
expect(check_ticket_ids).to match_array(expected_ticket_ids)
end
end
end