@@ -1,35 +1,35 | |||||
1 | require File.expand_path('../../test_helper', __FILE__) |
|
1 | require File.expand_path('../../test_helper', __FILE__) | |
2 |
|
2 | |||
3 | class BoardTest < ActiveSupport::TestCase |
|
3 | class BoardTest < ActiveSupport::TestCase | |
4 | fixtures :projects, :boards, :messages, :attachments, :watchers |
|
4 | fixtures :projects, :boards, :messages, :attachments, :watchers | |
5 |
|
5 | |||
6 | def setup |
|
6 | def setup | |
7 | @project = Project.find(1) |
|
7 | @project = Project.find(1) | |
8 | end |
|
8 | end | |
9 |
|
9 | |||
10 | def test_create |
|
10 | def test_create | |
11 | board = Board.new(:project => @project, :name => 'Test board', :description => 'Test board description') |
|
11 | board = Board.new(:project => @project, :name => 'Test board', :description => 'Test board description') | |
12 | assert board.save |
|
12 | assert board.save | |
13 | board.reload |
|
13 | board.reload | |
14 | assert_equal 'Test board', board.name |
|
14 | assert_equal 'Test board', board.name | |
15 | assert_equal 'Test board description', board.description |
|
15 | assert_equal 'Test board description', board.description | |
16 | assert_equal @project, board.project |
|
16 | assert_equal @project, board.project | |
17 | assert_equal 0, board.topics_count |
|
17 | assert_equal 0, board.topics_count | |
18 | assert_equal 0, board.messages_count |
|
18 | assert_equal 0, board.messages_count | |
19 | assert_nil board.last_message |
|
19 | assert_nil board.last_message | |
20 | # last position |
|
20 | # last position | |
21 | assert_equal @project.boards.size, board.position |
|
21 | assert_equal @project.boards.size, board.position | |
22 | end |
|
22 | end | |
23 |
|
23 | |||
24 | def test_destroy |
|
24 | def test_destroy | |
25 | board = Board.find(1) |
|
25 | board = Board.find(1) | |
26 | assert_difference 'Message.count', -6 do |
|
26 | assert_difference 'Message.count', -6 do | |
27 | assert_difference 'Attachment.count', -1 do |
|
27 | assert_difference 'Attachment.count', -1 do | |
28 | assert_difference 'Watcher.count', -1 do |
|
28 | assert_difference 'Watcher.count', -1 do | |
29 | assert board.destroy |
|
29 | assert board.destroy | |
30 | end |
|
30 | end | |
31 | end |
|
31 | end | |
32 | end |
|
32 | end | |
33 | assert_equal 0, Message.count(:conditions => {:board_id => 1}) |
|
33 | assert_equal 0, Message.count(:conditions => {:board_id => 1}) | |
34 | end |
|
34 | end | |
35 | end |
|
35 | end |
General Comments 0
You need to be logged in to leave comments.
Login now