##// END OF EJS Templates
scm: darcs: remove duplicate test from functional test....
Toshi MARUYAMA -
r5079:bf251a586b98
parent child
Show More
@@ -1,118 +1,108
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006-2008 Jean-Philippe Lang
2 # Copyright (C) 2006-2008 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 require File.expand_path('../../test_helper', __FILE__)
18 require File.expand_path('../../test_helper', __FILE__)
19 require 'repositories_controller'
19 require 'repositories_controller'
20
20
21 # Re-raise errors caught by the controller.
21 # Re-raise errors caught by the controller.
22 class RepositoriesController; def rescue_action(e) raise e end; end
22 class RepositoriesController; def rescue_action(e) raise e end; end
23
23
24 class RepositoriesDarcsControllerTest < ActionController::TestCase
24 class RepositoriesDarcsControllerTest < ActionController::TestCase
25 fixtures :projects, :users, :roles, :members, :member_roles, :repositories, :enabled_modules
25 fixtures :projects, :users, :roles, :members, :member_roles, :repositories, :enabled_modules
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 PRJ_ID = 3
30
30
31 def setup
31 def setup
32 @controller = RepositoriesController.new
32 @controller = RepositoriesController.new
33 @request = ActionController::TestRequest.new
33 @request = ActionController::TestRequest.new
34 @response = ActionController::TestResponse.new
34 @response = ActionController::TestResponse.new
35 User.current = nil
35 User.current = nil
36 @project = Project.find(PRJ_ID)
36 @project = Project.find(PRJ_ID)
37 @repository = Repository::Darcs.create(
37 @repository = Repository::Darcs.create(
38 :project => @project, :url => REPOSITORY_PATH,
38 :project => @project, :url => REPOSITORY_PATH,
39 :log_encoding => 'UTF-8')
39 :log_encoding => 'UTF-8')
40 assert @repository
40 assert @repository
41 end
41 end
42
42
43 if File.directory?(REPOSITORY_PATH)
43 if File.directory?(REPOSITORY_PATH)
44 def test_show
45 @repository.fetch_changesets
46 @repository.reload
47 get :show, :id => PRJ_ID
48 assert_response :success
49 assert_template 'show'
50 assert_not_nil assigns(:entries)
51 assert_not_nil assigns(:changesets)
52 end
53
54 def test_browse_root
44 def test_browse_root
55 @repository.fetch_changesets
45 @repository.fetch_changesets
56 @repository.reload
46 @repository.reload
57 get :show, :id => PRJ_ID
47 get :show, :id => PRJ_ID
58 assert_response :success
48 assert_response :success
59 assert_template 'show'
49 assert_template 'show'
60 assert_not_nil assigns(:entries)
50 assert_not_nil assigns(:entries)
61 assert_equal 3, assigns(:entries).size
51 assert_equal 3, assigns(:entries).size
62 assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'}
52 assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'}
63 assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'}
53 assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'}
64 assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'}
54 assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'}
65 end
55 end
66
56
67 def test_browse_directory
57 def test_browse_directory
68 @repository.fetch_changesets
58 @repository.fetch_changesets
69 @repository.reload
59 @repository.reload
70 get :show, :id => PRJ_ID, :path => ['images']
60 get :show, :id => PRJ_ID, :path => ['images']
71 assert_response :success
61 assert_response :success
72 assert_template 'show'
62 assert_template 'show'
73 assert_not_nil assigns(:entries)
63 assert_not_nil assigns(:entries)
74 assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name)
64 assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name)
75 entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
65 entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
76 assert_not_nil entry
66 assert_not_nil entry
77 assert_equal 'file', entry.kind
67 assert_equal 'file', entry.kind
78 assert_equal 'images/edit.png', entry.path
68 assert_equal 'images/edit.png', entry.path
79 end
69 end
80
70
81 def test_browse_at_given_revision
71 def test_browse_at_given_revision
82 @repository.fetch_changesets
72 @repository.fetch_changesets
83 @repository.reload
73 @repository.reload
84 get :show, :id => PRJ_ID, :path => ['images'], :rev => 1
74 get :show, :id => PRJ_ID, :path => ['images'], :rev => 1
85 assert_response :success
75 assert_response :success
86 assert_template 'show'
76 assert_template 'show'
87 assert_not_nil assigns(:entries)
77 assert_not_nil assigns(:entries)
88 assert_equal ['delete.png'], assigns(:entries).collect(&:name)
78 assert_equal ['delete.png'], assigns(:entries).collect(&:name)
89 end
79 end
90
80
91 def test_changes
81 def test_changes
92 @repository.fetch_changesets
82 @repository.fetch_changesets
93 @repository.reload
83 @repository.reload
94 get :changes, :id => PRJ_ID, :path => ['images', 'edit.png']
84 get :changes, :id => PRJ_ID, :path => ['images', 'edit.png']
95 assert_response :success
85 assert_response :success
96 assert_template 'changes'
86 assert_template 'changes'
97 assert_tag :tag => 'h2', :content => 'edit.png'
87 assert_tag :tag => 'h2', :content => 'edit.png'
98 end
88 end
99
89
100 def test_diff
90 def test_diff
101 @repository.fetch_changesets
91 @repository.fetch_changesets
102 @repository.reload
92 @repository.reload
103 # Full diff of changeset 5
93 # Full diff of changeset 5
104 get :diff, :id => PRJ_ID, :rev => 5
94 get :diff, :id => PRJ_ID, :rev => 5
105 assert_response :success
95 assert_response :success
106 assert_template 'diff'
96 assert_template 'diff'
107 # Line 22 removed
97 # Line 22 removed
108 assert_tag :tag => 'th',
98 assert_tag :tag => 'th',
109 :content => /22/,
99 :content => /22/,
110 :sibling => { :tag => 'td',
100 :sibling => { :tag => 'td',
111 :attributes => { :class => /diff_out/ },
101 :attributes => { :class => /diff_out/ },
112 :content => /def remove/ }
102 :content => /def remove/ }
113 end
103 end
114 else
104 else
115 puts "Darcs test repository NOT FOUND. Skipping functional tests !!!"
105 puts "Darcs test repository NOT FOUND. Skipping functional tests !!!"
116 def test_fake; assert true end
106 def test_fake; assert true end
117 end
107 end
118 end
108 end
General Comments 0
You need to be logged in to leave comments. Login now