1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-28 09:24:24 +01:00

(bug) unable to create a recurrent event

This commit is contained in:
Sylvain 2023-01-31 11:39:51 +01:00
parent 66311b8761
commit 98d6363525
5 changed files with 51 additions and 4 deletions

View File

@ -1,7 +1,9 @@
# Changelog Fab-manager
- Updated shakapaker to 6.5.5
- Fix a bug: invalid month in shown in date format
- Fix a bug: unable to create a recurrent event
- Fix a bug: invalid month in date format
- Fix a bug: do not show theme and age-range fields in event form if no options were set
- Fix a bug: new setups doesn't log
## v5.6.8 2023 January 26

View File

@ -180,12 +180,12 @@ export const EventForm: React.FC<EventFormProps> = ({ action, event, onError, on
label={t('app.admin.event_form.event_category')}
options={categoriesOptions}
rules={{ required: true }} />
{themesOptions && <FormMultiSelect control={control}
{themesOptions?.length > 0 && <FormMultiSelect control={control}
id="event_theme_ids"
formState={formState}
options={themesOptions}
label={t('app.admin.event_form.event_themes')} />}
{ageRangeOptions && <FormSelect control={control}
{ageRangeOptions?.length > 0 && <FormSelect control={control}
id="age_range_id"
formState={formState}
options={ageRangeOptions}

View File

@ -65,7 +65,7 @@ class Event::CreateEventService
end
def occurrence_advanced_accounting(event)
AdvancedAccounting.new(code: event.advanced_accounting.code, analytical_section: event.advanced_accounting.analytical_section)
AdvancedAccounting.new(code: event.advanced_accounting&.code, analytical_section: event.advanced_accounting&.analytical_section)
end
end
end

BIN
test/fixtures/files/event/Party.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

View File

@ -73,4 +73,49 @@ class Events::RecurrenceTest < ActionDispatch::IntegrationTest
assert(db_events.all? { |event| event.advanced_accounting.code == '706300' })
assert(db_events.all? { |event| event.advanced_accounting.analytical_section == '9A54C' })
end
test 'create a simple recurrent event' do
name = 'Fablab party'
post '/api/events',
params: {
event: {
title: name,
event_image_attributes: {
attachment: fixture_file_upload('/files/event/Party.jpg')
},
description: 'Come party tonight at the fablab...',
start_date: 2.weeks.from_now.utc,
end_date: 2.weeks.from_now.utc,
all_day: false,
start_time: '18:00',
end_time: '23:29',
amount: 20,
category_id: 2,
recurrence: 'month',
recurrence_end_at: 3.months.from_now.utc + 2.weeks
}
},
headers: upload_headers
# Check response format & status
assert_equal 201, response.status, response.body
assert_equal Mime[:json], response.content_type
# Check the events were correctly created
db_events = Event.where(title: name)
assert_equal 4, db_events.count
assert(db_events.all? { |event| !event.event_image.attachment.nil? })
assert(db_events.all? { |event| !event.description.empty? })
assert(db_events.all? { |event| event.availability.start_at.to_date >= 2.weeks.from_now.to_date })
assert(db_events.all? { |event| event.availability.start_at.to_date <= 3.months.from_now.end_of_day.to_date + 2.weeks })
assert(db_events.all? { |event| event.availability.end_at.to_date >= 2.weeks.from_now.to_date })
assert(db_events.all? { |event| event.availability.end_at.to_date <= 3.months.from_now.end_of_day.to_date + 2.weeks })
assert(db_events.none?(&:all_day?))
assert(db_events.all? { |event| event.amount == 2000 })
assert(db_events.all? { |event| event.event_theme_ids.empty? })
assert(db_events.all? { |event| event.category_id == 2 })
assert(db_events.all? { |event| event.age_range_id.nil? })
assert(db_events.all? { |event| event.event_files.count.zero? })
assert(db_events.all? { |event| event.event_price_categories.count.zero? })
end
end