Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed issue #1216 - Race condition if agents merge ticket at same tim…
…e but in different directions.
- Loading branch information
1 parent
2be861e
commit d636996
Showing
4 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FactoryGirl.define do | ||
factory :ticket do | ||
title 'Test Ticket' | ||
group { Group.lookup(name: 'Users') } | ||
customer { FactoryGirl.create(:customer_user) } | ||
state { Ticket::State.lookup(name: 'new') } | ||
priority { Ticket::Priority.lookup(name: '2 normal') } | ||
updated_by_id 1 | ||
created_by_id 1 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe Ticket do | ||
|
||
describe '.merge_to' do | ||
|
||
it 'prevents cross merging tickets' do | ||
source_ticket = create(:ticket) | ||
target_ticket = create(:ticket) | ||
|
||
result = source_ticket.merge_to( | ||
ticket_id: target_ticket.id, | ||
user_id: 1, | ||
) | ||
expect(result).to be(true) | ||
|
||
expect { | ||
result = target_ticket.merge_to( | ||
ticket_id: source_ticket.id, | ||
user_id: 1, | ||
) | ||
}.to raise_error('invalid state for target ticket') | ||
end | ||
|
||
end | ||
|
||
end |