create 1 file per test model
This commit is contained in:
parent
ad8405eff2
commit
ecd1dfd054
|
@ -1,75 +0,0 @@
|
|||
class DefaultState
|
||||
attr_accessor :transient_store, :persisted_store
|
||||
include AASM
|
||||
aasm do
|
||||
state :alpha, :initial => true
|
||||
state :beta
|
||||
state :gamma
|
||||
event :release do
|
||||
transitions :from => [:alpha, :beta, :gamma], :to => :beta
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class ProvidedState
|
||||
attr_accessor :transient_store, :persisted_store
|
||||
include AASM
|
||||
aasm do
|
||||
state :alpha, :initial => true
|
||||
state :beta
|
||||
state :gamma
|
||||
event :release do
|
||||
transitions :from => [:alpha, :beta, :gamma], :to => :beta
|
||||
end
|
||||
end
|
||||
|
||||
def aasm_read_state
|
||||
:beta
|
||||
end
|
||||
|
||||
def aasm_write_state(new_state)
|
||||
@persisted_store = new_state
|
||||
end
|
||||
|
||||
def aasm_write_state_without_persistence(new_state)
|
||||
@transient_store = new_state
|
||||
end
|
||||
end
|
||||
|
||||
class PersistedState < ActiveRecord::Base
|
||||
attr_accessor :transient_store, :persisted_store
|
||||
include AASM
|
||||
aasm do
|
||||
state :alpha, :initial => true
|
||||
state :beta
|
||||
state :gamma
|
||||
event :release do
|
||||
transitions :from => [:alpha, :beta, :gamma], :to => :beta
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class ProvidedAndPersistedState < ActiveRecord::Base
|
||||
attr_accessor :transient_store, :persisted_store
|
||||
include AASM
|
||||
aasm do
|
||||
state :alpha, :initial => true
|
||||
state :beta
|
||||
state :gamma
|
||||
event :release do
|
||||
transitions :from => [:alpha, :beta, :gamma], :to => :beta
|
||||
end
|
||||
end
|
||||
|
||||
def aasm_read_state
|
||||
:gamma
|
||||
end
|
||||
|
||||
def aasm_write_state(new_state)
|
||||
@persisted_store = new_state
|
||||
end
|
||||
|
||||
def aasm_write_state_without_persistence(new_state)
|
||||
@transient_store = new_state
|
||||
end
|
||||
end
|
|
@ -0,0 +1,12 @@
|
|||
class DefaultState
|
||||
attr_accessor :transient_store, :persisted_store
|
||||
include AASM
|
||||
aasm do
|
||||
state :alpha, :initial => true
|
||||
state :beta
|
||||
state :gamma
|
||||
event :release do
|
||||
transitions :from => [:alpha, :beta, :gamma], :to => :beta
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,12 @@
|
|||
class PersistedState < ActiveRecord::Base
|
||||
attr_accessor :transient_store, :persisted_store
|
||||
include AASM
|
||||
aasm do
|
||||
state :alpha, :initial => true
|
||||
state :beta
|
||||
state :gamma
|
||||
event :release do
|
||||
transitions :from => [:alpha, :beta, :gamma], :to => :beta
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,24 @@
|
|||
class ProvidedAndPersistedState < ActiveRecord::Base
|
||||
attr_accessor :transient_store, :persisted_store
|
||||
include AASM
|
||||
aasm do
|
||||
state :alpha, :initial => true
|
||||
state :beta
|
||||
state :gamma
|
||||
event :release do
|
||||
transitions :from => [:alpha, :beta, :gamma], :to => :beta
|
||||
end
|
||||
end
|
||||
|
||||
def aasm_read_state
|
||||
:gamma
|
||||
end
|
||||
|
||||
def aasm_write_state(new_state)
|
||||
@persisted_store = new_state
|
||||
end
|
||||
|
||||
def aasm_write_state_without_persistence(new_state)
|
||||
@transient_store = new_state
|
||||
end
|
||||
end
|
|
@ -0,0 +1,24 @@
|
|||
class ProvidedState
|
||||
attr_accessor :transient_store, :persisted_store
|
||||
include AASM
|
||||
aasm do
|
||||
state :alpha, :initial => true
|
||||
state :beta
|
||||
state :gamma
|
||||
event :release do
|
||||
transitions :from => [:alpha, :beta, :gamma], :to => :beta
|
||||
end
|
||||
end
|
||||
|
||||
def aasm_read_state
|
||||
:beta
|
||||
end
|
||||
|
||||
def aasm_write_state(new_state)
|
||||
@persisted_store = new_state
|
||||
end
|
||||
|
||||
def aasm_write_state_without_persistence(new_state)
|
||||
@transient_store = new_state
|
||||
end
|
||||
end
|
|
@ -1,5 +1,10 @@
|
|||
require 'spec_helper'
|
||||
require 'models/active_record/api.rb'
|
||||
require 'models/active_record/default_state.rb'
|
||||
require 'models/active_record/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
|
||||
|
|
Loading…
Reference in New Issue