1 | NO CONTENT: new file 100644, binary diff hidden |
|
NO CONTENT: new file 100644, binary diff hidden |
@@ -0,0 +1,117 | |||||
|
1 | # redMine - project management software | |||
|
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang | |||
|
3 | # | |||
|
4 | # This program is free software; you can redistribute it and/or | |||
|
5 | # modify it under the terms of the GNU General Public License | |||
|
6 | # as published by the Free Software Foundation; either version 2 | |||
|
7 | # of the License, or (at your option) any later version. | |||
|
8 | # | |||
|
9 | # This program is distributed in the hope that it will be useful, | |||
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
|
12 | # GNU General Public License for more details. | |||
|
13 | # | |||
|
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 | |||
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
|
17 | ||||
|
18 | require File.dirname(__FILE__) + '/../test_helper' | |||
|
19 | require 'repositories_controller' | |||
|
20 | ||||
|
21 | # Re-raise errors caught by the controller. | |||
|
22 | class RepositoriesController; def rescue_action(e) raise e end; end | |||
|
23 | ||||
|
24 | class RepositoriesMercurialControllerTest < Test::Unit::TestCase | |||
|
25 | fixtures :projects, :users, :roles, :members, :repositories, :enabled_modules | |||
|
26 | ||||
|
27 | # No '..' in the repository path | |||
|
28 | REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/mercurial_repository' | |||
|
29 | ||||
|
30 | def setup | |||
|
31 | @controller = RepositoriesController.new | |||
|
32 | @request = ActionController::TestRequest.new | |||
|
33 | @response = ActionController::TestResponse.new | |||
|
34 | User.current = nil | |||
|
35 | Repository::Mercurial.create(:project => Project.find(3), :url => REPOSITORY_PATH) | |||
|
36 | end | |||
|
37 | ||||
|
38 | def test_show | |||
|
39 | get :show, :id => 3 | |||
|
40 | assert_response :success | |||
|
41 | assert_template 'show' | |||
|
42 | assert_not_nil assigns(:entries) | |||
|
43 | assert_not_nil assigns(:changesets) | |||
|
44 | end | |||
|
45 | ||||
|
46 | def test_browse_root | |||
|
47 | get :browse, :id => 3 | |||
|
48 | assert_response :success | |||
|
49 | assert_template 'browse' | |||
|
50 | assert_not_nil assigns(:entries) | |||
|
51 | assert_equal 3, assigns(:entries).size | |||
|
52 | assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'} | |||
|
53 | assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'} | |||
|
54 | assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'} | |||
|
55 | end | |||
|
56 | ||||
|
57 | def test_browse_directory | |||
|
58 | get :browse, :id => 3, :path => ['images'] | |||
|
59 | assert_response :success | |||
|
60 | assert_template 'browse' | |||
|
61 | assert_not_nil assigns(:entries) | |||
|
62 | assert_equal 2, assigns(:entries).size | |||
|
63 | entry = assigns(:entries).detect {|e| e.name == 'edit.png'} | |||
|
64 | assert_not_nil entry | |||
|
65 | assert_equal 'file', entry.kind | |||
|
66 | assert_equal 'images/edit.png', entry.path | |||
|
67 | end | |||
|
68 | ||||
|
69 | def test_changes | |||
|
70 | get :changes, :id => 3, :path => ['images', 'edit.png'] | |||
|
71 | assert_response :success | |||
|
72 | assert_template 'changes' | |||
|
73 | assert_tag :tag => 'h2', :content => 'edit.png' | |||
|
74 | end | |||
|
75 | ||||
|
76 | def test_entry_show | |||
|
77 | get :entry, :id => 3, :path => ['sources', 'watchers_controller.rb'] | |||
|
78 | assert_response :success | |||
|
79 | assert_template 'entry' | |||
|
80 | # Line 19 | |||
|
81 | assert_tag :tag => 'th', | |||
|
82 | :content => /10/, | |||
|
83 | :attributes => { :class => /line-num/ }, | |||
|
84 | :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ } | |||
|
85 | end | |||
|
86 | ||||
|
87 | def test_entry_download | |||
|
88 | get :entry, :id => 3, :path => ['sources', 'watchers_controller.rb'], :format => 'raw' | |||
|
89 | assert_response :success | |||
|
90 | # File content | |||
|
91 | assert @response.body.include?('WITHOUT ANY WARRANTY') | |||
|
92 | end | |||
|
93 | ||||
|
94 | def test_diff | |||
|
95 | # Full diff of changeset 4 | |||
|
96 | get :diff, :id => 3, :rev => 4 | |||
|
97 | assert_response :success | |||
|
98 | assert_template 'diff' | |||
|
99 | # Line 22 removed | |||
|
100 | assert_tag :tag => 'th', | |||
|
101 | :content => /22/, | |||
|
102 | :sibling => { :tag => 'td', | |||
|
103 | :attributes => { :class => /diff_out/ }, | |||
|
104 | :content => /def remove/ } | |||
|
105 | end | |||
|
106 | ||||
|
107 | def test_annotate | |||
|
108 | get :annotate, :id => 3, :path => ['sources', 'watchers_controller.rb'] | |||
|
109 | assert_response :success | |||
|
110 | assert_template 'annotate' | |||
|
111 | # Line 23, revision 4 | |||
|
112 | assert_tag :tag => 'th', :content => /23/, | |||
|
113 | :sibling => { :tag => 'td', :child => { :tag => 'a', :content => /4/ } }, | |||
|
114 | :sibling => { :tag => 'td', :content => /jsmith/ }, | |||
|
115 | :sibling => { :tag => 'td', :content => /watcher =/ } | |||
|
116 | end | |||
|
117 | end |
@@ -0,0 +1,55 | |||||
|
1 | # redMine - project management software | |||
|
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang | |||
|
3 | # | |||
|
4 | # This program is free software; you can redistribute it and/or | |||
|
5 | # modify it under the terms of the GNU General Public License | |||
|
6 | # as published by the Free Software Foundation; either version 2 | |||
|
7 | # of the License, or (at your option) any later version. | |||
|
8 | # | |||
|
9 | # This program is distributed in the hope that it will be useful, | |||
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
|
12 | # GNU General Public License for more details. | |||
|
13 | # | |||
|
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 | |||
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
|
17 | ||||
|
18 | require File.dirname(__FILE__) + '/../test_helper' | |||
|
19 | ||||
|
20 | class RepositoryMercurialTest < Test::Unit::TestCase | |||
|
21 | fixtures :projects | |||
|
22 | ||||
|
23 | # No '..' in the repository path | |||
|
24 | REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/mercurial_repository' | |||
|
25 | ||||
|
26 | def setup | |||
|
27 | @project = Project.find(1) | |||
|
28 | assert @repository = Repository::Mercurial.create(:project => @project, :url => REPOSITORY_PATH) | |||
|
29 | end | |||
|
30 | ||||
|
31 | if File.directory?(REPOSITORY_PATH) | |||
|
32 | def test_fetch_changesets_from_scratch | |||
|
33 | @repository.fetch_changesets | |||
|
34 | @repository.reload | |||
|
35 | ||||
|
36 | assert_equal 6, @repository.changesets.count | |||
|
37 | assert_equal 11, @repository.changes.count | |||
|
38 | assert_equal "Initial import.\nThe repository contains 3 files.", @repository.changesets.find_by_revision(0).comments | |||
|
39 | end | |||
|
40 | ||||
|
41 | def test_fetch_changesets_incremental | |||
|
42 | @repository.fetch_changesets | |||
|
43 | # Remove changesets with revision > 2 | |||
|
44 | @repository.changesets.find(:all, :conditions => 'revision > 2').each(&:destroy) | |||
|
45 | @repository.reload | |||
|
46 | assert_equal 3, @repository.changesets.count | |||
|
47 | ||||
|
48 | @repository.fetch_changesets | |||
|
49 | assert_equal 6, @repository.changesets.count | |||
|
50 | end | |||
|
51 | else | |||
|
52 | puts "Mercurial test repository NOT FOUND. Skipping unit tests !!!" | |||
|
53 | def test_fake; assert true end | |||
|
54 | end | |||
|
55 | end |
@@ -14,4 +14,8 gunzip < test/fixtures/repositories/cvs_repository.tar.gz | tar -xv -C tmp/test | |||||
14 |
|
14 | |||
15 | Bazaar |
|
15 | Bazaar | |
16 | ------ |
|
16 | ------ | |
17 | gunzip < test/fixtures/repositories/bazaar_repository.tar.gz | tar -xv -C tmp/test No newline at end of file |
|
17 | gunzip < test/fixtures/repositories/bazaar_repository.tar.gz | tar -xv -C tmp/test | |
|
18 | ||||
|
19 | Mercurial | |||
|
20 | --------- | |||
|
21 | gunzip < test/fixtures/repositories/mercurial_repository.tar.gz | tar -xv -C tmp/test |
General Comments 0
You need to be logged in to leave comments.
Login now