Class: ODDB::State::Admin::TestRootState

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
test/test_state/admin/root.rb

Defined Under Namespace

Classes: StubApp, StubPointer, StubSession, TestState

Instance Method Summary (collapse)

Instance Method Details

- (Object) setup



75
76
77
78
# File 'test/test_state/admin/root.rb', line 75

def setup
  @session = StubSession.new
  @state = State::Drugs::Init.new(@session, @session)
end

- (Object) test_new_registration



97
98
99
100
101
# File 'test/test_state/admin/root.rb', line 97

def test_new_registration
  @state.extend(State::Admin::Root)
  regstate = @state.new_registration
  assert_equal(nil, regstate.model.company)
end

- (Object) test_resolve_root_state



79
80
81
82
83
84
# File 'test/test_state/admin/root.rb', line 79

def test_resolve_root_state
  pointer = Persistence::Pointer.new([:resolve, "foo", "bar"])
  assert_equal(State::Admin::StubResolvedState, @state.resolve_state(pointer))
  @state.extend(State::Admin::Root)
  assert_equal(State::Admin::StubResolvedRootState, @state.resolve_state(pointer))
end

- (Object) test_root_state



85
86
87
88
89
90
91
92
93
94
95
96
# File 'test/test_state/admin/root.rb', line 85

def test_root_state
  @state.extend(State::Admin::Root)
  assert(@state.is_a?(State::Admin::Root), 'extend did not work')
  state = @state.trigger(:login_form)
  assert_equal(State::Admin::, state.class)
  assert(state.is_a?(State::Admin::Root), 'trigger did not pass on RootState')
  newstate = state.trigger(:resolve)
  assert_equal(State::Admin::StubResolvedRootState, newstate.class)
  state = state.trigger(:logout)
  assert_equal(State::Drugs::Init, state.class)
  assert(!state.is_a?(State::Admin::Root), 'should not include RootState after logout')
end