mirror of
https://github.com/aasm/aasm
synced 2023-03-27 23:22:41 -04:00
77 lines
1.8 KiB
Ruby
77 lines
1.8 KiB
Ruby
require 'spec_helper'
|
|
require 'models/default_state.rb'
|
|
require 'models/provided_state.rb'
|
|
require 'models/active_record/persisted_state.rb'
|
|
require 'models/active_record/provided_and_persisted_state.rb'
|
|
|
|
load_schema
|
|
|
|
describe "reading the current state" do
|
|
it "uses the AASM default" do
|
|
expect(DefaultState.new.aasm.current_state).to eql :alpha
|
|
end
|
|
|
|
it "uses the provided method" do
|
|
expect(ProvidedState.new.aasm.current_state).to eql :beta
|
|
end
|
|
|
|
it "uses the persistence storage" do
|
|
expect(PersistedState.new.aasm.current_state).to eql :alpha
|
|
end
|
|
|
|
it "uses the provided method even if persisted" do
|
|
expect(ProvidedAndPersistedState.new.aasm.current_state).to eql :gamma
|
|
end
|
|
end
|
|
|
|
describe "writing and persisting the current state" do
|
|
it "uses the AASM default" do
|
|
o = DefaultState.new
|
|
o.release!
|
|
expect(o.persisted_store).to be_nil
|
|
end
|
|
|
|
it "uses the provided method" do
|
|
o = ProvidedState.new
|
|
o.release!
|
|
expect(o.persisted_store).to eql :beta
|
|
end
|
|
|
|
it "uses the persistence storage" do
|
|
o = PersistedState.new
|
|
o.release!
|
|
expect(o.persisted_store).to be_nil
|
|
end
|
|
|
|
it "uses the provided method even if persisted" do
|
|
o = ProvidedAndPersistedState.new
|
|
o.release!
|
|
expect(o.persisted_store).to eql :beta
|
|
end
|
|
end
|
|
|
|
describe "writing the current state without persisting it" do
|
|
it "uses the AASM default" do
|
|
o = DefaultState.new
|
|
o.release
|
|
expect(o.transient_store).to be_nil
|
|
end
|
|
|
|
it "uses the provided method" do
|
|
o = ProvidedState.new
|
|
o.release
|
|
expect(o.transient_store).to eql :beta
|
|
end
|
|
|
|
it "uses the persistence storage" do
|
|
o = PersistedState.new
|
|
o.release
|
|
expect(o.transient_store).to be_nil
|
|
end
|
|
|
|
it "uses the provided method even if persisted" do
|
|
o = ProvidedAndPersistedState.new
|
|
o.release
|
|
expect(o.transient_store).to eql :beta
|
|
end
|
|
end
|