Class: ODDB::TestUserObserver

Inherits:
Test::Unit::TestCase
  • Object
show all
Includes:
FlexMock::TestCase
Defined in:
test/test_model/user.rb

Defined Under Namespace

Classes: Observer

Instance Method Summary (collapse)

Instance Method Details

- (Object) setup



228
229
230
# File 'test/test_model/user.rb', line 228

def setup
  @observer = Observer.new
end

- (Object) test_add_user



231
232
233
234
235
236
237
238
239
240
241
242
# File 'test/test_model/user.rb', line 231

def test_add_user
  user = flexmock 'user'
  @observer.add_user nil
  assert_equal [], @observer.users
  @observer.add_user user
  assert_equal [user], @observer.users
  assert_equal true, @observer.saved
  @observer.add_user user
  assert_equal [user], @observer.users
  @observer.add_user nil
  assert_equal [user], @observer.users
end

- (Object) test_contact_email



243
244
245
246
247
248
249
# File 'test/test_model/user.rb', line 243

def test_contact_email
  assert_nil @observer.contact_email
  @observer.users.push flexmock(:yus_name => 'test@email.ch')
  assert_equal 'test@email.ch', @observer.contact_email
  @observer.users.push flexmock(:yus_name => 'other@email.ch')
  assert_equal 'test@email.ch', @observer.contact_email
end

- (Object) test_has_user



250
251
252
253
254
# File 'test/test_model/user.rb', line 250

def test_has_user
  assert_equal false, @observer.has_user?
  @observer.users.push flexmock(:yus_name => 'test@email.ch')
  assert_equal true, @observer.has_user?
end

- (Object) test_invoice_email



255
256
257
258
259
260
261
262
263
# File 'test/test_model/user.rb', line 255

def test_invoice_email
  assert_nil @observer.invoice_email
  @observer.users.push flexmock(:yus_name => 'test@email.ch')
  assert_equal 'test@email.ch', @observer.invoice_email
  @observer.users.push flexmock(:yus_name => 'other@email.ch')
  assert_equal 'test@email.ch', @observer.invoice_email
  @observer.invoice_email = 'other@email.ch'
  assert_equal 'other@email.ch', @observer.invoice_email
end

- (Object) test_remove_user



264
265
266
267
268
269
270
271
272
273
274
# File 'test/test_model/user.rb', line 264

def test_remove_user
  user = flexmock 'user'
  @observer.users.push user
  other = flexmock 'other'
  @observer.remove_user other
  assert_equal [user], @observer.users
  assert_nil @observer.saved
  @observer.remove_user user
  assert_equal [], @observer.users
  assert_equal true, @observer.saved
end