destroy appointmentgroup if no more events
fixes CNVS-36124 Test Plan: - Create some appointments in new scheduler (via modal) - Delete all appointments - Go to the syllabus page - Notice that the event isn't showing there - delete more events from your calenar - notice nothing breaks - watch screen cast for more context Change-Id: Ib992247bf9267889f5a296e36536b23cdc4cc22d Reviewed-on: https://gerrit.instructure.com/110470 Tested-by: Jenkins Reviewed-by: James Williams <jamesw@instructure.com> QA-Review: Deepeeca Soundarrajan <dsoundarrajan@instructure.com> Product-Review: Chris Ward <cward@instructure.com>
This commit is contained in:
parent
2db1239cff
commit
5e2238dd06
|
@ -648,6 +648,9 @@ class CalendarEventsApiController < ApplicationController
|
|||
@event.updating_user = @current_user
|
||||
@event.cancel_reason = params[:cancel_reason]
|
||||
if @event.destroy
|
||||
if @event.appointment_group && @event.appointment_group.appointments.count == 0 && @event.appointment_group.context.root_account.feature_enabled?(:better_scheduler)
|
||||
@event.appointment_group.destroy
|
||||
end
|
||||
render :json => event_json(@event, @current_user, session)
|
||||
else
|
||||
render :json => @event.errors, :status => :bad_request
|
||||
|
|
|
@ -1019,6 +1019,22 @@ describe CalendarEventsApiController, type: :request do
|
|||
expect(event.reload).to be_deleted
|
||||
end
|
||||
|
||||
it 'should delete the appointment group if it has no appointments' do
|
||||
@course.root_account.enable_feature!(:better_scheduler)
|
||||
time = Time.utc(Time.now.year, Time.now.month, Time.now.day, 4, 20)
|
||||
@appointment_group = AppointmentGroup.create!(
|
||||
:title => "appointment group", :participants_per_appointment => 4,
|
||||
:new_appointments => [
|
||||
[time + 3.days, time + 3.days + 1.hour]
|
||||
],
|
||||
:contexts => [@course]
|
||||
)
|
||||
|
||||
api_call(:delete, "/api/v1/calendar_events/#{@appointment_group.appointments.first.id}",
|
||||
{:controller => 'calendar_events_api', :action => 'destroy', :id => @appointment_group.appointments.first.id.to_s, :format => 'json'})
|
||||
expect(@appointment_group.reload).to be_deleted
|
||||
end
|
||||
|
||||
it 'should api translate event descriptions' do
|
||||
should_translate_user_content(@course) do |content|
|
||||
event = @course.calendar_events.create!(:title => 'event', :start_at => '2012-01-08 12:00:00', :description => content)
|
||||
|
|
Loading…
Reference in New Issue