block_test.rb
1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
require File.dirname(__FILE__) + '/../test_helper'
class BlockTest < Test::Unit::TestCase
fixtures :blocks, :profiles
def setup
@profile = Profile.find(1)
end
def test_setup_assumptions
assert @profile.valid?
end
# Replace this with your real tests.
def test_create
count = Block.count
b = Block.new
assert !b.valid?
assert b.errors.invalid?(:box_id)
assert b.errors.invalid?(:position)
box = Box.new
box.owner = @profile
box.number = 1000
assert box.save
b.box = box
assert !b.valid?
assert b.errors.invalid?(:position)
b.position=1
assert b.save
assert_equal count + 1, Block.count
end
def test_box_presence
b = Block.new
b.position = 1000
assert !b.valid?
assert b.errors.invalid?(:box_id)
box = Box.new
box.owner = @profile
box.number = 1000
assert box.save
b.box = box
assert b.valid?
end
def test_destroy
b = Block.find(1)
assert b.destroy
end
def test_valid_fixtures
Block.find(:all).each do |b|
assert b.valid?
end
end
end