mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-19 13:54:25 +01:00
Merge remote-tracking branch 'origin/fix-time-now' into dev
This commit is contained in:
commit
60755a2c2a
@ -16,6 +16,7 @@
|
||||
- Added freeCAD files as default allowed extensions
|
||||
- Fix a bug: unable to remove the picture from a training
|
||||
- Fix a bug: no alerts on errors during admin creation
|
||||
- Fix a bug: replaces all Time.now by DateTime.current to prevent time zones issues [Taiga#134]
|
||||
- Fix a security issue: updated loofah to fix [CVE-2019-15587](https://github.com/advisories/GHSA-c3gv-9cxf-6f57)
|
||||
- Fix a security issue: updated angular to 1.7.9 to fix [CVE-2019-10768](https://github.com/advisories/GHSA-89mq-4x47-5v83)
|
||||
- [TODO DEPLOY] add the `SLOT_DURATION` environment variable (see [doc/environment.md](doc/environment.md#SLOT_DURATION) for configuration details)
|
||||
|
@ -14,7 +14,7 @@ class API::AccountingPeriodsController < API::ApiController
|
||||
|
||||
def create
|
||||
authorize AccountingPeriod
|
||||
@accounting_period = AccountingPeriod.new(period_params.merge(closed_at: DateTime.now, closed_by: current_user.id))
|
||||
@accounting_period = AccountingPeriod.new(period_params.merge(closed_at: DateTime.current, closed_by: current_user.id))
|
||||
if @accounting_period.save
|
||||
render :show, status: :created, location: @accounting_period
|
||||
else
|
||||
|
@ -17,11 +17,11 @@ class API::EventsController < API::ApiController
|
||||
if current_user&.admin?
|
||||
@events = case params[:scope]
|
||||
when 'future'
|
||||
@events.where('availabilities.start_at >= ?', Time.now).order('availabilities.start_at DESC')
|
||||
@events.where('availabilities.start_at >= ?', DateTime.current).order('availabilities.start_at DESC')
|
||||
when 'future_asc'
|
||||
@events.where('availabilities.start_at >= ?', Time.now).order('availabilities.start_at ASC')
|
||||
@events.where('availabilities.start_at >= ?', DateTime.current).order('availabilities.start_at ASC')
|
||||
when 'passed'
|
||||
@events.where('availabilities.start_at < ?', Time.now).order('availabilities.start_at DESC')
|
||||
@events.where('availabilities.start_at < ?', DateTime.current).order('availabilities.start_at DESC')
|
||||
else
|
||||
@events.order('availabilities.start_at DESC')
|
||||
end
|
||||
@ -36,7 +36,7 @@ class API::EventsController < API::ApiController
|
||||
limit = params[:limit]
|
||||
@events = Event.includes(:event_image, :event_files, :availability, :category)
|
||||
.where('events.nb_total_places != -1 OR events.nb_total_places IS NULL')
|
||||
.where('availabilities.start_at >= ?', Time.now)
|
||||
.where('availabilities.start_at >= ?', DateTime.current)
|
||||
.order('availabilities.start_at ASC').references(:availabilities)
|
||||
.limit(limit)
|
||||
end
|
||||
|
@ -6,7 +6,7 @@ class OpenAPI::V1::EventsController < OpenAPI::V1::BaseController
|
||||
|
||||
if upcoming
|
||||
@events = Event.includes(:event_image, :event_files, :availability, :category)
|
||||
.where('availabilities.end_at >= ?', Time.now)
|
||||
.where('availabilities.end_at >= ?', DateTime.current)
|
||||
.order('availabilities.start_at ASC').references(:availabilities)
|
||||
else
|
||||
@events = Event.includes(:event_image, :event_files, :availability, :category).order(created_at: :desc)
|
||||
|
@ -5,7 +5,7 @@ class Rss::EventsController < Rss::RssController
|
||||
|
||||
def index
|
||||
@events = Event.includes(:event_image, :event_files, :availability, :category)
|
||||
.where('availabilities.start_at >= ?', Time.now)
|
||||
.where('availabilities.start_at >= ?', DateTime.current)
|
||||
.order('availabilities.start_at ASC').references(:availabilities).limit(10)
|
||||
@fab_name = Setting.find_by(name: 'fablab_name').value
|
||||
end
|
||||
|
@ -14,6 +14,6 @@ class Avoir < Invoice
|
||||
end
|
||||
|
||||
def expire_subscription
|
||||
user.subscription.expire(Time.now)
|
||||
user.subscription.expire(DateTime.current)
|
||||
end
|
||||
end
|
||||
|
@ -17,7 +17,7 @@ class Coupon < ActiveRecord::Base
|
||||
validates_with CouponExpirationValidator
|
||||
|
||||
scope :disabled, -> { where(active: false) }
|
||||
scope :expired, -> { where('valid_until IS NOT NULL AND valid_until < ?', DateTime.now) }
|
||||
scope :expired, -> { where('valid_until IS NOT NULL AND valid_until < ?', DateTime.current) }
|
||||
scope :sold_out, lambda {
|
||||
joins(:invoices).select('coupons.*, COUNT(invoices.id) as invoices_count').group('coupons.id')
|
||||
.where.not(max_usages: nil).having('COUNT(invoices.id) >= coupons.max_usages')
|
||||
@ -26,7 +26,7 @@ class Coupon < ActiveRecord::Base
|
||||
joins('LEFT OUTER JOIN invoices ON invoices.coupon_id = coupons.id')
|
||||
.select('coupons.*, COUNT(invoices.id) as invoices_count')
|
||||
.group('coupons.id')
|
||||
.where('active = true AND (valid_until IS NULL OR valid_until >= ?)', DateTime.now)
|
||||
.where('active = true AND (valid_until IS NULL OR valid_until >= ?)', DateTime.current)
|
||||
.having('COUNT(invoices.id) < coupons.max_usages OR coupons.max_usages IS NULL')
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ class Coupon < ActiveRecord::Base
|
||||
def status(user_id = nil, amount = nil)
|
||||
if !active?
|
||||
'disabled'
|
||||
elsif !valid_until.nil? && valid_until.at_end_of_day < DateTime.now
|
||||
elsif !valid_until.nil? && valid_until.at_end_of_day < DateTime.current
|
||||
'expired'
|
||||
elsif !max_usages.nil? && invoices.count >= max_usages
|
||||
'sold_out'
|
||||
|
@ -37,7 +37,7 @@ class Event < ActiveRecord::Base
|
||||
|
||||
def recurrence_events
|
||||
Event.includes(:availability)
|
||||
.where('events.recurrence_id = ? AND events.id != ? AND availabilities.start_at >= ?', recurrence_id, id, Time.now)
|
||||
.where('events.recurrence_id = ? AND events.id != ? AND availabilities.start_at >= ?', recurrence_id, id, DateTime.current)
|
||||
.references(:availabilities)
|
||||
end
|
||||
|
||||
|
@ -151,7 +151,7 @@ class Project < ActiveRecord::Base
|
||||
def after_save_and_publish
|
||||
return unless state_changed? && published?
|
||||
|
||||
update_columns(published_at: Time.now)
|
||||
update_columns(published_at: DateTime.current)
|
||||
notify_admin_when_project_published
|
||||
end
|
||||
end
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
# Time range of duration defined by ApplicationHelper::SLOT_DURATION, slicing an Availability.
|
||||
# During a slot a Reservation is possible
|
||||
# Only reserved slots are persisted in DB, others are instanciated on the fly
|
||||
class Slot < ActiveRecord::Base
|
||||
include NotifyWith::NotificationAttachedObject
|
||||
|
||||
|
@ -30,7 +30,7 @@ class StatisticProfile < ActiveRecord::Base
|
||||
|
||||
def age
|
||||
if birthday.present?
|
||||
now = Time.now.utc.to_date
|
||||
now = DateTime.current.utc.to_date
|
||||
(now - birthday).to_f / AVG_DAYS_PER_YEAR
|
||||
else
|
||||
''
|
||||
|
@ -81,7 +81,7 @@ class Subscription < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def cancel
|
||||
update_columns(canceled_at: Time.now)
|
||||
update_columns(canceled_at: DateTime.current)
|
||||
end
|
||||
|
||||
def expire(time)
|
||||
@ -96,7 +96,7 @@ class Subscription < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def expired?
|
||||
expired_at <= Time.now
|
||||
expired_at <= DateTime.current
|
||||
end
|
||||
|
||||
def expired_at
|
||||
@ -179,7 +179,7 @@ class Subscription < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def set_expiration_date
|
||||
start_at = Time.now
|
||||
start_at = DateTime.current
|
||||
self.expiration_date = start_at + plan.duration
|
||||
end
|
||||
|
||||
|
@ -108,7 +108,7 @@ class User < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def subscribed_plan
|
||||
return nil if subscription.nil? || subscription.expired_at < Time.now
|
||||
return nil if subscription.nil? || subscription.expired_at < DateTime.current
|
||||
|
||||
subscription.plan
|
||||
end
|
||||
@ -240,7 +240,7 @@ class User < ActiveRecord::Base
|
||||
|
||||
# remove the token
|
||||
self.auth_token = nil
|
||||
self.merged_at = DateTime.now
|
||||
self.merged_at = DateTime.current
|
||||
|
||||
# check that the email duplication was resolved
|
||||
if sso_user.email.end_with? '-duplicate'
|
||||
|
@ -7,7 +7,7 @@ class EventPolicy < ApplicationPolicy
|
||||
def resolve
|
||||
if user.nil? || (user && !user.admin?)
|
||||
scope.includes(:event_image, :event_files, :availability, :category)
|
||||
.where('availabilities.start_at >= ?', Time.now)
|
||||
.where('availabilities.start_at >= ?', DateTime.current)
|
||||
.order('availabilities.start_at ASC')
|
||||
.references(:availabilities)
|
||||
else
|
||||
|
@ -6,7 +6,7 @@ class SlotPolicy < ApplicationPolicy
|
||||
|
||||
# these condition does not apply to admins
|
||||
user.admin? or
|
||||
(record.reservation.user == user and enabled and ((record.start_at - Time.now).to_i / 3600 >= delay))
|
||||
(record.reservation.user == user and enabled and ((record.start_at - DateTime.current).to_i / 3600 >= delay))
|
||||
end
|
||||
|
||||
def cancel?
|
||||
|
@ -18,7 +18,7 @@ class Availabilities::AvailabilitiesService
|
||||
slots = []
|
||||
availabilities.each do |a|
|
||||
((a.end_at - a.start_at) / ApplicationHelper::SLOT_DURATION.minutes).to_i.times do |i|
|
||||
next unless (a.start_at + (i * ApplicationHelper::SLOT_DURATION).minutes) > Time.now
|
||||
next unless (a.start_at + (i * ApplicationHelper::SLOT_DURATION).minutes) > DateTime.current
|
||||
|
||||
slot = Slot.new(
|
||||
start_at: a.start_at + (i * ApplicationHelper::SLOT_DURATION).minutes,
|
||||
@ -44,7 +44,7 @@ class Availabilities::AvailabilitiesService
|
||||
slots = []
|
||||
availabilities.each do |a|
|
||||
((a.end_at - a.start_at) / ApplicationHelper::SLOT_DURATION.minutes).to_i.times do |i|
|
||||
next unless (a.start_at + (i * ApplicationHelper::SLOT_DURATION).minutes) > Time.now
|
||||
next unless (a.start_at + (i * ApplicationHelper::SLOT_DURATION).minutes) > DateTime.current
|
||||
|
||||
slot = Slot.new(
|
||||
start_at: a.start_at + (i * ApplicationHelper::SLOT_DURATION).minutes,
|
||||
@ -69,7 +69,7 @@ class Availabilities::AvailabilitiesService
|
||||
# first, we get the already-made reservations
|
||||
reservations = user.reservations.where("reservable_type = 'Training'")
|
||||
reservations = reservations.where('reservable_id = :id', id: training_id.to_i) if training_id.is_number?
|
||||
reservations = reservations.joins(:slots).where('slots.start_at > ?', Time.now)
|
||||
reservations = reservations.joins(:slots).where('slots.start_at > ?', DateTime.current)
|
||||
|
||||
# visible availabilities depends on multiple parameters
|
||||
availabilities = training_availabilities(training_id, user)
|
||||
@ -83,7 +83,7 @@ class Availabilities::AvailabilitiesService
|
||||
private
|
||||
|
||||
def subscription_year?(user)
|
||||
user.subscription && user.subscription.plan.interval == 'year' && user.subscription.expired_at >= Time.now
|
||||
user.subscription && user.subscription.plan.interval == 'year' && user.subscription.expired_at >= DateTime.current
|
||||
end
|
||||
|
||||
# member must have validated at least 1 training and must have a valid yearly subscription.
|
||||
@ -95,21 +95,21 @@ class Availabilities::AvailabilitiesService
|
||||
Reservation.where('reservable_type = ? and reservable_id = ?', reservable.class.name, reservable.id)
|
||||
.includes(:slots, statistic_profile: [user: [:profile]])
|
||||
.references(:slots, :user)
|
||||
.where('slots.start_at > ?', Time.now)
|
||||
.where('slots.start_at > ?', DateTime.current)
|
||||
end
|
||||
|
||||
def availabilities(reservable, type, user)
|
||||
if user.admin?
|
||||
reservable.availabilities
|
||||
.includes(:tags)
|
||||
.where('end_at > ? AND available_type = ?', Time.now, type)
|
||||
.where('end_at > ? AND available_type = ?', DateTime.current, type)
|
||||
.where(lock: false)
|
||||
else
|
||||
end_at = @maximum_visibility[:other]
|
||||
end_at = @maximum_visibility[:year] if subscription_year?(user)
|
||||
reservable.availabilities
|
||||
.includes(:tags)
|
||||
.where('end_at > ? AND end_at < ? AND available_type = ?', Time.now, end_at, type)
|
||||
.where('end_at > ? AND end_at < ? AND available_type = ?', DateTime.current, end_at, type)
|
||||
.where('availability_tags.tag_id' => user.tag_ids.concat([nil]))
|
||||
.where(lock: false)
|
||||
end
|
||||
@ -126,14 +126,14 @@ class Availabilities::AvailabilitiesService
|
||||
# 1) an admin (he can see all future availabilities)
|
||||
if @current_user.admin?
|
||||
availabilities.includes(:tags, :slots, trainings: [:machines])
|
||||
.where('availabilities.start_at > ?', Time.now)
|
||||
.where('availabilities.start_at > ?', DateTime.current)
|
||||
.where(lock: false)
|
||||
# 2) an user (he cannot see availabilities further than 1 (or 3) months)
|
||||
else
|
||||
end_at = @maximum_visibility[:other]
|
||||
end_at = @maximum_visibility[:year] if show_extended_slots?(user)
|
||||
availabilities.includes(:tags, :slots, :availability_tags, trainings: [:machines])
|
||||
.where('availabilities.start_at > ? AND availabilities.start_at < ?', Time.now, end_at)
|
||||
.where('availabilities.start_at > ? AND availabilities.start_at < ?', DateTime.current, end_at)
|
||||
.where('availability_tags.tag_id' => user.tag_ids.concat([nil]))
|
||||
.where(lock: false)
|
||||
end
|
||||
|
@ -47,7 +47,7 @@ class Availabilities::PublicAvailabilitiesService
|
||||
availabilities.each do |a|
|
||||
space = a.spaces.first
|
||||
((a.end_at - a.start_at) / ApplicationHelper::SLOT_DURATION.minutes).to_i.times do |i|
|
||||
next unless (a.start_at + (i * ApplicationHelper::SLOT_DURATION).minutes) > Time.now
|
||||
next unless (a.start_at + (i * ApplicationHelper::SLOT_DURATION).minutes) > DateTime.current
|
||||
|
||||
slot = Slot.new(
|
||||
start_at: a.start_at + (i * ApplicationHelper::SLOT_DURATION).minutes,
|
||||
|
@ -3,7 +3,7 @@
|
||||
# Provides methods to generate invoice references
|
||||
class InvoiceReferenceService
|
||||
class << self
|
||||
def generate_reference(invoice, date: Time.now, avoir: false)
|
||||
def generate_reference(invoice, date: DateTime.current, avoir: false)
|
||||
pattern = Setting.find_by(name: 'invoice_reference').value
|
||||
|
||||
reference = replace_invoice_number_pattern(pattern, invoice)
|
||||
|
@ -4,7 +4,7 @@
|
||||
class SlotService
|
||||
def cancel(slot)
|
||||
# first we mark ths slot as cancelled in DB, to free a ticket
|
||||
slot.update_attributes(canceled_at: DateTime.now)
|
||||
slot.update_attributes(canceled_at: DateTime.current)
|
||||
|
||||
# then we try to remove this reservation from ElasticSearch, to keep the statistics up-to-date
|
||||
model_name = slot.reservation.reservable.class.name
|
||||
|
@ -19,7 +19,7 @@ class UserService
|
||||
)
|
||||
user.build_statistic_profile(
|
||||
gender: true,
|
||||
birthday: Time.now
|
||||
birthday: DateTime.current
|
||||
)
|
||||
|
||||
saved = user.save
|
||||
|
@ -27,7 +27,7 @@ class VatHistoryService
|
||||
|
||||
def vat_history
|
||||
chronology = []
|
||||
end_date = DateTime.now
|
||||
end_date = DateTime.current
|
||||
Setting.find_by(name: 'invoice_VAT-active').history_values.order(created_at: 'DESC').each do |v|
|
||||
chronology.push(start: v.created_at, end: end_date, enabled: v.value == 'true')
|
||||
end_date = v.created_at
|
||||
|
@ -6,7 +6,7 @@ class ClosedPeriodValidator < ActiveModel::Validator
|
||||
date = if record.is_a?(Avoir)
|
||||
record.avoir_date
|
||||
else
|
||||
DateTime.now
|
||||
DateTime.current
|
||||
end
|
||||
|
||||
|
||||
|
@ -7,7 +7,7 @@ class CouponExpirationValidator < ActiveModel::Validator
|
||||
current = record.valid_until
|
||||
|
||||
unless current.blank?
|
||||
if current.end_of_day < Time.now
|
||||
if current.end_of_day < DateTime.current
|
||||
record.errors[:valid_until] << I18n.t('errors.messages.cannot_be_in_the_past')
|
||||
end
|
||||
|
||||
|
@ -56,8 +56,8 @@ wb.add_worksheet(name: t('export_members.members')) do |sheet|
|
||||
member.profile.interest,
|
||||
member.profile.software_mastered,
|
||||
member.group&.name,
|
||||
expiration && Time.now < expiration ? member.subscription.plan.name : t('export_members.without_subscriptions'),
|
||||
expiration && Time.now < expiration ? member.subscription.expired_at.to_date : nil,
|
||||
expiration && DateTime.current < expiration ? member.subscription.plan.name : t('export_members.without_subscriptions'),
|
||||
expiration && DateTime.current < expiration ? member.subscription.expired_at.to_date : nil,
|
||||
member.trainings.map(&:name).join("\n"),
|
||||
member.tags.map(&:name).join("\n"),
|
||||
member.invoices.size,
|
||||
|
@ -45,7 +45,7 @@ class ArchiveWorker
|
||||
last_archive_checksum: last_checksum,
|
||||
previous_file: previous_file,
|
||||
software_version: Version.current,
|
||||
date: Time.now.iso8601
|
||||
date: DateTime.current.iso8601
|
||||
},
|
||||
formats: [:json],
|
||||
handlers: [:jbuilder]
|
||||
|
@ -4,7 +4,7 @@ class OpenAPITraceCallsCountWorker < Sidekiq::Workers
|
||||
|
||||
def perform
|
||||
OpenAPI::Client.find_each do |client|
|
||||
OpenAPI::CallsCountTracing.create!(client: client, calls_count: client.calls_count, at: DateTime.now)
|
||||
OpenAPI::CallsCountTracing.create!(client: client, calls_count: client.calls_count, at: DateTime.current)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -9,7 +9,7 @@ class ReservationReminderWorker
|
||||
if enabled == 'true'
|
||||
delay = Setting.find_by(name: 'reminder_delay').try(:value).try(:to_i).try(:hours) || DEFAULT_REMINDER_DELAY
|
||||
|
||||
starting = Time.now.beginning_of_hour + delay
|
||||
starting = DateTime.current.beginning_of_hour + delay
|
||||
ending = starting + 1.hour
|
||||
|
||||
Reservation.joins(:slots).where('slots.start_at >= ? AND slots.start_at <= ? AND slots.canceled_at IS NULL', starting, ending).each do |r|
|
||||
|
@ -2,8 +2,8 @@ class SubscriptionExpireWorker
|
||||
include Sidekiq::Worker
|
||||
|
||||
def perform(expire_in)
|
||||
Subscription.where('expiration_date >= ?', Time.now.at_beginning_of_day).each do |s|
|
||||
if (s.expired_at - expire_in.days).to_date == Time.now.to_date
|
||||
Subscription.where('expiration_date >= ?', DateTime.current.at_beginning_of_day).each do |s|
|
||||
if (s.expired_at - expire_in.days).to_date == DateTime.current.to_date
|
||||
if expire_in != 0
|
||||
NotificationCenter.call type: 'notify_member_subscription_will_expire_in_7_days',
|
||||
receiver: s.user,
|
||||
|
@ -15,8 +15,8 @@ ActiveRecord::Schema.define(version: 20191202135507) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
enable_extension "pg_trgm"
|
||||
enable_extension "unaccent"
|
||||
enable_extension "pg_trgm"
|
||||
|
||||
create_table "abuses", force: :cascade do |t|
|
||||
t.integer "signaled_id"
|
||||
|
@ -90,7 +90,7 @@ if Role.where(name: 'admin').joins(:users).count.zero?
|
||||
admin = User.new(username: 'admin', email: ENV['ADMIN_EMAIL'], password: ENV['ADMIN_PASSWORD'],
|
||||
password_confirmation: Rails.application.secrets.admin_password, group_id: Group.find_by(slug: 'admins').id,
|
||||
profile_attributes: { first_name: 'admin', last_name: 'admin', phone: '0123456789' },
|
||||
statistic_profile_attributes: { gender: true, birthday: Time.now })
|
||||
statistic_profile_attributes: { gender: true, birthday: DateTime.current })
|
||||
admin.add_role 'admin'
|
||||
admin.save!
|
||||
end
|
||||
|
@ -170,7 +170,7 @@ namespace :fablab do
|
||||
|
||||
days = args.period.to_i
|
||||
if days.zero?
|
||||
StatisticService.new.generate_statistic(start_date: DateTime.now.beginning_of_day, end_date: DateTime.now.end_of_day)
|
||||
StatisticService.new.generate_statistic(start_date: DateTime.current.beginning_of_day, end_date: DateTime.current.end_of_day)
|
||||
else
|
||||
days.times.each do |i|
|
||||
StatisticService.new.generate_statistic(start_date: i.day.ago.beginning_of_day, end_date: i.day.ago.end_of_day)
|
||||
|
@ -129,7 +129,7 @@ namespace :fablab do
|
||||
desc '[release 3.1.2] fix users with invalid group_id'
|
||||
task users_group_ids: :environment do
|
||||
User.where.not(group_id: Group.all.map(&:id)).each do |u|
|
||||
u.update_columns(group_id: Group.first.id, updated_at: DateTime.now)
|
||||
u.update_columns(group_id: Group.first.id, updated_at: DateTime.current)
|
||||
|
||||
meta_data = { ex_group_name: 'invalid group' }
|
||||
|
||||
|
@ -6,7 +6,7 @@ namespace :fablab do
|
||||
|
||||
desc 'Cancel stripe subscriptions'
|
||||
task cancel_subscriptions: :environment do
|
||||
Subscription.where('expiration_date >= ?', Time.now.at_beginning_of_day).each do |s|
|
||||
Subscription.where('expiration_date >= ?', DateTime.current.at_beginning_of_day).each do |s|
|
||||
puts "-> Start cancel subscription of #{s.user.email}"
|
||||
s.cancel
|
||||
puts '-> Done'
|
||||
|
32
test/fixtures/availabilities.yml
vendored
32
test/fixtures/availabilities.yml
vendored
@ -1,8 +1,8 @@
|
||||
|
||||
availability_1:
|
||||
id: 1
|
||||
start_at: <%= DateTime.now.utc.change({hour: 6}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
|
||||
end_at: <%= DateTime.now.utc.change({hour: 10}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
|
||||
start_at: <%= DateTime.current.utc.change({hour: 6}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
|
||||
end_at: <%= DateTime.current.utc.change({hour: 10}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
|
||||
available_type: training
|
||||
created_at: 2016-04-04 15:24:01.517486000 Z
|
||||
updated_at: 2016-04-04 15:24:01.517486000 Z
|
||||
@ -11,8 +11,8 @@ availability_1:
|
||||
|
||||
availability_2:
|
||||
id: 2
|
||||
start_at: <%= (DateTime.now + 1.day).utc.change({hour: 6}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
|
||||
end_at: <%= (DateTime.now + 1.day).utc.change({hour: 10}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
|
||||
start_at: <%= (DateTime.current + 1.day).utc.change({hour: 6}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
|
||||
end_at: <%= (DateTime.current + 1.day).utc.change({hour: 10}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
|
||||
available_type: training
|
||||
created_at: 2016-04-04 15:24:09.169364000 Z
|
||||
updated_at: 2016-04-04 15:24:09.169364000 Z
|
||||
@ -21,8 +21,8 @@ availability_2:
|
||||
|
||||
availability_3:
|
||||
id: 3
|
||||
start_at: <%= DateTime.now.utc.change({hour: 12}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
|
||||
end_at: <%= DateTime.now.utc.change({hour: 18}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
|
||||
start_at: <%= DateTime.current.utc.change({hour: 12}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
|
||||
end_at: <%= DateTime.current.utc.change({hour: 18}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
|
||||
available_type: machines
|
||||
created_at: 2016-04-04 15:24:27.587583000 Z
|
||||
updated_at: 2016-04-04 15:24:27.587583000 Z
|
||||
@ -31,8 +31,8 @@ availability_3:
|
||||
|
||||
availability_4:
|
||||
id: 4
|
||||
start_at: <%= (DateTime.now + 1.day).utc.change({hour: 12}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
|
||||
end_at: <%= (DateTime.now + 1.day).utc.change({hour: 18}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
|
||||
start_at: <%= (DateTime.current + 1.day).utc.change({hour: 12}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
|
||||
end_at: <%= (DateTime.current + 1.day).utc.change({hour: 18}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
|
||||
available_type: machines
|
||||
created_at: 2016-04-04 15:24:44.044908000 Z
|
||||
updated_at: 2016-04-04 15:24:44.044908000 Z
|
||||
@ -41,8 +41,8 @@ availability_4:
|
||||
|
||||
availability_5:
|
||||
id: 5
|
||||
start_at: <%= (DateTime.now + 2.day).utc.change({hour: 12}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
|
||||
end_at: <%= (DateTime.now + 2.day).utc.change({hour: 18}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
|
||||
start_at: <%= (DateTime.current + 2.day).utc.change({hour: 12}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
|
||||
end_at: <%= (DateTime.current + 2.day).utc.change({hour: 18}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
|
||||
available_type: machines
|
||||
created_at: 2016-04-04 15:25:48.584444000 Z
|
||||
updated_at: 2016-04-04 15:25:48.584444000 Z
|
||||
@ -51,8 +51,8 @@ availability_5:
|
||||
|
||||
availability_6:
|
||||
id: 6
|
||||
start_at: <%= (DateTime.now + 3.day).utc.change({hour: 12}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
|
||||
end_at: <%= (DateTime.now + 3.day).utc.change({hour: 18}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
|
||||
start_at: <%= (DateTime.current + 3.day).utc.change({hour: 12}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
|
||||
end_at: <%= (DateTime.current + 3.day).utc.change({hour: 18}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
|
||||
available_type: machines
|
||||
created_at: 2016-04-04 15:26:17.953216000 Z
|
||||
updated_at: 2016-04-04 15:26:17.953216000 Z
|
||||
@ -61,8 +61,8 @@ availability_6:
|
||||
|
||||
availability_7:
|
||||
id: 7
|
||||
start_at: <%= (DateTime.now + 3.day).utc.change({hour: 12}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
|
||||
end_at: <%= (DateTime.now + 3.day).utc.change({hour: 18}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
|
||||
start_at: <%= (DateTime.current + 3.day).utc.change({hour: 12}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
|
||||
end_at: <%= (DateTime.current + 3.day).utc.change({hour: 18}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
|
||||
available_type: machines
|
||||
created_at: 2016-04-04 15:26:39.278627000 Z
|
||||
updated_at: 2016-04-04 15:26:39.278627000 Z
|
||||
@ -71,8 +71,8 @@ availability_7:
|
||||
|
||||
availability_8:
|
||||
id: 8
|
||||
start_at: <%= (DateTime.now + 2.day).utc.change({hour: 6}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
|
||||
end_at: <%= (DateTime.now + 2.day).utc.change({hour: 10}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
|
||||
start_at: <%= (DateTime.current + 2.day).utc.change({hour: 6}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
|
||||
end_at: <%= (DateTime.current + 2.day).utc.change({hour: 10}).strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
|
||||
available_type: training
|
||||
created_at: 2016-04-04 15:26:49.572724000 Z
|
||||
updated_at: 2016-04-04 15:26:49.572724000 Z
|
||||
|
@ -37,7 +37,7 @@ module Availabilities
|
||||
|
||||
# Check that we din't get availabilities from the past
|
||||
availabilities.each do |a|
|
||||
assert_not a[:start] < DateTime.now, 'retrieved a slot in the past'
|
||||
assert_not a[:start] < DateTime.current, 'retrieved a slot in the past'
|
||||
end
|
||||
end
|
||||
|
||||
@ -46,7 +46,7 @@ module Availabilities
|
||||
Rails.application.secrets.fablab_without_spaces = true
|
||||
|
||||
# this simulates a fullCalendar (v2) call
|
||||
start_date = DateTime.now.utc.strftime('%Y-%m-%d')
|
||||
start_date = DateTime.current.utc.strftime('%Y-%m-%d')
|
||||
end_date = 7.days.from_now.utc.strftime('%Y-%m-%d')
|
||||
tz = Time.zone.tzinfo.name
|
||||
get "/api/availabilities?start=#{start_date}&end=#{end_date}&timezone=#{tz}&_=1487169767960"
|
||||
@ -68,7 +68,7 @@ module Availabilities
|
||||
|
||||
test 'get calendar availabilities with spaces' do
|
||||
# this simulates a fullCalendar (v2) call
|
||||
start_date = DateTime.now.utc.strftime('%Y-%m-%d')
|
||||
start_date = DateTime.current.utc.strftime('%Y-%m-%d')
|
||||
end_date = 7.days.from_now.utc.strftime('%Y-%m-%d')
|
||||
tz = Time.zone.tzinfo.name
|
||||
get "/api/availabilities?start=#{start_date}&end=#{end_date}&timezone=#{tz}&_=1487169767960"
|
||||
|
@ -22,7 +22,7 @@ class Availabilities::AsUserTest < ActionDispatch::IntegrationTest
|
||||
|
||||
# Check that we din't get availabilities from the past
|
||||
availabilities.each do |a|
|
||||
assert_not a[:start] < DateTime.now, 'retrieved a slot in the past'
|
||||
assert_not a[:start] < DateTime.current, 'retrieved a slot in the past'
|
||||
end
|
||||
|
||||
# Check that we don't get availabilities in more than a month
|
||||
|
@ -57,7 +57,7 @@ module Credits
|
||||
credit = json_response(response.body)
|
||||
assert_equal 13, credit[:id]
|
||||
c = Credit.find(credit[:id])
|
||||
assert Time.now - c.updated_at < 1.minute
|
||||
assert c.updated_at > 1.minute.ago
|
||||
|
||||
assert_equal 5, c.hours
|
||||
end
|
||||
|
@ -19,7 +19,7 @@ class Exports::AccountingExportTest < ActionDispatch::IntegrationTest
|
||||
encoding: 'ISO-8859-1',
|
||||
date_format: '%d/%m/%Y',
|
||||
start_date: '2012-03-12T00:00:00.000Z',
|
||||
end_date: DateTime.now.utc.iso8601,
|
||||
end_date: DateTime.current.utc.iso8601,
|
||||
label_max_length: 50,
|
||||
decimal_separator: ',',
|
||||
export_invoices_at_zero: false
|
||||
|
@ -33,7 +33,7 @@ class InvoicesTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
|
||||
test 'admin generates a refund' do
|
||||
date = DateTime.now.iso8601
|
||||
date = DateTime.current.iso8601
|
||||
|
||||
post '/api/invoices', { avoir: {
|
||||
avoir_date: date,
|
||||
|
@ -37,14 +37,14 @@ class Subscriptions::RenewAsUserTest < ActionDispatch::IntegrationTest
|
||||
assert_not_nil @user.subscription, "user's subscription was not found"
|
||||
|
||||
# Check the expiration date
|
||||
assert @user.subscription.expired_at > DateTime.now,
|
||||
assert @user.subscription.expired_at > DateTime.current,
|
||||
"user's subscription expiration was not updated ... VCR cassettes may be outdated, please check the gitlab wiki"
|
||||
assert_equal @user.subscription.expired_at.iso8601,
|
||||
(@user.subscription.created_at + plan.duration).iso8601,
|
||||
'subscription expiration date does not match'
|
||||
|
||||
assert_in_delta 5,
|
||||
(DateTime.now.to_i - @user.subscription.updated_at.to_i),
|
||||
(DateTime.current.to_i - @user.subscription.updated_at.to_i),
|
||||
10,
|
||||
"user's subscription was not updated recently"
|
||||
|
||||
|
@ -83,7 +83,7 @@ class WalletsTest < ActionDispatch::IntegrationTest
|
||||
login_as(admin, scope: :user)
|
||||
w = @vlonchamp.wallet
|
||||
amount = 10
|
||||
avoir_date = Time.now.end_of_day
|
||||
avoir_date = DateTime.current.end_of_day
|
||||
expected_amount = w.amount + amount
|
||||
put "/api/wallet/#{w.id}/credit",
|
||||
amount: amount,
|
||||
|
@ -3,7 +3,7 @@ require 'test_helper'
|
||||
class CouponTest < ActiveSupport::TestCase
|
||||
|
||||
test 'valid coupon with percentage' do
|
||||
c = Coupon.new({name: 'Hot deals', code: 'HOT15', percent_off: 15, validity_per_user: 'once', valid_until: (Time.now + 2.weeks), max_usages: 100, active: true})
|
||||
c = Coupon.new({name: 'Hot deals', code: 'HOT15', percent_off: 15, validity_per_user: 'once', valid_until: (DateTime.current + 2.weeks), max_usages: 100, active: true})
|
||||
assert c.valid?
|
||||
assert_equal 'active', c.status, 'Invalid coupon status'
|
||||
assert_equal 'percent_off', c.type, 'Invalid coupon type'
|
||||
|
@ -39,7 +39,7 @@ class ActiveSupport::TestCase
|
||||
def stripe_payment_method(error: nil)
|
||||
number = '4242424242424242'
|
||||
exp_month = 4
|
||||
exp_year = DateTime.now.next_year.year
|
||||
exp_year = DateTime.current.next_year.year
|
||||
cvc = '314'
|
||||
|
||||
case error
|
||||
|
Loading…
x
Reference in New Issue
Block a user