fluke/devops-service/spec/models/report_spec.rb

43 lines
961 B
Ruby
Raw Normal View History

2015-11-03 11:46:54 +03:00
require 'db/mongo/models/report'
RSpec.describe Devops::Model::Report, type: :model do
let(:report) { build(:report) }
describe '#initialize' do
it 'converts created_at to localtime' do
now = Time.now.utc
expect(now.zone).to eq 'UTC'
expect(
build(:report, created_at: now).created_at.zone
).not_to eq 'UTC'
end
it 'converts updated_at to localtime' do
now = Time.now.utc
expect(now.zone).to eq 'UTC'
expect(
build(:report, updated_at: now).updated_at.zone
).not_to eq 'UTC'
end
end
describe '#to_hash_without_id' do
it 'contains several fields' do
expect(report.to_hash_without_id.keys).to match_array(%w(
file
created_at
updated_at
created_by
project
deploy_env
type
chef_node_name
host
status
stack
subreports
job_result_code
))
end
end
end