123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- # encoding: utf-8
- require 'test_helper'
- class CalendarTest < ActiveSupport::TestCase
- test 'default test' do
- Calendar.delete_all
- calendar1 = Calendar.create_or_update(
- name: 'US 1',
- timezone: 'America/Los_Angeles',
- business_hours: {
- mon: { '09:00' => '17:00' },
- tue: { '09:00' => '17:00' },
- wed: { '09:00' => '17:00' },
- thu: { '09:00' => '17:00' },
- fri: { '09:00' => '17:00' }
- },
- default: true,
- ical_url: nil,
- updated_by_id: 1,
- created_by_id: 1,
- )
- sleep 1
- calendar2 = Calendar.create_or_update(
- name: 'US 2',
- timezone: 'America/Los_Angeles',
- business_hours: {
- mon: { '09:00' => '17:00' },
- tue: { '09:00' => '17:00' },
- wed: { '09:00' => '17:00' },
- thu: { '09:00' => '17:00' },
- fri: { '09:00' => '17:00' }
- },
- default: false,
- ical_url: nil,
- updated_by_id: 1,
- created_by_id: 1,
- )
- calendar3 = Calendar.create_or_update(
- name: 'US 3',
- timezone: 'America/Los_Angeles',
- business_hours: {
- mon: { '09:00' => '17:00' },
- tue: { '09:00' => '17:00' },
- wed: { '09:00' => '17:00' },
- thu: { '09:00' => '17:00' },
- fri: { '09:00' => '17:00' }
- },
- default: true,
- ical_url: nil,
- updated_by_id: 1,
- created_by_id: 1,
- )
- calendar1 = Calendar.find_by(name: 'US 1')
- calendar2 = Calendar.find_by(name: 'US 2')
- calendar3 = Calendar.find_by(name: 'US 3')
- assert_equal(false, calendar1.default)
- assert_equal(false, calendar2.default)
- assert_equal(true, calendar3.default)
- calendar2.default = true
- calendar2.save
- calendar1 = Calendar.find_by(name: 'US 1')
- calendar2 = Calendar.find_by(name: 'US 2')
- calendar3 = Calendar.find_by(name: 'US 3')
- assert_equal(false, calendar1.default)
- assert_equal(true, calendar2.default)
- assert_equal(false, calendar3.default)
- calendar2.default = false
- calendar2.save
- calendar1 = Calendar.find_by(name: 'US 1')
- calendar2 = Calendar.find_by(name: 'US 2')
- calendar3 = Calendar.find_by(name: 'US 3')
- assert_equal(true, calendar1.default)
- assert_equal(false, calendar2.default)
- assert_equal(false, calendar3.default)
- calendar1.destroy
- calendar2 = Calendar.find_by(name: 'US 2')
- calendar3 = Calendar.find_by(name: 'US 3')
- assert_equal(true, calendar2.default)
- assert_equal(false, calendar3.default)
- end
- end
|