mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-17 06:52:27 +01:00
fix tests
This commit is contained in:
parent
8ede604eb7
commit
4b8504f531
@ -89,7 +89,7 @@ class Availability < ApplicationRecord
|
||||
def available_space_places
|
||||
return unless available_type == 'space'
|
||||
|
||||
duration = slot_duration || Setting.get('slot_duration')
|
||||
duration = slot_duration || Setting.get('slot_duration').to_i
|
||||
((end_at - start_at) / duration.minutes).to_i * nb_total_places
|
||||
end
|
||||
|
||||
@ -162,7 +162,7 @@ class Availability < ApplicationRecord
|
||||
def length_must_be_slot_multiple
|
||||
return unless available_type == 'machines' || available_type == 'space'
|
||||
|
||||
duration = slot_duration || Setting.get('slot_duration')
|
||||
duration = slot_duration || Setting.get('slot_duration').to_i
|
||||
return unless end_at < (start_at + duration.minutes)
|
||||
|
||||
errors.add(:end_at, I18n.t('availabilities.length_must_be_slot_multiple', MIN: duration))
|
||||
|
@ -17,7 +17,7 @@ class Availabilities::AvailabilitiesService
|
||||
|
||||
slots = []
|
||||
availabilities.each do |a|
|
||||
slot_duration = a.slot_duration || Setting.get('slot_duration')
|
||||
slot_duration = a.slot_duration || Setting.get('slot_duration').to_i
|
||||
((a.end_at - a.start_at) / slot_duration.minutes).to_i.times do |i|
|
||||
next unless (a.start_at + (i * slot_duration).minutes) > DateTime.current || user.admin?
|
||||
|
||||
@ -44,7 +44,7 @@ class Availabilities::AvailabilitiesService
|
||||
|
||||
slots = []
|
||||
availabilities.each do |a|
|
||||
slot_duration = a.slot_duration || Setting.get('slot_duration')
|
||||
slot_duration = a.slot_duration || Setting.get('slot_duration').to_i
|
||||
((a.end_at - a.start_at) / slot_duration.minutes).to_i.times do |i|
|
||||
next unless (a.start_at + (i * slot_duration).minutes) > DateTime.current || user.admin?
|
||||
|
||||
|
@ -15,7 +15,7 @@ class Availabilities::PublicAvailabilitiesService
|
||||
.where(lock: false)
|
||||
slots = []
|
||||
availabilities.each do |a|
|
||||
slot_duration = a.slot_duration || Setting.get('slot_duration')
|
||||
slot_duration = a.slot_duration || Setting.get('slot_duration').to_i
|
||||
a.machines.each do |machine|
|
||||
next unless machine_ids&.include?(machine.id.to_s)
|
||||
|
||||
@ -46,7 +46,7 @@ class Availabilities::PublicAvailabilitiesService
|
||||
|
||||
slots = []
|
||||
availabilities.each do |a|
|
||||
slot_duration = a.slot_duration || Setting.get('slot_duration')
|
||||
slot_duration = a.slot_duration || Setting.get('slot_duration').to_i
|
||||
space = a.spaces.first
|
||||
((a.end_at - a.start_at) / slot_duration.minutes).to_i.times do |i|
|
||||
next unless (a.start_at + (i * slot_duration).minutes) > DateTime.current
|
||||
|
@ -16,7 +16,7 @@ wb.add_worksheet(name: t('export_availabilities.machines')) do |sheet|
|
||||
|
||||
# data rows
|
||||
@availabilities.where(available_type: 'machines').order(:start_at).each do |a|
|
||||
slot_duration = a.slot_duration || Setting.get('slot_duration')
|
||||
slot_duration = a.slot_duration || Setting.get('slot_duration').to_i
|
||||
a.machines.each do |m|
|
||||
((a.end_at - a.start_at) / slot_duration.minutes).to_i.times do |i|
|
||||
start_at = a.start_at + (i * slot_duration).minutes
|
||||
@ -84,7 +84,7 @@ if Setting.get('spaces_module')
|
||||
|
||||
# data rows
|
||||
@availabilities.where(available_type: 'space').order(:start_at).each do |a|
|
||||
slot_duration = a.slot_duration || Setting.get('slot_duration')
|
||||
slot_duration = a.slot_duration || Setting.get('slot_duration').to_i
|
||||
((a.end_at - a.start_at) / slot_duration.minutes).to_i.times do |i|
|
||||
start_at = a.start_at + (i * slot_duration).minutes
|
||||
end_at = a.start_at + (i * slot_duration).minutes + slot_duration.minutes
|
||||
|
2
test/fixtures/history_values.yml
vendored
2
test/fixtures/history_values.yml
vendored
@ -598,7 +598,7 @@ history_value_62:
|
||||
id: 62
|
||||
setting_id: 62
|
||||
invoicing_profile_id: 1
|
||||
value: 'false'
|
||||
value: 'true'
|
||||
created_at: 2020-06-01 11:12:21.255550000 Z
|
||||
updated_at: 2020-06-01 11:12:21.255550000 Z
|
||||
footprint:
|
||||
|
Loading…
x
Reference in New Issue
Block a user