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:
commit
8cd8b6d0f0
3 changed files with 26 additions and 0 deletions
|
@ -70,6 +70,11 @@ module AASM
|
||||||
@aasm[name.to_sym] ||= AASM::InstanceBase.new(self, name.to_sym)
|
@aasm[name.to_sym] ||= AASM::InstanceBase.new(self, name.to_sym)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def initialize_dup(other)
|
||||||
|
@aasm = {}
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# Takes args and a from state and removes the first
|
# Takes args and a from state and removes the first
|
||||||
|
|
|
@ -3,6 +3,7 @@ $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib
|
||||||
require 'aasm'
|
require 'aasm'
|
||||||
require 'rspec'
|
require 'rspec'
|
||||||
require 'aasm/rspec'
|
require 'aasm/rspec'
|
||||||
|
require 'pry'
|
||||||
|
|
||||||
# require 'ruby-debug'; Debugger.settings[:autoeval] = true; debugger; rubys_debugger = 'annoying'
|
# require 'ruby-debug'; Debugger.settings[:autoeval] = true; debugger; rubys_debugger = 'annoying'
|
||||||
# require 'ruby-debug/completion'
|
# require 'ruby-debug/completion'
|
||||||
|
|
|
@ -22,6 +22,26 @@ describe "reading the current state" do
|
||||||
it "uses the provided method even if persisted" do
|
it "uses the provided method even if persisted" do
|
||||||
expect(ProvidedAndPersistedState.new.aasm.current_state).to eql :gamma
|
expect(ProvidedAndPersistedState.new.aasm.current_state).to eql :gamma
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe "writing and persisting the current state" do
|
describe "writing and persisting the current state" do
|
||||||
|
|
Loading…
Reference in a new issue