Merge branch 'private-bugfix-1216-rs-develop' into develop

This commit is contained in:
Martin Edenhofer 2017-07-25 13:21:07 +02:00
commit ab63ef2e0d
2 changed files with 24 additions and 1 deletions

View file

@ -244,6 +244,11 @@ returns
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
Transaction.execute do
@ -296,7 +301,7 @@ returns
save!
# touch new ticket (to broadcast change)
Ticket.find(data[:ticket_id]).touch
target_ticket.touch
end
true
end

View file

@ -32,6 +32,24 @@ RSpec.describe Ticket do
expect(check_ticket_ids).to match_array(expected_ticket_ids)
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
describe '.destroy' do