Improve Error messages
- Improve error messages in event schedules, schedules and program controller. - Two respond_to blocks in the update method of program controller.
This commit is contained in:
parent
c687c1072e
commit
e8261d41bc
4 changed files with 13 additions and 11 deletions
|
|
@ -6,7 +6,7 @@ module Admin
|
||||||
if @event_schedule.save
|
if @event_schedule.save
|
||||||
render json: { 'status' => 'ok', event_schedule_id: @event_schedule.id }
|
render json: { 'status' => 'ok', event_schedule_id: @event_schedule.id }
|
||||||
else
|
else
|
||||||
render json: { 'status' => "The event couldn't be scheduled" }
|
render json: { 'status' => "The event couldn't be scheduled. #{@event_schedule.errors.full_messages.join('. ')}" }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -14,7 +14,7 @@ module Admin
|
||||||
if @event_schedule.update(event_schedule_params)
|
if @event_schedule.update(event_schedule_params)
|
||||||
render json: { 'status' => 'ok', event_schedule_id: @event_schedule.id }
|
render json: { 'status' => 'ok', event_schedule_id: @event_schedule.id }
|
||||||
else
|
else
|
||||||
render json: { 'status' => "The event couldn't be scheduled" }
|
render json: { 'status' => "The event couldn't be scheduled. #{@event_schedule.errors.full_messages.join('. ')}" }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -22,7 +22,7 @@ module Admin
|
||||||
if @event_schedule.destroy
|
if @event_schedule.destroy
|
||||||
render json: { 'status' => 'ok' }
|
render json: { 'status' => 'ok' }
|
||||||
else
|
else
|
||||||
render json: { 'status' => "The event couldn't be unscheduled" }
|
render json: { 'status' => "The event couldn't be unscheduled. #{@event_schedule.errors.full_messages.join('. ')}" }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,20 +13,22 @@ module Admin
|
||||||
@program.assign_attributes(program_params)
|
@program.assign_attributes(program_params)
|
||||||
send_mail_on_schedule_public = @program.notify_on_schedule_public?
|
send_mail_on_schedule_public = @program.notify_on_schedule_public?
|
||||||
|
|
||||||
respond_to do |format|
|
if @program.update_attributes(program_params)
|
||||||
if @program.update_attributes(program_params)
|
ConferenceScheduleUpdateMailJob.perform_later(@conference) if send_mail_on_schedule_public
|
||||||
ConferenceScheduleUpdateMailJob.perform_later(@conference) if send_mail_on_schedule_public
|
respond_to do |format|
|
||||||
format.html do
|
format.html do
|
||||||
redirect_to admin_conference_program_path(@conference.short_title),
|
redirect_to admin_conference_program_path(@conference.short_title),
|
||||||
notice: 'The program was successfully updated.'
|
notice: 'The program was successfully updated.'
|
||||||
end
|
end
|
||||||
format.js { render json: { 'status' => 'ok' } }
|
format.js { render json: { 'status' => 'ok' } }
|
||||||
else
|
end
|
||||||
|
else
|
||||||
|
respond_to do |format|
|
||||||
format.html do
|
format.html do
|
||||||
flash[:error] = "Updating program failed. #{@program.errors.to_a.join('. ')}."
|
flash[:error] = "Updating program failed. #{@program.errors.to_a.join('. ')}."
|
||||||
render :new
|
render :new
|
||||||
end
|
end
|
||||||
format.js { render json: { 'status' => "The selected schedule couldn't been updated" } }
|
format.js { render json: { 'status' => "The selected schedule couldn't been updated #{@program.errors.to_a.join('. ')}" } }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ module Admin
|
||||||
notice: 'Schedule was successfully created.'
|
notice: 'Schedule was successfully created.'
|
||||||
else
|
else
|
||||||
redirect_to admin_conference_schedules_path(conference_id: @conference.short_title),
|
redirect_to admin_conference_schedules_path(conference_id: @conference.short_title),
|
||||||
error: 'Could not create schedule'
|
error: "Could not create schedule. #{@schedule.errors.full_messages.join('. ')}."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ describe Admin::EventSchedulesController do
|
||||||
room_id: nil,
|
room_id: nil,
|
||||||
start_time: nil)
|
start_time: nil)
|
||||||
|
|
||||||
expect(JSON.parse(response.body)['status']).to_not eq('ok')
|
expect(JSON.parse(response.body)['status']).to eq("The event couldn't be scheduled. Event can't be blank. Room can't be blank. Start time can't be blank")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -119,7 +119,7 @@ describe Admin::EventSchedulesController do
|
||||||
room_id: nil,
|
room_id: nil,
|
||||||
start_time: nil)
|
start_time: nil)
|
||||||
|
|
||||||
expect(JSON.parse(response.body)['status']).to_not eq('ok')
|
expect(JSON.parse(response.body)['status']).to eq("The event couldn't be scheduled. Event can't be blank. Room can't be blank. Start time can't be blank")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue