Sha256: e2c8eb241db2b8e73424055c2a428b5cabbbc897be1a72098b408c3d97062433
Contents?: true
Size: 963 Bytes
Versions: 1
Compression:
Stored size: 963 Bytes
Contents
# frozen_string_literal: true require 'spec_helper' describe 'Cistern::Model#dirty' do subject { Class.new(Sample::Model) do identity :id attribute :name attribute :properties, type: :array def save merge_attributes(attributes) end end } it 'should mark a existing record as dirty' do model = subject.new(id: 1, name: 'steve') expect(model.changed).to be_empty expect do model.properties = [1] end.to change { model.dirty? }.to(true) expect(model.changed).to eq(properties: [nil, [1]]) expect(model.dirty_attributes).to eq(properties: [1]) expect do model.properties = [2] end.to change { model.changed }.to(properties: [nil, [2]]) expect(model.dirty_attributes).to eq(properties: [2]) expect do model.save end.to change { model.dirty? }.to(false) expect(model.changed).to eq({}) expect(model.dirty_attributes).to eq({}) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cistern-2.8.1 | spec/dirty_spec.rb |