Sha256: fee9b9c38804a47a485b44e6d96e1eb25548b3b29ee71b6a6e2b21da97657921

Contents?: true

Size: 771 Bytes

Versions: 8

Compression:

Stored size: 771 Bytes

Contents

require 'spec_helper'

describe Mongoid::History::Tracker do
  before :all do
    class Element
      include Mongoid::Document
      include Mongoid::Timestamps
      include Mongoid::History::Trackable

      field :body

      track_history on: [:body], track_create: true, track_update: true, track_destroy: true
    end

    class Prompt < Element
    end
  end

  it 'tracks subclass create and update' do
    prompt = Prompt.new
    expect { prompt.save! }.to change(Tracker, :count).by(1)
    expect { prompt.update_attributes!(body: 'one') }.to change(Tracker, :count).by(1)
    prompt.undo!
    expect(prompt.body).to be_blank
    prompt.redo! nil, 2
    expect(prompt.body).to eq('one')
    expect { prompt.destroy }.to change(Tracker, :count).by(1)
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
mongoid-history-0.8.0 spec/integration/subclasses_spec.rb
mongoid-history-0.7.0 spec/integration/subclasses_spec.rb
mongoid-history-0.6.1 spec/integration/subclasses_spec.rb
mongoid-history-0.6.0 spec/integration/subclasses_spec.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/mongoid-history-0.5.0/spec/integration/subclasses_spec.rb
mongoid-history-0.5.0 spec/integration/subclasses_spec.rb
mongoid-history-0.4.7 spec/integration/subclasses_spec.rb
mongoid-history-0.4.5 spec/integration/subclasses_spec.rb