2019-11-21 23:22:15 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe RepositoryDateTimeRangeValue, type: :model do
|
2019-12-08 23:53:59 +08:00
|
|
|
let(:date_time_range_value) do
|
|
|
|
create :repository_date_time_range_value, start_time: Time.utc(2000, 10, 10), end_time: Time.utc(2000, 10, 11)
|
2019-11-21 23:22:15 +08:00
|
|
|
end
|
|
|
|
|
2019-12-08 23:53:59 +08:00
|
|
|
describe '.formatted' do
|
|
|
|
it 'prints date format with time' do
|
|
|
|
str = '10/10/2000, 00:00 - 10/11/2000, 00:00'
|
|
|
|
expect(date_time_range_value.formatted).to eq(str)
|
2019-11-21 23:22:15 +08:00
|
|
|
end
|
2019-12-08 23:53:59 +08:00
|
|
|
end
|
2019-11-21 23:22:15 +08:00
|
|
|
|
2019-12-08 23:53:59 +08:00
|
|
|
describe '.data_changed?' do
|
|
|
|
context 'when has different datetime value' do
|
|
|
|
let(:new_values) do
|
|
|
|
{
|
|
|
|
start_time: Time.utc(2000, 10, 10).to_s,
|
|
|
|
end_time: Time.utc(2000, 10, 12).to_s
|
|
|
|
}
|
|
|
|
end
|
2019-11-21 23:22:15 +08:00
|
|
|
|
2019-12-08 23:53:59 +08:00
|
|
|
it do
|
|
|
|
expect(date_time_range_value.data_changed?(new_values)).to be_truthy
|
|
|
|
end
|
2019-11-21 23:22:15 +08:00
|
|
|
end
|
|
|
|
|
2019-12-08 23:53:59 +08:00
|
|
|
context 'when has same datetime value' do
|
|
|
|
let(:new_values) do
|
|
|
|
{
|
|
|
|
start_time: Time.utc(2000, 10, 10).to_s,
|
|
|
|
end_time: Time.utc(2000, 10, 11).to_s
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
it do
|
|
|
|
expect(date_time_range_value.data_changed?(new_values)).to be_falsey
|
|
|
|
end
|
|
|
|
end
|
2019-11-21 23:22:15 +08:00
|
|
|
end
|
|
|
|
end
|