Make the snapshots the hashes

openid
Marcin Kulik 11 years ago
parent ecdf984789
commit a10a447c53

@ -6,6 +6,8 @@ class Asciicast < ActiveRecord::Base
mount_uploader :stdout, BasicUploader
mount_uploader :stdout_timing, BasicUploader
serialize :snapshot, Hash
validates :stdout, :stdout_timing, :presence => true
validates :terminal_columns, :terminal_lines, :duration, :presence => true

@ -0,0 +1,8 @@
class ClearAsciicastSnapshots < ActiveRecord::Migration
def up
execute "UPDATE asciicasts SET snapshot = NULL"
end
def down
end
end

@ -117,4 +117,27 @@ describe Asciicast do
asciicast.terminal_type.should == terminal_type
end
end
describe '#snapshot' do
let(:asciicast) { Asciicast.new }
it 'is an empty hash initially' do
expect(asciicast.snapshot).to eq({})
end
it 'is a hash before persisting' do
asciicast.snapshot = { :foo => 1 }
expect(asciicast.snapshot).to eq({ :foo => 1})
end
it 'is a hash after persisting and loading' do
asciicast = build(:asciicast)
asciicast.snapshot = { :foo => 1 }
asciicast.save!
expect(asciicast.snapshot).to eq({ :foo => 1 })
expect(Asciicast.find(asciicast.id).snapshot).to eq({ :foo => 1 })
end
end
end

Loading…
Cancel
Save