Fixes #3845 - Removing calendars via UI and API does not check for references.

This commit is contained in:
Rolf Schmidt 2021-11-10 14:29:31 +00:00
parent 8053f2fc72
commit 44703499e3
2 changed files with 15 additions and 0 deletions

View file

@ -38,6 +38,7 @@ class CalendarsController < ApplicationController
end end
def destroy def destroy
model_references_check(Calendar, params)
model_destroy_render(Calendar, params) model_destroy_render(Calendar, params)
end end

View file

@ -76,4 +76,18 @@ RSpec.describe 'Calendars', type: :request do
end end
end end
describe 'Removing calendars via UI and API does not check for references #3845', authenticated_as: -> { user } do
let(:calendar) { create(:calendar) }
let(:sla) { create(:sla, calendar: calendar) }
let(:user) { create(:admin) }
before do
sla
end
it 'does return reference error on delete if related objects exist' do
delete "/api/v1/calendars/#{calendar.id}", params: {}, as: :json
expect(json_response['error']).to eq("Can't delete, object has references.")
end
end
end end