To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / test / functional / .svn / text-base / repositories_bazaar_controller_test.rb.svn-base @ 441:cbce1fd3b1b7
History | View | Annotate | Download (5.07 KB)
| 1 | 0:513646585e45 | Chris | # 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 | 119:8661b858af72 | Chris | require File.expand_path('../../test_helper', __FILE__)
|
| 19 | 0:513646585e45 | Chris | 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 | 245:051f544170fe | Chris | @project = Project.find(3) |
| 36 | @repository = Repository::Bazaar.create( |
||
| 37 | :project => @project, :url => REPOSITORY_PATH, |
||
| 38 | :log_encoding => 'UTF-8') |
||
| 39 | assert @repository |
||
| 40 | 0:513646585e45 | Chris | end |
| 41 | 245:051f544170fe | Chris | |
| 42 | 0:513646585e45 | Chris | if File.directory?(REPOSITORY_PATH) |
| 43 | def test_show |
||
| 44 | get :show, :id => 3 |
||
| 45 | assert_response :success |
||
| 46 | assert_template 'show' |
||
| 47 | assert_not_nil assigns(:entries) |
||
| 48 | assert_not_nil assigns(:changesets) |
||
| 49 | end |
||
| 50 | 245:051f544170fe | Chris | |
| 51 | 0:513646585e45 | Chris | def test_browse_root |
| 52 | get :show, :id => 3 |
||
| 53 | assert_response :success |
||
| 54 | assert_template 'show' |
||
| 55 | assert_not_nil assigns(:entries) |
||
| 56 | assert_equal 2, assigns(:entries).size |
||
| 57 | assert assigns(:entries).detect {|e| e.name == 'directory' && e.kind == 'dir'}
|
||
| 58 | assert assigns(:entries).detect {|e| e.name == 'doc-mkdir.txt' && e.kind == 'file'}
|
||
| 59 | end |
||
| 60 | 245:051f544170fe | Chris | |
| 61 | 0:513646585e45 | Chris | def test_browse_directory |
| 62 | get :show, :id => 3, :path => ['directory'] |
||
| 63 | assert_response :success |
||
| 64 | assert_template 'show' |
||
| 65 | assert_not_nil assigns(:entries) |
||
| 66 | assert_equal ['doc-ls.txt', 'document.txt', 'edit.png'], assigns(:entries).collect(&:name) |
||
| 67 | entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
|
||
| 68 | assert_not_nil entry |
||
| 69 | assert_equal 'file', entry.kind |
||
| 70 | assert_equal 'directory/edit.png', entry.path |
||
| 71 | end |
||
| 72 | |||
| 73 | def test_browse_at_given_revision |
||
| 74 | get :show, :id => 3, :path => [], :rev => 3 |
||
| 75 | assert_response :success |
||
| 76 | assert_template 'show' |
||
| 77 | assert_not_nil assigns(:entries) |
||
| 78 | assert_equal ['directory', 'doc-deleted.txt', 'doc-ls.txt', 'doc-mkdir.txt'], assigns(:entries).collect(&:name) |
||
| 79 | end |
||
| 80 | |||
| 81 | def test_changes |
||
| 82 | get :changes, :id => 3, :path => ['doc-mkdir.txt'] |
||
| 83 | assert_response :success |
||
| 84 | assert_template 'changes' |
||
| 85 | assert_tag :tag => 'h2', :content => 'doc-mkdir.txt' |
||
| 86 | end |
||
| 87 | |||
| 88 | def test_entry_show |
||
| 89 | get :entry, :id => 3, :path => ['directory', 'doc-ls.txt'] |
||
| 90 | assert_response :success |
||
| 91 | assert_template 'entry' |
||
| 92 | # Line 19 |
||
| 93 | assert_tag :tag => 'th', |
||
| 94 | :content => /29/, |
||
| 95 | :attributes => { :class => /line-num/ },
|
||
| 96 | :sibling => { :tag => 'td', :content => /Show help message/ }
|
||
| 97 | end |
||
| 98 | |||
| 99 | def test_entry_download |
||
| 100 | get :entry, :id => 3, :path => ['directory', 'doc-ls.txt'], :format => 'raw' |
||
| 101 | assert_response :success |
||
| 102 | # File content |
||
| 103 | assert @response.body.include?('Show help message')
|
||
| 104 | end |
||
| 105 | |||
| 106 | def test_directory_entry |
||
| 107 | get :entry, :id => 3, :path => ['directory'] |
||
| 108 | assert_response :success |
||
| 109 | assert_template 'show' |
||
| 110 | assert_not_nil assigns(:entry) |
||
| 111 | assert_equal 'directory', assigns(:entry).name |
||
| 112 | end |
||
| 113 | |||
| 114 | def test_diff |
||
| 115 | # Full diff of changeset 3 |
||
| 116 | get :diff, :id => 3, :rev => 3 |
||
| 117 | assert_response :success |
||
| 118 | assert_template 'diff' |
||
| 119 | 441:cbce1fd3b1b7 | Chris | # Line 11 removed |
| 120 | 0:513646585e45 | Chris | assert_tag :tag => 'th', |
| 121 | 441:cbce1fd3b1b7 | Chris | :content => /11/, |
| 122 | 0:513646585e45 | Chris | :sibling => { :tag => 'td',
|
| 123 | 441:cbce1fd3b1b7 | Chris | :attributes => { :class => /diff_out/ },
|
| 124 | :content => /Display more information/ } |
||
| 125 | 0:513646585e45 | Chris | end |
| 126 | |||
| 127 | def test_annotate |
||
| 128 | get :annotate, :id => 3, :path => ['doc-mkdir.txt'] |
||
| 129 | assert_response :success |
||
| 130 | assert_template 'annotate' |
||
| 131 | # Line 2, revision 3 |
||
| 132 | assert_tag :tag => 'th', :content => /2/, |
||
| 133 | :sibling => { :tag => 'td', :child => { :tag => 'a', :content => /3/ } },
|
||
| 134 | :sibling => { :tag => 'td', :content => /jsmith/ },
|
||
| 135 | :sibling => { :tag => 'td', :content => /Main purpose/ }
|
||
| 136 | end |
||
| 137 | else |
||
| 138 | puts "Bazaar test repository NOT FOUND. Skipping functional tests !!!" |
||
| 139 | def test_fake; assert true end |
||
| 140 | end |
||
| 141 | end |