Fixes #3845 - Removing calendars via UI and API does not check for references.
This commit is contained in:
parent
92cd364ec2
commit
44422c5357
2 changed files with 15 additions and 0 deletions
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue