Merge branch 'private-bugfix-1216-rs-develop' into develop
This commit is contained in:
commit
ab63ef2e0d
2 changed files with 24 additions and 1 deletions
|
@ -244,6 +244,11 @@ returns
|
||||||
|
|
||||||
def merge_to(data)
|
def merge_to(data)
|
||||||
|
|
||||||
|
# prevent cross merging tickets
|
||||||
|
target_ticket = Ticket.find(data[:ticket_id])
|
||||||
|
raise 'no target ticket given' if !target_ticket
|
||||||
|
raise 'invalid state for target ticket' if target_ticket.state.name == 'merged'
|
||||||
|
|
||||||
# update articles
|
# update articles
|
||||||
Transaction.execute do
|
Transaction.execute do
|
||||||
|
|
||||||
|
@ -296,7 +301,7 @@ returns
|
||||||
save!
|
save!
|
||||||
|
|
||||||
# touch new ticket (to broadcast change)
|
# touch new ticket (to broadcast change)
|
||||||
Ticket.find(data[:ticket_id]).touch
|
target_ticket.touch
|
||||||
end
|
end
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
|
@ -32,6 +32,24 @@ RSpec.describe Ticket do
|
||||||
expect(check_ticket_ids).to match_array(expected_ticket_ids)
|
expect(check_ticket_ids).to match_array(expected_ticket_ids)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
describe '.destroy' do
|
describe '.destroy' do
|
||||||
|
|
Loading…
Reference in a new issue