Sha256: 0c82ae6c8a2f51664a24eec6264c18f5dc8940b6b1ad1bbc2738a8efc7d18ecb
Contents?: true
Size: 1.14 KB
Versions: 1
Compression:
Stored size: 1.14 KB
Contents
require 'spec_helper' describe Mongoid::History::Tracker do before :each do class Element include Mongoid::Document include Mongoid::Timestamps include Mongoid::History::Trackable track_history field :body # force preparation of options history_trackable_options end class Prompt < Element field :head end class User include Mongoid::Document end end after :each do Object.send(:remove_const, :Element) Object.send(:remove_const, :Prompt) Object.send(:remove_const, :User) end let(:user) { User.create! } it 'tracks subclass create and update' do prompt = Prompt.new(modifier: user) expect { prompt.save! }.to change(Tracker, :count).by(1) expect { prompt.update_attributes!(body: 'one', head: 'two') }.to change(Tracker, :count).by(1) prompt.undo! user expect(prompt.body).to be_blank expect(prompt.head).to be_blank prompt.redo! user, 2 expect(prompt.body).to eq('one') expect(prompt.head).to eq('two') expect { prompt.destroy }.to change(Tracker, :count).by(1) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mongoid-history-0.8.5 | spec/integration/subclasses_spec.rb |