Mercurial > hg > soundsoftware-site
comparison test/functional/.svn/text-base/repositories_bazaar_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 | af80e5618e9b |
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 RepositoriesBazaarControllerTest < ActionController::TestCase | |
25 fixtures :projects, :users, :roles, :members, :member_roles, :repositories, :enabled_modules | |
26 | |
27 # No '..' in the repository path | |
28 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/bazaar_repository' | |
29 | |
30 def setup | |
31 @controller = RepositoriesController.new | |
32 @request = ActionController::TestRequest.new | |
33 @response = ActionController::TestResponse.new | |
34 User.current = nil | |
35 Repository::Bazaar.create(:project => Project.find(3), :url => REPOSITORY_PATH) | |
36 end | |
37 | |
38 if File.directory?(REPOSITORY_PATH) | |
39 def test_show | |
40 get :show, :id => 3 | |
41 assert_response :success | |
42 assert_template 'show' | |
43 assert_not_nil assigns(:entries) | |
44 assert_not_nil assigns(:changesets) | |
45 end | |
46 | |
47 def test_browse_root | |
48 get :show, :id => 3 | |
49 assert_response :success | |
50 assert_template 'show' | |
51 assert_not_nil assigns(:entries) | |
52 assert_equal 2, assigns(:entries).size | |
53 assert assigns(:entries).detect {|e| e.name == 'directory' && e.kind == 'dir'} | |
54 assert assigns(:entries).detect {|e| e.name == 'doc-mkdir.txt' && e.kind == 'file'} | |
55 end | |
56 | |
57 def test_browse_directory | |
58 get :show, :id => 3, :path => ['directory'] | |
59 assert_response :success | |
60 assert_template 'show' | |
61 assert_not_nil assigns(:entries) | |
62 assert_equal ['doc-ls.txt', 'document.txt', 'edit.png'], assigns(:entries).collect(&:name) | |
63 entry = assigns(:entries).detect {|e| e.name == 'edit.png'} | |
64 assert_not_nil entry | |
65 assert_equal 'file', entry.kind | |
66 assert_equal 'directory/edit.png', entry.path | |
67 end | |
68 | |
69 def test_browse_at_given_revision | |
70 get :show, :id => 3, :path => [], :rev => 3 | |
71 assert_response :success | |
72 assert_template 'show' | |
73 assert_not_nil assigns(:entries) | |
74 assert_equal ['directory', 'doc-deleted.txt', 'doc-ls.txt', 'doc-mkdir.txt'], assigns(:entries).collect(&:name) | |
75 end | |
76 | |
77 def test_changes | |
78 get :changes, :id => 3, :path => ['doc-mkdir.txt'] | |
79 assert_response :success | |
80 assert_template 'changes' | |
81 assert_tag :tag => 'h2', :content => 'doc-mkdir.txt' | |
82 end | |
83 | |
84 def test_entry_show | |
85 get :entry, :id => 3, :path => ['directory', 'doc-ls.txt'] | |
86 assert_response :success | |
87 assert_template 'entry' | |
88 # Line 19 | |
89 assert_tag :tag => 'th', | |
90 :content => /29/, | |
91 :attributes => { :class => /line-num/ }, | |
92 :sibling => { :tag => 'td', :content => /Show help message/ } | |
93 end | |
94 | |
95 def test_entry_download | |
96 get :entry, :id => 3, :path => ['directory', 'doc-ls.txt'], :format => 'raw' | |
97 assert_response :success | |
98 # File content | |
99 assert @response.body.include?('Show help message') | |
100 end | |
101 | |
102 def test_directory_entry | |
103 get :entry, :id => 3, :path => ['directory'] | |
104 assert_response :success | |
105 assert_template 'show' | |
106 assert_not_nil assigns(:entry) | |
107 assert_equal 'directory', assigns(:entry).name | |
108 end | |
109 | |
110 def test_diff | |
111 # Full diff of changeset 3 | |
112 get :diff, :id => 3, :rev => 3 | |
113 assert_response :success | |
114 assert_template 'diff' | |
115 # Line 22 removed | |
116 assert_tag :tag => 'th', | |
117 :content => /2/, | |
118 :sibling => { :tag => 'td', | |
119 :attributes => { :class => /diff_in/ }, | |
120 :content => /Main purpose/ } | |
121 end | |
122 | |
123 def test_annotate | |
124 get :annotate, :id => 3, :path => ['doc-mkdir.txt'] | |
125 assert_response :success | |
126 assert_template 'annotate' | |
127 # Line 2, revision 3 | |
128 assert_tag :tag => 'th', :content => /2/, | |
129 :sibling => { :tag => 'td', :child => { :tag => 'a', :content => /3/ } }, | |
130 :sibling => { :tag => 'td', :content => /jsmith/ }, | |
131 :sibling => { :tag => 'td', :content => /Main purpose/ } | |
132 end | |
133 else | |
134 puts "Bazaar test repository NOT FOUND. Skipping functional tests !!!" | |
135 def test_fake; assert true end | |
136 end | |
137 end |