Sha256: a3dac9437056e994259f7b4491e67eba77bd241cd39d17892c04239fb9799aec
Contents?: true
Size: 1.2 KB
Versions: 1
Compression:
Stored size: 1.2 KB
Contents
require "spec_helper" require "json" describe "Sequel::Plugins::Bitemporal" do include DbHelpers before :all do db_setup @version_class.instance_eval do plugin :serialization serialize_attributes :json, :name end end subject{ @master_class.new.update_attributes name: {test: 1}, price: 18 } it "serializes as expected" do subject.name.should == {"test" => 1} end it "doesn't create a new version when value hasn't changed" do name = subject.name.dup name["test"] = 1 subject.attributes = {name: name} lambda{ subject.save }.should_not change(@version_class, :count) end it "doesn't create a new version when value is the same" do subject.attributes = {name: {"test" => 1}} lambda{ subject.save }.should_not change(@version_class, :count) end it "does create a new version when value has changed" do name = subject.name.dup name["test"] = 0 subject.attributes = {name: name} lambda{ subject.save }.should change(@version_class, :count).by 1 end it "does create a new version when value is not the same" do subject.attributes = {name: {"test" => 0}} lambda{ subject.save }.should change(@version_class, :count).by 1 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sequel_bitemporal-0.6.10 | spec/bitemporal_serialization_spec.rb |