Mercurial > hg > soundsoftware-site
comparison test/functional/.svn/text-base/repositories_cvs_controller_test.rb.svn-base @ 0:513646585e45
* Import Redmine trunk SVN rev 3859
author | Chris Cannam |
---|---|
date | Fri, 23 Jul 2010 15:52:44 +0100 |
parents | |
children | 94944d00e43c |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:513646585e45 |
---|---|
1 # redMine - project management software | |
2 # Copyright (C) 2006-2008 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 RepositoriesCvsControllerTest < ActionController::TestCase | |
25 | |
26 # No '..' in the repository path | |
27 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/cvs_repository' | |
28 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin? | |
29 # CVS module | |
30 MODULE_NAME = 'test' | |
31 | |
32 def setup | |
33 @controller = RepositoriesController.new | |
34 @request = ActionController::TestRequest.new | |
35 @response = ActionController::TestResponse.new | |
36 Setting.default_language = 'en' | |
37 User.current = nil | |
38 | |
39 @project = Project.find(1) | |
40 @project.repository = Repository::Cvs.create(:root_url => REPOSITORY_PATH, | |
41 :url => MODULE_NAME) | |
42 end | |
43 | |
44 if File.directory?(REPOSITORY_PATH) | |
45 def test_show | |
46 get :show, :id => 1 | |
47 assert_response :success | |
48 assert_template 'show' | |
49 assert_not_nil assigns(:entries) | |
50 assert_not_nil assigns(:changesets) | |
51 end | |
52 | |
53 def test_browse_root | |
54 get :show, :id => 1 | |
55 assert_response :success | |
56 assert_template 'show' | |
57 assert_not_nil assigns(:entries) | |
58 assert_equal 3, assigns(:entries).size | |
59 | |
60 entry = assigns(:entries).detect {|e| e.name == 'images'} | |
61 assert_equal 'dir', entry.kind | |
62 | |
63 entry = assigns(:entries).detect {|e| e.name == 'README'} | |
64 assert_equal 'file', entry.kind | |
65 end | |
66 | |
67 def test_browse_directory | |
68 get :show, :id => 1, :path => ['images'] | |
69 assert_response :success | |
70 assert_template 'show' | |
71 assert_not_nil assigns(:entries) | |
72 assert_equal ['add.png', 'delete.png', 'edit.png'], assigns(:entries).collect(&:name) | |
73 entry = assigns(:entries).detect {|e| e.name == 'edit.png'} | |
74 assert_not_nil entry | |
75 assert_equal 'file', entry.kind | |
76 assert_equal 'images/edit.png', entry.path | |
77 end | |
78 | |
79 def test_browse_at_given_revision | |
80 Project.find(1).repository.fetch_changesets | |
81 get :show, :id => 1, :path => ['images'], :rev => 1 | |
82 assert_response :success | |
83 assert_template 'show' | |
84 assert_not_nil assigns(:entries) | |
85 assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name) | |
86 end | |
87 | |
88 def test_entry | |
89 get :entry, :id => 1, :path => ['sources', 'watchers_controller.rb'] | |
90 assert_response :success | |
91 assert_template 'entry' | |
92 assert_no_tag :tag => 'td', :attributes => { :class => /line-code/}, | |
93 :content => /before_filter/ | |
94 end | |
95 | |
96 def test_entry_at_given_revision | |
97 # changesets must be loaded | |
98 Project.find(1).repository.fetch_changesets | |
99 get :entry, :id => 1, :path => ['sources', 'watchers_controller.rb'], :rev => 2 | |
100 assert_response :success | |
101 assert_template 'entry' | |
102 # this line was removed in r3 | |
103 assert_tag :tag => 'td', :attributes => { :class => /line-code/}, | |
104 :content => /before_filter/ | |
105 end | |
106 | |
107 def test_entry_not_found | |
108 get :entry, :id => 1, :path => ['sources', 'zzz.c'] | |
109 assert_tag :tag => 'div', :attributes => { :class => /error/ }, | |
110 :content => /The entry or revision was not found in the repository/ | |
111 end | |
112 | |
113 def test_entry_download | |
114 get :entry, :id => 1, :path => ['sources', 'watchers_controller.rb'], :format => 'raw' | |
115 assert_response :success | |
116 end | |
117 | |
118 def test_directory_entry | |
119 get :entry, :id => 1, :path => ['sources'] | |
120 assert_response :success | |
121 assert_template 'show' | |
122 assert_not_nil assigns(:entry) | |
123 assert_equal 'sources', assigns(:entry).name | |
124 end | |
125 | |
126 def test_diff | |
127 Project.find(1).repository.fetch_changesets | |
128 get :diff, :id => 1, :rev => 3, :type => 'inline' | |
129 assert_response :success | |
130 assert_template 'diff' | |
131 assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_out' }, | |
132 :content => /watched.remove_watcher/ | |
133 assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_in' }, | |
134 :content => /watched.remove_all_watcher/ | |
135 end | |
136 | |
137 def test_annotate | |
138 Project.find(1).repository.fetch_changesets | |
139 get :annotate, :id => 1, :path => ['sources', 'watchers_controller.rb'] | |
140 assert_response :success | |
141 assert_template 'annotate' | |
142 # 1.1 line | |
143 assert_tag :tag => 'th', :attributes => { :class => 'line-num' }, | |
144 :content => '18', | |
145 :sibling => { :tag => 'td', :attributes => { :class => 'revision' }, | |
146 :content => /1.1/, | |
147 :sibling => { :tag => 'td', :attributes => { :class => 'author' }, | |
148 :content => /LANG/ | |
149 } | |
150 } | |
151 # 1.2 line | |
152 assert_tag :tag => 'th', :attributes => { :class => 'line-num' }, | |
153 :content => '32', | |
154 :sibling => { :tag => 'td', :attributes => { :class => 'revision' }, | |
155 :content => /1.2/, | |
156 :sibling => { :tag => 'td', :attributes => { :class => 'author' }, | |
157 :content => /LANG/ | |
158 } | |
159 } | |
160 end | |
161 else | |
162 puts "CVS test repository NOT FOUND. Skipping functional tests !!!" | |
163 def test_fake; assert true end | |
164 end | |
165 end |