1
0
Fork 0
mirror of https://github.com/aasm/aasm synced 2023-03-27 23:22:41 -04:00
lingceng 2016-02-18 15:01:52 +08:00
parent e750b83696
commit 8f4b096985
3 changed files with 26 additions and 0 deletions

View file

@ -67,6 +67,11 @@ module AASM
@aasm[name.to_sym] ||= AASM::InstanceBase.new(self, name.to_sym)
end
def initialize_dup(other)
@aasm = {}
super
end
private
# Takes args and a from state and removes the first

View file

@ -3,6 +3,7 @@ $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib
require 'aasm'
require 'rspec'
require 'aasm/rspec'
require 'pry'
# require 'ruby-debug'; Debugger.settings[:autoeval] = true; debugger; rubys_debugger = 'annoying'
# require 'ruby-debug/completion'

View file

@ -22,6 +22,26 @@ describe "reading the current state" do
it "uses the provided method even if persisted" do
expect(ProvidedAndPersistedState.new.aasm.current_state).to eql :gamma
end
context "after dup" do
it "uses the persistence storage" do
source = PersistedState.create!
copy = source.dup
copy.save!
copy.release!
expect(source.aasm_state).to eql 'alpha'
expect(source.aasm.current_state).to eql :alpha
source2 = PersistedState.find(source.id)
expect(source2.reload.aasm_state).to eql 'alpha'
expect(source2.aasm.current_state).to eql :alpha
expect(copy.aasm_state).to eql 'beta'
expect(copy.aasm.current_state).to eql :beta
end
end
end
describe "writing and persisting the current state" do