1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-30 19:52:20 +01:00

(bug) unable to update recurring event

This commit is contained in:
Du Peng 2023-03-27 12:44:55 +02:00
parent ae904c000c
commit f04b93baec
3 changed files with 11 additions and 1 deletions

View File

@ -1,5 +1,7 @@
# Changelog Fab-manager
- Fix a bug: unable to update recurring event
## v5.9.1 2023 March 22
- Fix a bug: logical sequence of invoices references has duplicates

View File

@ -120,7 +120,7 @@ class Event::UpdateEventService
def file_attributes(base_event, occurrence, event_params)
ef_attributes = []
event_params['event_files_attributes']&.each do |efa|
event_params['event_files_attributes']&.values&.each do |efa|
if efa['id'].present?
event_file = base_event.event_files.find(efa['id'])
ef = occurrence.event_files.find_by(attachment: event_file.attachment.file.filename)

View File

@ -47,12 +47,16 @@ class Events::RecurrenceUpdateTest < ActionDispatch::IntegrationTest
new_title = 'Skateboard party'
new_descr = 'Come make a skateboard tonight at the Fablab'
new_image = '/files/event/Skateboard.jpg'
new_file = '/files/document.pdf'
put "/api/events/#{event&.id}", params: {
event: {
title: new_title,
event_image_attributes: {
attachment: fixture_file_upload(new_image)
},
event_files_attributes: {
'0' => { attachment: fixture_file_upload(new_file) }
},
description: new_descr,
category_id: 1,
event_theme_ids: [1],
@ -88,6 +92,10 @@ class Events::RecurrenceUpdateTest < ActionDispatch::IntegrationTest
File.join(ActionDispatch::IntegrationTest.fixture_path, new_image),
db_event.event_image.attachment.file.path
)
assert FileUtils.compare_file(
File.join(ActionDispatch::IntegrationTest.fixture_path, new_file),
db_event.event_files[0].attachment.file.path
)
end
# Update again but only the next events