Serialize Snapshot with Snapshot::Serializer
This commit is contained in:
parent
a10a447c53
commit
8daf2d0f7f
@ -6,7 +6,7 @@ class Asciicast < ActiveRecord::Base
|
||||
mount_uploader :stdout, BasicUploader
|
||||
mount_uploader :stdout_timing, BasicUploader
|
||||
|
||||
serialize :snapshot, Hash
|
||||
serialize :snapshot, Snapshot::Serializer.new
|
||||
|
||||
validates :stdout, :stdout_timing, :presence => true
|
||||
validates :terminal_columns, :terminal_lines, :duration, :presence => true
|
||||
|
@ -121,23 +121,23 @@ describe Asciicast do
|
||||
describe '#snapshot' do
|
||||
let(:asciicast) { Asciicast.new }
|
||||
|
||||
it 'is an empty hash initially' do
|
||||
expect(asciicast.snapshot).to eq({})
|
||||
it 'is empty Snapshot instance initially' do
|
||||
expect(asciicast.snapshot).to eq(Snapshot.new)
|
||||
end
|
||||
|
||||
it 'is a hash before persisting' do
|
||||
asciicast.snapshot = { :foo => 1 }
|
||||
it 'is a Snapshot instance before persisting' do
|
||||
asciicast.snapshot = Snapshot.new({ :foo => 1 })
|
||||
|
||||
expect(asciicast.snapshot).to eq({ :foo => 1})
|
||||
expect(asciicast.snapshot).to eq(Snapshot.new({ :foo => 1 }))
|
||||
end
|
||||
|
||||
it 'is a hash after persisting and loading' do
|
||||
it 'is a Snapshot instance after persisting and loading' do
|
||||
asciicast = build(:asciicast)
|
||||
asciicast.snapshot = { :foo => 1 }
|
||||
asciicast.snapshot = Snapshot.new({ :foo => 1 })
|
||||
asciicast.save!
|
||||
|
||||
expect(asciicast.snapshot).to eq({ :foo => 1 })
|
||||
expect(Asciicast.find(asciicast.id).snapshot).to eq({ :foo => 1 })
|
||||
expect(asciicast.snapshot).to eq(Snapshot.new({ :foo => 1 }))
|
||||
expect(Asciicast.find(asciicast.id).snapshot).to eq(Snapshot.new({ :foo => 1 }))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user