2013-04-24 06:57:06 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
require 'models/active_record/api.rb'
|
|
|
|
|
2013-04-24 07:51:21 -04:00
|
|
|
describe "reading the current state" do
|
2013-04-24 06:57:06 -04:00
|
|
|
it "uses the AASM default" do
|
|
|
|
DefaultState.new.aasm.current_state.should eql :alpha
|
|
|
|
end
|
|
|
|
|
|
|
|
it "uses the provided method" do
|
|
|
|
ProvidedState.new.aasm.current_state.should eql :beta
|
|
|
|
end
|
|
|
|
|
|
|
|
it "uses the persistence storage" do
|
|
|
|
PersistedState.new.aasm.current_state.should eql :alpha
|
|
|
|
end
|
|
|
|
|
|
|
|
it "uses the provided method even if persisted" do
|
|
|
|
ProvidedAndPersistedState.new.aasm.current_state.should eql :gamma
|
|
|
|
end
|
|
|
|
end
|
2013-04-24 07:51:21 -04:00
|
|
|
|
2013-04-24 08:19:02 -04:00
|
|
|
describe "writing and persisting the current state" do
|
2013-04-24 07:51:21 -04:00
|
|
|
it "uses the AASM default" do
|
|
|
|
o = DefaultState.new
|
|
|
|
o.release!
|
2013-04-24 08:19:02 -04:00
|
|
|
o.persisted_store.should be_nil
|
2013-04-24 07:51:21 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "uses the provided method" do
|
|
|
|
o = ProvidedState.new
|
|
|
|
o.release!
|
2013-04-24 08:19:02 -04:00
|
|
|
o.persisted_store.should eql :beta
|
2013-04-24 07:51:21 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "uses the persistence storage" do
|
|
|
|
o = PersistedState.new
|
|
|
|
o.release!
|
2013-04-24 08:19:02 -04:00
|
|
|
o.persisted_store.should be_nil
|
2013-04-24 07:51:21 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "uses the provided method even if persisted" do
|
|
|
|
o = ProvidedAndPersistedState.new
|
|
|
|
o.release!
|
2013-04-24 08:19:02 -04:00
|
|
|
o.persisted_store.should eql :beta
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "writing the current state without persisting it" do
|
|
|
|
it "uses the AASM default" do
|
|
|
|
o = DefaultState.new
|
|
|
|
o.release
|
|
|
|
o.transient_store.should be_nil
|
|
|
|
end
|
|
|
|
|
|
|
|
it "uses the provided method" do
|
|
|
|
o = ProvidedState.new
|
|
|
|
o.release
|
|
|
|
o.transient_store.should eql :beta
|
|
|
|
end
|
|
|
|
|
|
|
|
it "uses the persistence storage" do
|
|
|
|
o = PersistedState.new
|
|
|
|
o.release
|
|
|
|
o.transient_store.should be_nil
|
|
|
|
end
|
|
|
|
|
|
|
|
it "uses the provided method even if persisted" do
|
|
|
|
o = ProvidedAndPersistedState.new
|
|
|
|
o.release
|
2013-04-24 07:51:21 -04:00
|
|
|
o.transient_store.should eql :beta
|
|
|
|
end
|
|
|
|
end
|