2020-05-11 13:52:27 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-04-04 17:42:45 +02:00
|
|
|
require 'test_helper'
|
|
|
|
|
|
|
|
class AvailabilityTest < ActiveSupport::TestCase
|
2020-05-11 13:52:27 +02:00
|
|
|
test 'any duration is allowed' do
|
2016-04-05 12:28:42 +02:00
|
|
|
a = Availability.first
|
|
|
|
a.end_at = a.start_at + 15.minutes
|
2020-05-11 13:52:27 +02:00
|
|
|
assert a.valid?
|
2016-04-04 17:42:45 +02:00
|
|
|
end
|
2016-04-05 10:03:58 +02:00
|
|
|
|
|
|
|
test "if type available_type is 'machines' check that there is minimum 1 association" do
|
2016-04-05 12:28:42 +02:00
|
|
|
a = Availability.where(available_type: 'machines').first
|
|
|
|
a.machines_availabilities.destroy_all
|
2016-04-05 10:03:58 +02:00
|
|
|
assert a.invalid?
|
|
|
|
assert a.errors.key?(:machine_ids)
|
|
|
|
end
|
2016-04-04 17:42:45 +02:00
|
|
|
end
|