Class: ODDB::State::Companies::TestRootCompanyState

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

Defined Under Namespace

Classes: StubApp, StubCompany, StubSession

Instance Method Summary (collapse)

Instance Method Details

- (Object) setup



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'test/test_state/companies/company.rb', line 40

def setup
  @session = StubSession.new
  @app = StubApp.new
  @session.app = @app
  @model  = StubCompany.new
  @model.pointer = 'bar'
  @state = State::Companies::RootCompany.new(@session, @model)
  @session.user_input = {
    :name => 'Ecosol AG',
    :contact => 'Hans Meier',
    :contact_email => 'ecosol@ecosol.ch',
    :address => 'Bahnhofstrasse 10',
    :plz => '5780',
    :location => 'Baden',
    :url => 'www.oddb.org',
    :phone => '079 456 43 67',
    :fax => '655 453 44 54',
    :address_email => '',
    :cl_status => true,
    :ean13 => '1234567890976',
    :business_area => 'Pharmafirma',
    :fi_status => true,
    :foo => '12434',
  }
end

- (Object) test_update1



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'test/test_state/companies/company.rb', line 72

def test_update1
  @state.update()
  expected = {
    :address => 'Bahnhofstrasse 10',
    :address_email => '',
    :business_area => 'Pharmafirma',
    :cl_status => true,
    :contact_email => 'ecosol@ecosol.ch',
    :contact => 'Hans Meier',
    :ean13 => '1234567890976',
    :fax => '655 453 44 54',
    :fi_status => true,
    :location => 'Baden',
    :name => 'Ecosol AG',
    :phone => '079 456 43 67',
    :plz => '5780',
    :url => 'www.oddb.org',
  }
  assert_equal(@model.pointer, @app.pointer)
  assert_equal(expected, @app.input) 
end

- (Object) test_update2



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'test/test_state/companies/company.rb', line 93

def test_update2
  @app.company_of_same_name = @model
  @state.update()
  expected = {
    :address => 'Bahnhofstrasse 10',
    :address_email => '',
    :business_area => 'Pharmafirma',
    :cl_status => true,
    :contact_email => 'ecosol@ecosol.ch',
    :contact => 'Hans Meier',
    :ean13 => '1234567890976',
    :fax => '655 453 44 54',
    :fi_status => true,
    :location => 'Baden',
    :name => 'Ecosol AG',
    :phone => '079 456 43 67',
    :plz => '5780',
    :url => 'www.oddb.org',
  }
  assert_equal(@model.pointer, @app.pointer)
  assert_equal(expected, @app.input) 
end

- (Object) test_update3



115
116
117
118
119
120
# File 'test/test_state/companies/company.rb', line 115

def test_update3
  @app.company_of_same_name = StubCompany.new
  @state.update()
  assert_nil(@app.pointer)
  assert_nil(@app.input) 
end

- (Object) test_update_no_name



65
66
67
68
69
70
71
# File 'test/test_state/companies/company.rb', line 65

def test_update_no_name
  @session.user_input = {
    :name  => nil,
  }
  @state.update
  assert_equal(true, @state.error?)
end