Sha256: 30c7f7193573ba467936d01c66efee3dfdbdf4bd48f4f1938ce88ef470dfc533

Contents?: true

Size: 945 Bytes

Versions: 7

Compression:

Stored size: 945 Bytes

Contents

require File.join(File.dirname(File.expand_path(__FILE__)), "spec_helper")

describe "serialization_modification_detection plugin" do
  before do
    @c = Class.new(Sequel::Model(:items))
    @c.class_eval do
      columns :id, :h
      plugin :serialization, :yaml, :h
      plugin :serialization_modification_detection
    end
    @o1 = @c.new
    @o2 = @c.load(:id=>1, :h=>"--- {}\n\n")
    MODEL_DB.reset
  end
  
  it "should not detect columns that haven't been changed" do
    @o2.changed_columns.should == []
    @o2.h.should == {}
    @o2.h[1] = 2
    @o2.h.clear
    @o2.changed_columns.should == []
  end
  
  it "should detect columns that have been changed" do
    @o2.changed_columns.should == []
    @o2.h.should == {}
    @o2.h[1] = 2
    @o2.changed_columns.should == [:h]
  end
  
  it "should report correct changed_columns after saving" do
    @o2.h[1] = 2
    @o2.save_changes
    @o2.changed_columns.should == []
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sequel-3.28.0 spec/extensions/serialization_modification_detection_spec.rb
sequel-3.27.0 spec/extensions/serialization_modification_detection_spec.rb
sequel-3.26.0 spec/extensions/serialization_modification_detection_spec.rb
sequel-3.25.0 spec/extensions/serialization_modification_detection_spec.rb
sequel-3.24.1 spec/extensions/serialization_modification_detection_spec.rb
sequel-3.24.0 spec/extensions/serialization_modification_detection_spec.rb
sequel-3.23.0 spec/extensions/serialization_modification_detection_spec.rb