Fixes #3841 - Zammad returns stack error when one tries to remove groups via API.
This commit is contained in:
parent
8f5a74a560
commit
59ecff9274
2 changed files with 21 additions and 0 deletions
|
@ -149,6 +149,7 @@ curl http://localhost/api/v1/groups/{id} -v -u #{login}:#{password} -H "Content-
|
||||||
=end
|
=end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
model_references_check(Group, params)
|
||||||
model_destroy_render(Group, params)
|
model_destroy_render(Group, params)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
20
spec/requests/group_spec.rb
Normal file
20
spec/requests/group_spec.rb
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe 'Group', type: :request, authenticated_as: -> { user } do
|
||||||
|
describe 'Zammad returns stack error when one tries to remove groups via API #3841' do
|
||||||
|
let(:group) { create(:group) }
|
||||||
|
let(:ticket) { create(:ticket, group: group) }
|
||||||
|
let(:user) { create(:admin) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
ticket
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'does return reference error on delete if related objects exist' do
|
||||||
|
delete "/api/v1/groups/#{group.id}", params: {}, as: :json
|
||||||
|
expect(json_response['error']).to eq("Can't delete, object has references.")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue