Class: ODDB::Migel::TestSubgroup

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

Instance Method Summary (collapse)

Instance Method Details

- (Object) setup



16
17
18
# File 'test/test_model/migel_subgroup.rb', line 16

def setup
  @subgroup = Subgroup.new('01')
end

- (Object) test_checkout



19
20
21
22
23
24
25
26
27
28
29
# File 'test/test_model/migel_subgroup.rb', line 19

def test_checkout
  prod = flexmock 'product'
  @subgroup.products.store '02', prod
  assert_raises(RuntimeError) do
    @subgroup.checkout
  end
  @subgroup.products.clear
  assert_nothing_raised do
    @subgroup.checkout
  end
end

- (Object) test_create_limitation_text



30
31
32
33
34
35
# File 'test/test_model/migel_subgroup.rb', line 30

def test_create_limitation_text
  assert_nil @subgroup.limitation_text
  res = @subgroup.create_limitation_text
  assert_instance_of LimitationText, res
  assert_equal res, @subgroup.limitation_text
end

- (Object) test_create_product



36
37
38
39
40
41
42
43
# File 'test/test_model/migel_subgroup.rb', line 36

def test_create_product
  product = @subgroup.create_product('01.02.2')
  assert_instance_of(ODDB::Migel::Product, product)
  assert_equal({'01.02.2' => product }, @subgroup.products)
  assert_equal('01.02.2', product.code)
  assert_equal(@subgroup, product.subgroup)
  assert_equal(product, @subgroup.product('01.02.2'))
end

- (Object) test_delete_limitation_text



44
45
46
47
48
49
# File 'test/test_model/migel_subgroup.rb', line 44

def test_delete_limitation_text
  lt = flexmock :odba_delete => true
  @subgroup.instance_variable_set '@limitation_text', lt
  @subgroup.delete_limitation_text
  assert_nil @subgroup.limitation_text
end

- (Object) test_delete_product



50
51
52
53
54
55
# File 'test/test_model/migel_subgroup.rb', line 50

def test_delete_product
  prod = flexmock 'product'
  @subgroup.products.store '02', prod
  @subgroup.delete_product '02'
  assert_equal({}, @subgroup.products)
end

- (Object) test_group_code



56
57
58
59
# File 'test/test_model/migel_subgroup.rb', line 56

def test_group_code
  @subgroup.group = flexmock :code => '03'
  assert_equal '03', @subgroup.group_code
end

- (Object) test_migel_code



60
61
62
63
# File 'test/test_model/migel_subgroup.rb', line 60

def test_migel_code
  @subgroup.group = flexmock :code => '03'
  assert_equal '03.01', @subgroup.migel_code
end