@@ -26,18 +26,23 class RepositoriesDarcsControllerTest < ActionController::TestCase | |||||
26 |
|
26 | |||
27 | # No '..' in the repository path |
|
27 | # No '..' in the repository path | |
28 | REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/darcs_repository' |
|
28 | REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/darcs_repository' | |
|
29 | PRJ_ID = 3 | |||
29 |
|
30 | |||
30 | def setup |
|
31 | def setup | |
31 | @controller = RepositoriesController.new |
|
32 | @controller = RepositoriesController.new | |
32 | @request = ActionController::TestRequest.new |
|
33 | @request = ActionController::TestRequest.new | |
33 | @response = ActionController::TestResponse.new |
|
34 | @response = ActionController::TestResponse.new | |
34 | User.current = nil |
|
35 | User.current = nil | |
35 | Repository::Darcs.create(:project => Project.find(3), :url => REPOSITORY_PATH) |
|
36 | @project = Project.find(PRJ_ID) | |
|
37 | @repository = Repository::Darcs.create(:project => @project, :url => REPOSITORY_PATH) | |||
|
38 | assert @repository | |||
36 | end |
|
39 | end | |
37 |
|
40 | |||
38 | if File.directory?(REPOSITORY_PATH) |
|
41 | if File.directory?(REPOSITORY_PATH) | |
39 | def test_show |
|
42 | def test_show | |
40 | get :show, :id => 3 |
|
43 | @repository.fetch_changesets | |
|
44 | @repository.reload | |||
|
45 | get :show, :id => PRJ_ID | |||
41 | assert_response :success |
|
46 | assert_response :success | |
42 | assert_template 'show' |
|
47 | assert_template 'show' | |
43 | assert_not_nil assigns(:entries) |
|
48 | assert_not_nil assigns(:entries) | |
@@ -45,7 +50,9 class RepositoriesDarcsControllerTest < ActionController::TestCase | |||||
45 | end |
|
50 | end | |
46 |
|
51 | |||
47 | def test_browse_root |
|
52 | def test_browse_root | |
48 | get :show, :id => 3 |
|
53 | @repository.fetch_changesets | |
|
54 | @repository.reload | |||
|
55 | get :show, :id => PRJ_ID | |||
49 | assert_response :success |
|
56 | assert_response :success | |
50 | assert_template 'show' |
|
57 | assert_template 'show' | |
51 | assert_not_nil assigns(:entries) |
|
58 | assert_not_nil assigns(:entries) | |
@@ -56,7 +63,9 class RepositoriesDarcsControllerTest < ActionController::TestCase | |||||
56 | end |
|
63 | end | |
57 |
|
64 | |||
58 | def test_browse_directory |
|
65 | def test_browse_directory | |
59 | get :show, :id => 3, :path => ['images'] |
|
66 | @repository.fetch_changesets | |
|
67 | @repository.reload | |||
|
68 | get :show, :id => PRJ_ID, :path => ['images'] | |||
60 | assert_response :success |
|
69 | assert_response :success | |
61 | assert_template 'show' |
|
70 | assert_template 'show' | |
62 | assert_not_nil assigns(:entries) |
|
71 | assert_not_nil assigns(:entries) | |
@@ -68,8 +77,9 class RepositoriesDarcsControllerTest < ActionController::TestCase | |||||
68 | end |
|
77 | end | |
69 |
|
78 | |||
70 | def test_browse_at_given_revision |
|
79 | def test_browse_at_given_revision | |
71 |
|
|
80 | @repository.fetch_changesets | |
72 | get :show, :id => 3, :path => ['images'], :rev => 1 |
|
81 | @repository.reload | |
|
82 | get :show, :id => PRJ_ID, :path => ['images'], :rev => 1 | |||
73 | assert_response :success |
|
83 | assert_response :success | |
74 | assert_template 'show' |
|
84 | assert_template 'show' | |
75 | assert_not_nil assigns(:entries) |
|
85 | assert_not_nil assigns(:entries) | |
@@ -77,16 +87,19 class RepositoriesDarcsControllerTest < ActionController::TestCase | |||||
77 | end |
|
87 | end | |
78 |
|
88 | |||
79 | def test_changes |
|
89 | def test_changes | |
80 | get :changes, :id => 3, :path => ['images', 'edit.png'] |
|
90 | @repository.fetch_changesets | |
|
91 | @repository.reload | |||
|
92 | get :changes, :id => PRJ_ID, :path => ['images', 'edit.png'] | |||
81 | assert_response :success |
|
93 | assert_response :success | |
82 | assert_template 'changes' |
|
94 | assert_template 'changes' | |
83 | assert_tag :tag => 'h2', :content => 'edit.png' |
|
95 | assert_tag :tag => 'h2', :content => 'edit.png' | |
84 | end |
|
96 | end | |
85 |
|
97 | |||
86 | def test_diff |
|
98 | def test_diff | |
87 |
|
|
99 | @repository.fetch_changesets | |
|
100 | @repository.reload | |||
88 | # Full diff of changeset 5 |
|
101 | # Full diff of changeset 5 | |
89 |
get :diff, :id => |
|
102 | get :diff, :id => PRJ_ID, :rev => 5 | |
90 | assert_response :success |
|
103 | assert_response :success | |
91 | assert_template 'diff' |
|
104 | assert_template 'diff' | |
92 | # Line 22 removed |
|
105 | # Line 22 removed |
General Comments 0
You need to be logged in to leave comments.
Login now