Sha256: 731e16ff3e871dc937aa569f5a4d54ec176dff6c6d813e78a4723469437dc2cd

Contents?: true

Size: 1.85 KB

Versions: 11

Compression:

Stored size: 1.85 KB

Contents

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
aasm-4.9.0 spec/unit/api_spec.rb
aasm-4.8.0 spec/unit/api_spec.rb
aasm-4.7.0 spec/unit/api_spec.rb
aasm-4.6.0 spec/unit/api_spec.rb
aasm-4.5.2 spec/unit/api_spec.rb
aasm-4.5.1 spec/unit/api_spec.rb
aasm-4.5.0 spec/unit/api_spec.rb
aasm-4.4.1 spec/unit/api_spec.rb
aasm-4.4.0 spec/unit/api_spec.rb
aasm-4.3.0 spec/unit/api_spec.rb
aasm-4.2.0 spec/unit/api_spec.rb