make report specs local timezone agnostic

This commit is contained in:
Anton Chuchkalov 2015-11-30 17:51:43 +04:00 committed by Anton Chuchkalov
parent 4e6e634e4a
commit 98dcbfb996

View File

@ -4,20 +4,16 @@ RSpec.describe Devops::Model::Report, type: :model do
let(:report) { build(:report) } let(:report) { build(:report) }
describe '#initialize' do describe '#initialize' do
let(:given_moment) { Time.new(2007,11,1,15,25,0, "+01:00") }
it 'converts created_at to localtime' do it 'converts created_at to localtime' do
now = Time.now.utc converted = build(:report, created_at: given_moment).created_at
expect(now.zone).to eq 'UTC' expect(converted).to eq given_moment.localtime
expect(
build(:report, created_at: now).created_at.zone
).not_to eq 'UTC'
end end
it 'converts updated_at to localtime' do it 'converts updated_at to localtime' do
now = Time.now.utc converted = build(:report, updated_at: given_moment).updated_at
expect(now.zone).to eq 'UTC' expect(converted).to eq given_moment.localtime
expect(
build(:report, updated_at: now).updated_at.zone
).not_to eq 'UTC'
end end
end end