@@ -0,0 +1,11 | |||
|
1 | class ChangeChangesPathLengthLimit < ActiveRecord::Migration | |
|
2 | def self.up | |
|
3 | change_column :changes, :path, :text, :default => "", :null => false | |
|
4 | change_column :changes, :from_path, :text | |
|
5 | end | |
|
6 | ||
|
7 | def self.down | |
|
8 | change_column :changes, :path, :string, :default => "", :null => false | |
|
9 | change_column :changes, :from_path, :string | |
|
10 | end | |
|
11 | end |
|
1 | NO CONTENT: modified file, binary diff hidden |
@@ -1,161 +1,162 | |||
|
1 | 1 | # redMine - project management software |
|
2 | 2 | # Copyright (C) 2006-2008 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require File.dirname(__FILE__) + '/../test_helper' |
|
19 | 19 | require 'repositories_controller' |
|
20 | 20 | |
|
21 | 21 | # Re-raise errors caught by the controller. |
|
22 | 22 | class RepositoriesController; def rescue_action(e) raise e end; end |
|
23 | 23 | |
|
24 | 24 | class RepositoriesGitControllerTest < ActionController::TestCase |
|
25 | 25 | fixtures :projects, :users, :roles, :members, :member_roles, :repositories, :enabled_modules |
|
26 | 26 | |
|
27 | 27 | # No '..' in the repository path |
|
28 | 28 | REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/git_repository' |
|
29 | 29 | REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin? |
|
30 | 30 | |
|
31 | 31 | def setup |
|
32 | 32 | @controller = RepositoriesController.new |
|
33 | 33 | @request = ActionController::TestRequest.new |
|
34 | 34 | @response = ActionController::TestResponse.new |
|
35 | 35 | User.current = nil |
|
36 | 36 | Repository::Git.create(:project => Project.find(3), :url => REPOSITORY_PATH) |
|
37 | 37 | end |
|
38 | 38 | |
|
39 | 39 | if File.directory?(REPOSITORY_PATH) |
|
40 | 40 | def test_show |
|
41 | 41 | get :show, :id => 3 |
|
42 | 42 | assert_response :success |
|
43 | 43 | assert_template 'show' |
|
44 | 44 | assert_not_nil assigns(:entries) |
|
45 | 45 | assert_not_nil assigns(:changesets) |
|
46 | 46 | end |
|
47 | 47 | |
|
48 | 48 | def test_browse_root |
|
49 | 49 | get :show, :id => 3 |
|
50 | 50 | assert_response :success |
|
51 | 51 | assert_template 'show' |
|
52 | 52 | assert_not_nil assigns(:entries) |
|
53 |
assert_equal |
|
|
53 | assert_equal 7, assigns(:entries).size | |
|
54 | 54 | assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'} |
|
55 | assert assigns(:entries).detect {|e| e.name == 'this_is_a_really_long_and_verbose_directory_name' && e.kind == 'dir'} | |
|
55 | 56 | assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'} |
|
56 | 57 | assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'} |
|
57 | 58 | assert assigns(:entries).detect {|e| e.name == 'copied_README' && e.kind == 'file'} |
|
58 | 59 | assert assigns(:entries).detect {|e| e.name == 'new_file.txt' && e.kind == 'file'} |
|
59 | 60 | assert assigns(:entries).detect {|e| e.name == 'renamed_test.txt' && e.kind == 'file'} |
|
60 | 61 | end |
|
61 | 62 | |
|
62 | 63 | def test_browse_branch |
|
63 | 64 | get :show, :id => 3, :rev => 'test_branch' |
|
64 | 65 | assert_response :success |
|
65 | 66 | assert_template 'show' |
|
66 | 67 | assert_not_nil assigns(:entries) |
|
67 | 68 | assert_equal 4, assigns(:entries).size |
|
68 | 69 | assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'} |
|
69 | 70 | assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'} |
|
70 | 71 | assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'} |
|
71 | 72 | assert assigns(:entries).detect {|e| e.name == 'test.txt' && e.kind == 'file'} |
|
72 | 73 | end |
|
73 | 74 | |
|
74 | 75 | def test_browse_directory |
|
75 | 76 | get :show, :id => 3, :path => ['images'] |
|
76 | 77 | assert_response :success |
|
77 | 78 | assert_template 'show' |
|
78 | 79 | assert_not_nil assigns(:entries) |
|
79 | 80 | assert_equal ['edit.png'], assigns(:entries).collect(&:name) |
|
80 | 81 | entry = assigns(:entries).detect {|e| e.name == 'edit.png'} |
|
81 | 82 | assert_not_nil entry |
|
82 | 83 | assert_equal 'file', entry.kind |
|
83 | 84 | assert_equal 'images/edit.png', entry.path |
|
84 | 85 | end |
|
85 | 86 | |
|
86 | 87 | def test_browse_at_given_revision |
|
87 | 88 | get :show, :id => 3, :path => ['images'], :rev => '7234cb2750b63f47bff735edc50a1c0a433c2518' |
|
88 | 89 | assert_response :success |
|
89 | 90 | assert_template 'show' |
|
90 | 91 | assert_not_nil assigns(:entries) |
|
91 | 92 | assert_equal ['delete.png'], assigns(:entries).collect(&:name) |
|
92 | 93 | end |
|
93 | 94 | |
|
94 | 95 | def test_changes |
|
95 | 96 | get :changes, :id => 3, :path => ['images', 'edit.png'] |
|
96 | 97 | assert_response :success |
|
97 | 98 | assert_template 'changes' |
|
98 | 99 | assert_tag :tag => 'h2', :content => 'edit.png' |
|
99 | 100 | end |
|
100 | 101 | |
|
101 | 102 | def test_entry_show |
|
102 | 103 | get :entry, :id => 3, :path => ['sources', 'watchers_controller.rb'] |
|
103 | 104 | assert_response :success |
|
104 | 105 | assert_template 'entry' |
|
105 | 106 | # Line 19 |
|
106 | 107 | assert_tag :tag => 'th', |
|
107 | 108 | :content => /11/, |
|
108 | 109 | :attributes => { :class => /line-num/ }, |
|
109 | 110 | :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ } |
|
110 | 111 | end |
|
111 | 112 | |
|
112 | 113 | def test_entry_download |
|
113 | 114 | get :entry, :id => 3, :path => ['sources', 'watchers_controller.rb'], :format => 'raw' |
|
114 | 115 | assert_response :success |
|
115 | 116 | # File content |
|
116 | 117 | assert @response.body.include?('WITHOUT ANY WARRANTY') |
|
117 | 118 | end |
|
118 | 119 | |
|
119 | 120 | def test_directory_entry |
|
120 | 121 | get :entry, :id => 3, :path => ['sources'] |
|
121 | 122 | assert_response :success |
|
122 | 123 | assert_template 'show' |
|
123 | 124 | assert_not_nil assigns(:entry) |
|
124 | 125 | assert_equal 'sources', assigns(:entry).name |
|
125 | 126 | end |
|
126 | 127 | |
|
127 | 128 | def test_diff |
|
128 | 129 | # Full diff of changeset 2f9c0091 |
|
129 | 130 | get :diff, :id => 3, :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' |
|
130 | 131 | assert_response :success |
|
131 | 132 | assert_template 'diff' |
|
132 | 133 | # Line 22 removed |
|
133 | 134 | assert_tag :tag => 'th', |
|
134 | 135 | :content => /22/, |
|
135 | 136 | :sibling => { :tag => 'td', |
|
136 | 137 | :attributes => { :class => /diff_out/ }, |
|
137 | 138 | :content => /def remove/ } |
|
138 | 139 | end |
|
139 | 140 | |
|
140 | 141 | def test_annotate |
|
141 | 142 | get :annotate, :id => 3, :path => ['sources', 'watchers_controller.rb'] |
|
142 | 143 | assert_response :success |
|
143 | 144 | assert_template 'annotate' |
|
144 | 145 | # Line 23, changeset 2f9c0091 |
|
145 | 146 | assert_tag :tag => 'th', :content => /24/, |
|
146 | 147 | :sibling => { :tag => 'td', :child => { :tag => 'a', :content => /2f9c0091/ } }, |
|
147 | 148 | :sibling => { :tag => 'td', :content => /jsmith/ }, |
|
148 | 149 | :sibling => { :tag => 'td', :content => /watcher =/ } |
|
149 | 150 | end |
|
150 | 151 | |
|
151 | 152 | def test_annotate_binary_file |
|
152 | 153 | get :annotate, :id => 3, :path => ['images', 'edit.png'] |
|
153 | 154 | assert_response 500 |
|
154 | 155 | assert_tag :tag => 'div', :attributes => { :class => /error/ }, |
|
155 | 156 | :content => /can not be annotated/ |
|
156 | 157 | end |
|
157 | 158 | else |
|
158 | 159 | puts "Git test repository NOT FOUND. Skipping functional tests !!!" |
|
159 | 160 | def test_fake; assert true end |
|
160 | 161 | end |
|
161 | 162 | end |
@@ -1,37 +1,37 | |||
|
1 | 1 | require File.dirname(__FILE__) + '/../../../../../test_helper' |
|
2 | 2 | |
|
3 | 3 | class GitAdapterTest < ActiveSupport::TestCase |
|
4 | 4 | REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/git_repository' |
|
5 | 5 | |
|
6 | 6 | if File.directory?(REPOSITORY_PATH) |
|
7 | 7 | def setup |
|
8 | 8 | @adapter = Redmine::Scm::Adapters::GitAdapter.new(REPOSITORY_PATH) |
|
9 | 9 | end |
|
10 | 10 | |
|
11 | 11 | def test_branches |
|
12 | 12 | assert_equal @adapter.branches, ['master', 'test_branch'] |
|
13 | 13 | end |
|
14 | 14 | |
|
15 | 15 | def test_getting_all_revisions |
|
16 |
assert_equal 1 |
|
|
16 | assert_equal 13, @adapter.revisions('',nil,nil,:all => true).length | |
|
17 | 17 | end |
|
18 | 18 | |
|
19 | 19 | def test_annotate |
|
20 | 20 | annotate = @adapter.annotate('sources/watchers_controller.rb') |
|
21 | 21 | assert_kind_of Redmine::Scm::Adapters::Annotate, annotate |
|
22 | 22 | assert_equal 41, annotate.lines.size |
|
23 | 23 | assert_equal "# This program is free software; you can redistribute it and/or", annotate.lines[4].strip |
|
24 | 24 | assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", annotate.revisions[4].identifier |
|
25 | 25 | assert_equal "jsmith", annotate.revisions[4].author |
|
26 | 26 | end |
|
27 | 27 | |
|
28 | 28 | def test_annotate_moved_file |
|
29 | 29 | annotate = @adapter.annotate('renamed_test.txt') |
|
30 | 30 | assert_kind_of Redmine::Scm::Adapters::Annotate, annotate |
|
31 | 31 | assert_equal 2, annotate.lines.size |
|
32 | 32 | end |
|
33 | 33 | else |
|
34 | 34 | puts "Git test repository NOT FOUND. Skipping unit tests !!!" |
|
35 | 35 | def test_fake; assert true end |
|
36 | 36 | end |
|
37 | 37 | end |
@@ -1,69 +1,69 | |||
|
1 | 1 | # redMine - project management software |
|
2 | 2 | # Copyright (C) 2006-2007 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require File.dirname(__FILE__) + '/../test_helper' |
|
19 | 19 | |
|
20 | 20 | class RepositoryGitTest < ActiveSupport::TestCase |
|
21 | 21 | fixtures :projects |
|
22 | 22 | |
|
23 | 23 | # No '..' in the repository path |
|
24 | 24 | REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/git_repository' |
|
25 | 25 | REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin? |
|
26 | 26 | |
|
27 | 27 | def setup |
|
28 | 28 | @project = Project.find(1) |
|
29 | 29 | assert @repository = Repository::Git.create(:project => @project, :url => REPOSITORY_PATH) |
|
30 | 30 | end |
|
31 | 31 | |
|
32 | 32 | if File.directory?(REPOSITORY_PATH) |
|
33 | 33 | def test_fetch_changesets_from_scratch |
|
34 | 34 | @repository.fetch_changesets |
|
35 | 35 | @repository.reload |
|
36 | 36 | |
|
37 |
assert_equal 1 |
|
|
38 |
assert_equal 2 |
|
|
37 | assert_equal 13, @repository.changesets.count | |
|
38 | assert_equal 22, @repository.changes.count | |
|
39 | 39 | |
|
40 | 40 | commit = @repository.changesets.find(:first, :order => 'committed_on ASC') |
|
41 | 41 | assert_equal "Initial import.\nThe repository contains 3 files.", commit.comments |
|
42 | 42 | assert_equal "jsmith <jsmith@foo.bar>", commit.committer |
|
43 | 43 | assert_equal User.find_by_login('jsmith'), commit.user |
|
44 | 44 | # TODO: add a commit with commit time <> author time to the test repository |
|
45 | 45 | assert_equal "2007-12-14 09:22:52".to_time, commit.committed_on |
|
46 | 46 | assert_equal "2007-12-14".to_date, commit.commit_date |
|
47 | 47 | assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", commit.revision |
|
48 | 48 | assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", commit.scmid |
|
49 | 49 | assert_equal 3, commit.changes.count |
|
50 | 50 | change = commit.changes.sort_by(&:path).first |
|
51 | 51 | assert_equal "README", change.path |
|
52 | 52 | assert_equal "A", change.action |
|
53 | 53 | end |
|
54 | 54 | |
|
55 | 55 | def test_fetch_changesets_incremental |
|
56 | 56 | @repository.fetch_changesets |
|
57 | 57 | # Remove the 3 latest changesets |
|
58 | 58 | @repository.changesets.find(:all, :order => 'committed_on DESC', :limit => 3).each(&:destroy) |
|
59 | 59 | @repository.reload |
|
60 |
assert_equal |
|
|
60 | assert_equal 10, @repository.changesets.count | |
|
61 | 61 | |
|
62 | 62 | @repository.fetch_changesets |
|
63 |
assert_equal 1 |
|
|
63 | assert_equal 13, @repository.changesets.count | |
|
64 | 64 | end |
|
65 | 65 | else |
|
66 | 66 | puts "Git test repository NOT FOUND. Skipping unit tests !!!" |
|
67 | 67 | def test_fake; assert true end |
|
68 | 68 | end |
|
69 | 69 | end |
General Comments 0
You need to be logged in to leave comments.
Login now