Mercurial > hg > soundsoftware-site
comparison test/functional/.svn/text-base/repositories_cvs_controller_test.rb.svn-base @ 210:0579821a129a
Update to Redmine trunk rev 4802
author | Chris Cannam |
---|---|
date | Tue, 08 Feb 2011 13:51:46 +0000 |
parents | 8661b858af72 |
children | 051f544170fe |
comparison
equal
deleted
inserted
replaced
128:07fa8a8b56a8 | 210:0579821a129a |
---|---|
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 assert @repository | |
43 end | 46 end |
44 | 47 |
45 if File.directory?(REPOSITORY_PATH) | 48 if File.directory?(REPOSITORY_PATH) |
46 def test_show | 49 def test_show |
47 get :show, :id => 1 | 50 @repository.fetch_changesets |
51 @repository.reload | |
52 get :show, :id => PRJ_ID | |
48 assert_response :success | 53 assert_response :success |
49 assert_template 'show' | 54 assert_template 'show' |
50 assert_not_nil assigns(:entries) | 55 assert_not_nil assigns(:entries) |
51 assert_not_nil assigns(:changesets) | 56 assert_not_nil assigns(:changesets) |
52 end | 57 end |
53 | 58 |
54 def test_browse_root | 59 def test_browse_root |
55 get :show, :id => 1 | 60 @repository.fetch_changesets |
61 @repository.reload | |
62 get :show, :id => PRJ_ID | |
56 assert_response :success | 63 assert_response :success |
57 assert_template 'show' | 64 assert_template 'show' |
58 assert_not_nil assigns(:entries) | 65 assert_not_nil assigns(:entries) |
59 assert_equal 3, assigns(:entries).size | 66 assert_equal 3, assigns(:entries).size |
60 | 67 |
64 entry = assigns(:entries).detect {|e| e.name == 'README'} | 71 entry = assigns(:entries).detect {|e| e.name == 'README'} |
65 assert_equal 'file', entry.kind | 72 assert_equal 'file', entry.kind |
66 end | 73 end |
67 | 74 |
68 def test_browse_directory | 75 def test_browse_directory |
69 get :show, :id => 1, :path => ['images'] | 76 @repository.fetch_changesets |
77 @repository.reload | |
78 get :show, :id => PRJ_ID, :path => ['images'] | |
70 assert_response :success | 79 assert_response :success |
71 assert_template 'show' | 80 assert_template 'show' |
72 assert_not_nil assigns(:entries) | 81 assert_not_nil assigns(:entries) |
73 assert_equal ['add.png', 'delete.png', 'edit.png'], assigns(:entries).collect(&:name) | 82 assert_equal ['add.png', 'delete.png', 'edit.png'], assigns(:entries).collect(&:name) |
74 entry = assigns(:entries).detect {|e| e.name == 'edit.png'} | 83 entry = assigns(:entries).detect {|e| e.name == 'edit.png'} |
76 assert_equal 'file', entry.kind | 85 assert_equal 'file', entry.kind |
77 assert_equal 'images/edit.png', entry.path | 86 assert_equal 'images/edit.png', entry.path |
78 end | 87 end |
79 | 88 |
80 def test_browse_at_given_revision | 89 def test_browse_at_given_revision |
81 Project.find(1).repository.fetch_changesets | 90 @repository.fetch_changesets |
82 get :show, :id => 1, :path => ['images'], :rev => 1 | 91 @repository.reload |
92 get :show, :id => PRJ_ID, :path => ['images'], :rev => 1 | |
83 assert_response :success | 93 assert_response :success |
84 assert_template 'show' | 94 assert_template 'show' |
85 assert_not_nil assigns(:entries) | 95 assert_not_nil assigns(:entries) |
86 assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name) | 96 assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name) |
87 end | 97 end |
88 | 98 |
89 def test_entry | 99 def test_entry |
90 get :entry, :id => 1, :path => ['sources', 'watchers_controller.rb'] | 100 @repository.fetch_changesets |
101 @repository.reload | |
102 get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'] | |
91 assert_response :success | 103 assert_response :success |
92 assert_template 'entry' | 104 assert_template 'entry' |
93 assert_no_tag :tag => 'td', :attributes => { :class => /line-code/}, | 105 assert_no_tag :tag => 'td', :attributes => { :class => /line-code/}, |
94 :content => /before_filter/ | 106 :content => /before_filter/ |
95 end | 107 end |
96 | 108 |
97 def test_entry_at_given_revision | 109 def test_entry_at_given_revision |
98 # changesets must be loaded | 110 # changesets must be loaded |
99 Project.find(1).repository.fetch_changesets | 111 @repository.fetch_changesets |
100 get :entry, :id => 1, :path => ['sources', 'watchers_controller.rb'], :rev => 2 | 112 @repository.reload |
113 get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'], :rev => 2 | |
101 assert_response :success | 114 assert_response :success |
102 assert_template 'entry' | 115 assert_template 'entry' |
103 # this line was removed in r3 | 116 # this line was removed in r3 |
104 assert_tag :tag => 'td', :attributes => { :class => /line-code/}, | 117 assert_tag :tag => 'td', :attributes => { :class => /line-code/}, |
105 :content => /before_filter/ | 118 :content => /before_filter/ |
106 end | 119 end |
107 | 120 |
108 def test_entry_not_found | 121 def test_entry_not_found |
109 get :entry, :id => 1, :path => ['sources', 'zzz.c'] | 122 @repository.fetch_changesets |
123 @repository.reload | |
124 get :entry, :id => PRJ_ID, :path => ['sources', 'zzz.c'] | |
110 assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, | 125 assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, |
111 :content => /The entry or revision was not found in the repository/ | 126 :content => /The entry or revision was not found in the repository/ |
112 end | 127 end |
113 | 128 |
114 def test_entry_download | 129 def test_entry_download |
115 get :entry, :id => 1, :path => ['sources', 'watchers_controller.rb'], :format => 'raw' | 130 @repository.fetch_changesets |
131 @repository.reload | |
132 get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'], :format => 'raw' | |
116 assert_response :success | 133 assert_response :success |
117 end | 134 end |
118 | 135 |
119 def test_directory_entry | 136 def test_directory_entry |
120 get :entry, :id => 1, :path => ['sources'] | 137 @repository.fetch_changesets |
138 @repository.reload | |
139 get :entry, :id => PRJ_ID, :path => ['sources'] | |
121 assert_response :success | 140 assert_response :success |
122 assert_template 'show' | 141 assert_template 'show' |
123 assert_not_nil assigns(:entry) | 142 assert_not_nil assigns(:entry) |
124 assert_equal 'sources', assigns(:entry).name | 143 assert_equal 'sources', assigns(:entry).name |
125 end | 144 end |
126 | 145 |
127 def test_diff | 146 def test_diff |
128 Project.find(1).repository.fetch_changesets | 147 @repository.fetch_changesets |
129 get :diff, :id => 1, :rev => 3, :type => 'inline' | 148 @repository.reload |
149 get :diff, :id => PRJ_ID, :rev => 3, :type => 'inline' | |
130 assert_response :success | 150 assert_response :success |
131 assert_template 'diff' | 151 assert_template 'diff' |
132 assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_out' }, | 152 assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_out' }, |
133 :content => /watched.remove_watcher/ | 153 :content => /watched.remove_watcher/ |
134 assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_in' }, | 154 assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_in' }, |
135 :content => /watched.remove_all_watcher/ | 155 :content => /watched.remove_all_watcher/ |
136 end | 156 end |
137 | 157 |
138 def test_annotate | 158 def test_annotate |
139 Project.find(1).repository.fetch_changesets | 159 @repository.fetch_changesets |
140 get :annotate, :id => 1, :path => ['sources', 'watchers_controller.rb'] | 160 @repository.reload |
161 get :annotate, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'] | |
141 assert_response :success | 162 assert_response :success |
142 assert_template 'annotate' | 163 assert_template 'annotate' |
143 # 1.1 line | 164 # 1.1 line |
144 assert_tag :tag => 'th', :attributes => { :class => 'line-num' }, | 165 assert_tag :tag => 'th', :attributes => { :class => 'line-num' }, |
145 :content => '18', | 166 :content => '18', |