2019-04-21 05:43:51 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
if defined?(ActiveRecord)
|
|
|
|
require 'models/active_record/person'
|
|
|
|
|
|
|
|
load_schema
|
|
|
|
describe 'Abstract subclassing' do
|
|
|
|
|
|
|
|
it 'should have the parent states' do
|
|
|
|
Person.aasm.states.each do |state|
|
2019-04-21 06:48:23 -04:00
|
|
|
expect(Base.aasm.states).to include(state)
|
2019-04-21 05:43:51 -04:00
|
|
|
end
|
2019-04-21 06:48:23 -04:00
|
|
|
expect(Person.aasm.states).to eq(Base.aasm.states)
|
2019-04-21 05:43:51 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should have the same events as its parent' do
|
2019-04-21 06:48:23 -04:00
|
|
|
expect(Base.aasm.events).to eq(Person.aasm.events)
|
2019-04-21 05:43:51 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should not break aasm methods when super class is abstract_class' do
|
|
|
|
person = Person.new
|
|
|
|
person.status = 'active'
|
|
|
|
person.deactivate!
|
|
|
|
expect(person.aasm.current_state).to eq(:inactive)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|