Mercurial > hg > soundsoftware-site
comparison .svn/pristine/4c/4c998cfe872582fc9c34765173f146ee719b1024.svn-base @ 1296:038ba2d95de8 redmine-2.2
Fix redmine-2.2 branch update (add missing svn files)
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:05:06 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1294:3e4c3460b6ca | 1296:038ba2d95de8 |
---|---|
1 # Redmine - project management software | |
2 # Copyright (C) 2006-2012 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.expand_path('../../test_helper', __FILE__) | |
19 | |
20 class RepositoriesDarcsControllerTest < ActionController::TestCase | |
21 tests RepositoriesController | |
22 | |
23 fixtures :projects, :users, :roles, :members, :member_roles, | |
24 :repositories, :enabled_modules | |
25 | |
26 REPOSITORY_PATH = Rails.root.join('tmp/test/darcs_repository').to_s | |
27 PRJ_ID = 3 | |
28 NUM_REV = 6 | |
29 | |
30 def setup | |
31 User.current = nil | |
32 @project = Project.find(PRJ_ID) | |
33 @repository = Repository::Darcs.create( | |
34 :project => @project, | |
35 :url => REPOSITORY_PATH, | |
36 :log_encoding => 'UTF-8' | |
37 ) | |
38 assert @repository | |
39 end | |
40 | |
41 if File.directory?(REPOSITORY_PATH) | |
42 def test_get_new | |
43 @request.session[:user_id] = 1 | |
44 @project.repository.destroy | |
45 get :new, :project_id => 'subproject1', :repository_scm => 'Darcs' | |
46 assert_response :success | |
47 assert_template 'new' | |
48 assert_kind_of Repository::Darcs, assigns(:repository) | |
49 assert assigns(:repository).new_record? | |
50 end | |
51 | |
52 def test_browse_root | |
53 assert_equal 0, @repository.changesets.count | |
54 @repository.fetch_changesets | |
55 @project.reload | |
56 assert_equal NUM_REV, @repository.changesets.count | |
57 get :show, :id => PRJ_ID | |
58 assert_response :success | |
59 assert_template 'show' | |
60 assert_not_nil assigns(:entries) | |
61 assert_equal 3, assigns(:entries).size | |
62 assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'} | |
63 assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'} | |
64 assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'} | |
65 end | |
66 | |
67 def test_browse_directory | |
68 assert_equal 0, @repository.changesets.count | |
69 @repository.fetch_changesets | |
70 @project.reload | |
71 assert_equal NUM_REV, @repository.changesets.count | |
72 get :show, :id => PRJ_ID, :path => repository_path_hash(['images'])[:param] | |
73 assert_response :success | |
74 assert_template 'show' | |
75 assert_not_nil assigns(:entries) | |
76 assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name) | |
77 entry = assigns(:entries).detect {|e| e.name == 'edit.png'} | |
78 assert_not_nil entry | |
79 assert_equal 'file', entry.kind | |
80 assert_equal 'images/edit.png', entry.path | |
81 end | |
82 | |
83 def test_browse_at_given_revision | |
84 assert_equal 0, @repository.changesets.count | |
85 @repository.fetch_changesets | |
86 @project.reload | |
87 assert_equal NUM_REV, @repository.changesets.count | |
88 get :show, :id => PRJ_ID, :path => repository_path_hash(['images'])[:param], | |
89 :rev => 1 | |
90 assert_response :success | |
91 assert_template 'show' | |
92 assert_not_nil assigns(:entries) | |
93 assert_equal ['delete.png'], assigns(:entries).collect(&:name) | |
94 end | |
95 | |
96 def test_changes | |
97 assert_equal 0, @repository.changesets.count | |
98 @repository.fetch_changesets | |
99 @project.reload | |
100 assert_equal NUM_REV, @repository.changesets.count | |
101 get :changes, :id => PRJ_ID, | |
102 :path => repository_path_hash(['images', 'edit.png'])[:param] | |
103 assert_response :success | |
104 assert_template 'changes' | |
105 assert_tag :tag => 'h2', :content => 'edit.png' | |
106 end | |
107 | |
108 def test_diff | |
109 assert_equal 0, @repository.changesets.count | |
110 @repository.fetch_changesets | |
111 @project.reload | |
112 assert_equal NUM_REV, @repository.changesets.count | |
113 # Full diff of changeset 5 | |
114 ['inline', 'sbs'].each do |dt| | |
115 get :diff, :id => PRJ_ID, :rev => 5, :type => dt | |
116 assert_response :success | |
117 assert_template 'diff' | |
118 # Line 22 removed | |
119 assert_tag :tag => 'th', | |
120 :content => '22', | |
121 :sibling => { :tag => 'td', | |
122 :attributes => { :class => /diff_out/ }, | |
123 :content => /def remove/ } | |
124 end | |
125 end | |
126 | |
127 def test_destroy_valid_repository | |
128 @request.session[:user_id] = 1 # admin | |
129 assert_equal 0, @repository.changesets.count | |
130 @repository.fetch_changesets | |
131 @project.reload | |
132 assert_equal NUM_REV, @repository.changesets.count | |
133 | |
134 assert_difference 'Repository.count', -1 do | |
135 delete :destroy, :id => @repository.id | |
136 end | |
137 assert_response 302 | |
138 @project.reload | |
139 assert_nil @project.repository | |
140 end | |
141 | |
142 def test_destroy_invalid_repository | |
143 @request.session[:user_id] = 1 # admin | |
144 @project.repository.destroy | |
145 @repository = Repository::Darcs.create!( | |
146 :project => @project, | |
147 :url => "/invalid", | |
148 :log_encoding => 'UTF-8' | |
149 ) | |
150 @repository.fetch_changesets | |
151 @project.reload | |
152 assert_equal 0, @repository.changesets.count | |
153 | |
154 assert_difference 'Repository.count', -1 do | |
155 delete :destroy, :id => @repository.id | |
156 end | |
157 assert_response 302 | |
158 @project.reload | |
159 assert_nil @project.repository | |
160 end | |
161 else | |
162 puts "Darcs test repository NOT FOUND. Skipping functional tests !!!" | |
163 def test_fake; assert true end | |
164 end | |
165 end |