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