Class: ODDB::State::Companies::TestMergeCompaniesState

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

Defined Under Namespace

Classes: StubApp, StubCompany, StubPointer, StubSession

Instance Method Summary (collapse)

Instance Method Details

- (Object) setup



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'test/test_state/companies/mergecompanies.rb', line 67

def setup
  @session = StubSession.new
  @company = StubCompany.new 
  @company2 = StubCompany.new
  @company.name = 'ywesee'
  @company2.name = 'ehz'
  @session.app.companies = {
    '2'  => @company,
    '1'  => @company2,
  }
  @state = State::Companies::MergeCompanies.new(@session, @company)
  @reg = Registration.new(10)
  @reg2 = Registration.new(11)
  @company.add_registration(@reg)
  @company.add_registration(@reg2)
end

- (Object) test_no_target



83
84
85
86
87
88
89
90
# File 'test/test_state/companies/mergecompanies.rb', line 83

def test_no_target
  newstate = @state.trigger(:merge)
  assert_equal(false, @session.app.merge_called)
  assert_equal(@state, newstate)
  assert_equal(true, @state.errors.values.any?{|err|
    err.message == 'e_unknown_company'
  })
end

- (Object) test_same_target



91
92
93
94
95
96
97
98
99
# File 'test/test_state/companies/mergecompanies.rb', line 91

def test_same_target
  company = @session.user_input = {:company_form => 'ywesee'}
  newstate = @state.trigger(:merge)
  assert_equal(false, @session.app.merge_called)
  assert_equal(@state, newstate)
  assert_equal(true, @state.errors.values.any?{|err|
    err.message == 'e_selfmerge_company'
  })
end

- (Object) test_target



100
101
102
103
104
105
# File 'test/test_state/companies/mergecompanies.rb', line 100

def test_target
  @session.user_input = {:company_form => 'ehz'}
  newstate = @state.trigger(:merge)
  assert_equal(true, @session.app.merge_called)
  assert_equal(State::Companies::Company, newstate.class)
end