Class: ODDB::State::Companies::TestUserCompanyState

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



151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'test/test_state/companies/company.rb', line 151

def setup
  @session = StubSession.new
  @app = StubApp.new
  @session.app = @app
  @model  = StubCompany.new
  @model.pointer = 'bar'
  @state = State::Companies::UserCompany.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



176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'test/test_state/companies/company.rb', line 176

def test_update1
  @session.user_equiv = true
  @state.update()
  expected = {
    :address => 'Bahnhofstrasse 10',
    :address_email => '',
    :business_area => 'Pharmafirma',
    :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



197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'test/test_state/companies/company.rb', line 197

def test_update2
  @session.user_equiv = true
  @app.company_of_same_name = @model
  @state.update()
  expected = {
    :address => 'Bahnhofstrasse 10',
    :address_email => '',
    :business_area => 'Pharmafirma',
    :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



219
220
221
222
223
224
# File 'test/test_state/companies/company.rb', line 219

def test_update3
  @session.user_equiv = false
  @state.update()
  assert_nil(@app.pointer)
  assert_nil(@app.input) 
end