Mercurial > hg > soundsoftware-site
comparison test/functional/.svn/text-base/repositories_cvs_controller_test.rb.svn-base @ 246:eeebe205a056 cannam
* Merge from default branch, bringing us up to SVN trunk rev 4993
author | Chris Cannam |
---|---|
date | Thu, 03 Mar 2011 12:02:03 +0000 |
parents | 051f544170fe |
children | cbce1fd3b1b7 |
comparison
equal
deleted
inserted
replaced
138:fca2657f4aa5 | 246:eeebe205a056 |
---|---|
27 # No '..' in the repository path | 27 # No '..' in the repository path |
28 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/cvs_repository' | 28 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/cvs_repository' |
29 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin? | 29 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin? |
30 # CVS module | 30 # CVS module |
31 MODULE_NAME = 'test' | 31 MODULE_NAME = 'test' |
32 | 32 PRJ_ID = 3 |
33 | |
33 def setup | 34 def setup |
34 @controller = RepositoriesController.new | 35 @controller = RepositoriesController.new |
35 @request = ActionController::TestRequest.new | 36 @request = ActionController::TestRequest.new |
36 @response = ActionController::TestResponse.new | 37 @response = ActionController::TestResponse.new |
37 Setting.default_language = 'en' | 38 Setting.default_language = 'en' |
38 User.current = nil | 39 User.current = nil |
39 | 40 |
40 @project = Project.find(1) | 41 @project = Project.find(PRJ_ID) |
41 @project.repository = Repository::Cvs.create(:root_url => REPOSITORY_PATH, | 42 @repository = Repository::Cvs.create(:project => Project.find(PRJ_ID), |
42 :url => MODULE_NAME) | 43 :root_url => REPOSITORY_PATH, |
44 :url => MODULE_NAME, | |
45 :log_encoding => 'UTF-8') | |
46 assert @repository | |
43 end | 47 end |
44 | 48 |
45 if File.directory?(REPOSITORY_PATH) | 49 if File.directory?(REPOSITORY_PATH) |
46 def test_show | 50 def test_show |
47 get :show, :id => 1 | 51 @repository.fetch_changesets |
52 @repository.reload | |
53 get :show, :id => PRJ_ID | |
48 assert_response :success | 54 assert_response :success |
49 assert_template 'show' | 55 assert_template 'show' |
50 assert_not_nil assigns(:entries) | 56 assert_not_nil assigns(:entries) |
51 assert_not_nil assigns(:changesets) | 57 assert_not_nil assigns(:changesets) |
52 end | 58 end |
53 | 59 |
54 def test_browse_root | 60 def test_browse_root |
55 get :show, :id => 1 | 61 @repository.fetch_changesets |
62 @repository.reload | |
63 get :show, :id => PRJ_ID | |
56 assert_response :success | 64 assert_response :success |
57 assert_template 'show' | 65 assert_template 'show' |
58 assert_not_nil assigns(:entries) | 66 assert_not_nil assigns(:entries) |
59 assert_equal 3, assigns(:entries).size | 67 assert_equal 3, assigns(:entries).size |
60 | 68 |
64 entry = assigns(:entries).detect {|e| e.name == 'README'} | 72 entry = assigns(:entries).detect {|e| e.name == 'README'} |
65 assert_equal 'file', entry.kind | 73 assert_equal 'file', entry.kind |
66 end | 74 end |
67 | 75 |
68 def test_browse_directory | 76 def test_browse_directory |
69 get :show, :id => 1, :path => ['images'] | 77 @repository.fetch_changesets |
78 @repository.reload | |
79 get :show, :id => PRJ_ID, :path => ['images'] | |
70 assert_response :success | 80 assert_response :success |
71 assert_template 'show' | 81 assert_template 'show' |
72 assert_not_nil assigns(:entries) | 82 assert_not_nil assigns(:entries) |
73 assert_equal ['add.png', 'delete.png', 'edit.png'], assigns(:entries).collect(&:name) | 83 assert_equal ['add.png', 'delete.png', 'edit.png'], assigns(:entries).collect(&:name) |
74 entry = assigns(:entries).detect {|e| e.name == 'edit.png'} | 84 entry = assigns(:entries).detect {|e| e.name == 'edit.png'} |
76 assert_equal 'file', entry.kind | 86 assert_equal 'file', entry.kind |
77 assert_equal 'images/edit.png', entry.path | 87 assert_equal 'images/edit.png', entry.path |
78 end | 88 end |
79 | 89 |
80 def test_browse_at_given_revision | 90 def test_browse_at_given_revision |
81 Project.find(1).repository.fetch_changesets | 91 @repository.fetch_changesets |
82 get :show, :id => 1, :path => ['images'], :rev => 1 | 92 @repository.reload |
93 get :show, :id => PRJ_ID, :path => ['images'], :rev => 1 | |
83 assert_response :success | 94 assert_response :success |
84 assert_template 'show' | 95 assert_template 'show' |
85 assert_not_nil assigns(:entries) | 96 assert_not_nil assigns(:entries) |
86 assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name) | 97 assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name) |
87 end | 98 end |
88 | 99 |
89 def test_entry | 100 def test_entry |
90 get :entry, :id => 1, :path => ['sources', 'watchers_controller.rb'] | 101 @repository.fetch_changesets |
102 @repository.reload | |
103 get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'] | |
91 assert_response :success | 104 assert_response :success |
92 assert_template 'entry' | 105 assert_template 'entry' |
93 assert_no_tag :tag => 'td', :attributes => { :class => /line-code/}, | 106 assert_no_tag :tag => 'td', :attributes => { :class => /line-code/}, |
94 :content => /before_filter/ | 107 :content => /before_filter/ |
95 end | 108 end |
96 | 109 |
97 def test_entry_at_given_revision | 110 def test_entry_at_given_revision |
98 # changesets must be loaded | 111 # changesets must be loaded |
99 Project.find(1).repository.fetch_changesets | 112 @repository.fetch_changesets |
100 get :entry, :id => 1, :path => ['sources', 'watchers_controller.rb'], :rev => 2 | 113 @repository.reload |
114 get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'], :rev => 2 | |
101 assert_response :success | 115 assert_response :success |
102 assert_template 'entry' | 116 assert_template 'entry' |
103 # this line was removed in r3 | 117 # this line was removed in r3 |
104 assert_tag :tag => 'td', :attributes => { :class => /line-code/}, | 118 assert_tag :tag => 'td', :attributes => { :class => /line-code/}, |
105 :content => /before_filter/ | 119 :content => /before_filter/ |
106 end | 120 end |
107 | 121 |
108 def test_entry_not_found | 122 def test_entry_not_found |
109 get :entry, :id => 1, :path => ['sources', 'zzz.c'] | 123 @repository.fetch_changesets |
124 @repository.reload | |
125 get :entry, :id => PRJ_ID, :path => ['sources', 'zzz.c'] | |
110 assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, | 126 assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, |
111 :content => /The entry or revision was not found in the repository/ | 127 :content => /The entry or revision was not found in the repository/ |
112 end | 128 end |
113 | 129 |
114 def test_entry_download | 130 def test_entry_download |
115 get :entry, :id => 1, :path => ['sources', 'watchers_controller.rb'], :format => 'raw' | 131 @repository.fetch_changesets |
132 @repository.reload | |
133 get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'], :format => 'raw' | |
116 assert_response :success | 134 assert_response :success |
117 end | 135 end |
118 | 136 |
119 def test_directory_entry | 137 def test_directory_entry |
120 get :entry, :id => 1, :path => ['sources'] | 138 @repository.fetch_changesets |
139 @repository.reload | |
140 get :entry, :id => PRJ_ID, :path => ['sources'] | |
121 assert_response :success | 141 assert_response :success |
122 assert_template 'show' | 142 assert_template 'show' |
123 assert_not_nil assigns(:entry) | 143 assert_not_nil assigns(:entry) |
124 assert_equal 'sources', assigns(:entry).name | 144 assert_equal 'sources', assigns(:entry).name |
125 end | 145 end |
126 | 146 |
127 def test_diff | 147 def test_diff |
128 Project.find(1).repository.fetch_changesets | 148 @repository.fetch_changesets |
129 get :diff, :id => 1, :rev => 3, :type => 'inline' | 149 @repository.reload |
150 get :diff, :id => PRJ_ID, :rev => 3, :type => 'inline' | |
130 assert_response :success | 151 assert_response :success |
131 assert_template 'diff' | 152 assert_template 'diff' |
132 assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_out' }, | 153 assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_out' }, |
133 :content => /watched.remove_watcher/ | 154 :content => /watched.remove_watcher/ |
134 assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_in' }, | 155 assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_in' }, |
135 :content => /watched.remove_all_watcher/ | 156 :content => /watched.remove_all_watcher/ |
136 end | 157 end |
158 | |
159 def test_diff_new_files | |
160 @repository.fetch_changesets | |
161 @repository.reload | |
162 get :diff, :id => PRJ_ID, :rev => 1, :type => 'inline' | |
163 assert_response :success | |
164 assert_template 'diff' | |
165 assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_in' }, | |
166 :content => /watched.remove_watcher/ | |
167 assert_tag :tag => 'th', :attributes => { :class => 'filename' }, | |
168 :content => /test\/README/ | |
169 assert_tag :tag => 'th', :attributes => { :class => 'filename' }, | |
170 :content => /test\/images\/delete.png / | |
171 assert_tag :tag => 'th', :attributes => { :class => 'filename' }, | |
172 :content => /test\/images\/edit.png/ | |
173 assert_tag :tag => 'th', :attributes => { :class => 'filename' }, | |
174 :content => /test\/sources\/watchers_controller.rb/ | |
175 end | |
137 | 176 |
138 def test_annotate | 177 def test_annotate |
139 Project.find(1).repository.fetch_changesets | 178 @repository.fetch_changesets |
140 get :annotate, :id => 1, :path => ['sources', 'watchers_controller.rb'] | 179 @repository.reload |
180 get :annotate, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'] | |
141 assert_response :success | 181 assert_response :success |
142 assert_template 'annotate' | 182 assert_template 'annotate' |
143 # 1.1 line | 183 # 1.1 line |
144 assert_tag :tag => 'th', :attributes => { :class => 'line-num' }, | 184 assert_tag :tag => 'th', :attributes => { :class => 'line-num' }, |
145 :content => '18', | 185 :content => '18', |