1
0
Fork 0
mirror of https://github.com/aasm/aasm synced 2023-03-27 23:22:41 -04:00

Merge pull request #325 from lingceng/master

Fix #273 work right after dup
This commit is contained in:
Thorsten Böttger 2016-03-18 21:47:31 +13:00
commit 8cd8b6d0f0
3 changed files with 26 additions and 0 deletions

View file

@ -70,6 +70,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