Mercurial > hg > soundsoftware-site
comparison test/functional/.svn/text-base/repositories_darcs_controller_test.rb.svn-base @ 245:051f544170fe
* Update to SVN trunk revision 4993
author | Chris Cannam |
---|---|
date | Thu, 03 Mar 2011 11:42:28 +0000 |
parents | 8661b858af72 |
children | cbce1fd3b1b7 |
comparison
equal
deleted
inserted
replaced
244:8972b600f4fb | 245:051f544170fe |
---|---|
24 class RepositoriesDarcsControllerTest < ActionController::TestCase | 24 class RepositoriesDarcsControllerTest < ActionController::TestCase |
25 fixtures :projects, :users, :roles, :members, :member_roles, :repositories, :enabled_modules | 25 fixtures :projects, :users, :roles, :members, :member_roles, :repositories, :enabled_modules |
26 | 26 |
27 # No '..' in the repository path | 27 # No '..' in the repository path |
28 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/darcs_repository' | 28 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/darcs_repository' |
29 PRJ_ID = 3 | |
29 | 30 |
30 def setup | 31 def setup |
31 @controller = RepositoriesController.new | 32 @controller = RepositoriesController.new |
32 @request = ActionController::TestRequest.new | 33 @request = ActionController::TestRequest.new |
33 @response = ActionController::TestResponse.new | 34 @response = ActionController::TestResponse.new |
34 User.current = nil | 35 User.current = nil |
35 Repository::Darcs.create(:project => Project.find(3), :url => REPOSITORY_PATH) | 36 @project = Project.find(PRJ_ID) |
37 @repository = Repository::Darcs.create( | |
38 :project => @project, :url => REPOSITORY_PATH, | |
39 :log_encoding => 'UTF-8') | |
40 assert @repository | |
36 end | 41 end |
37 | 42 |
38 if File.directory?(REPOSITORY_PATH) | 43 if File.directory?(REPOSITORY_PATH) |
39 def test_show | 44 def test_show |
40 get :show, :id => 3 | 45 @repository.fetch_changesets |
46 @repository.reload | |
47 get :show, :id => PRJ_ID | |
41 assert_response :success | 48 assert_response :success |
42 assert_template 'show' | 49 assert_template 'show' |
43 assert_not_nil assigns(:entries) | 50 assert_not_nil assigns(:entries) |
44 assert_not_nil assigns(:changesets) | 51 assert_not_nil assigns(:changesets) |
45 end | 52 end |
46 | 53 |
47 def test_browse_root | 54 def test_browse_root |
48 get :show, :id => 3 | 55 @repository.fetch_changesets |
56 @repository.reload | |
57 get :show, :id => PRJ_ID | |
49 assert_response :success | 58 assert_response :success |
50 assert_template 'show' | 59 assert_template 'show' |
51 assert_not_nil assigns(:entries) | 60 assert_not_nil assigns(:entries) |
52 assert_equal 3, assigns(:entries).size | 61 assert_equal 3, assigns(:entries).size |
53 assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'} | 62 assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'} |
54 assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'} | 63 assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'} |
55 assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'} | 64 assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'} |
56 end | 65 end |
57 | 66 |
58 def test_browse_directory | 67 def test_browse_directory |
59 get :show, :id => 3, :path => ['images'] | 68 @repository.fetch_changesets |
69 @repository.reload | |
70 get :show, :id => PRJ_ID, :path => ['images'] | |
60 assert_response :success | 71 assert_response :success |
61 assert_template 'show' | 72 assert_template 'show' |
62 assert_not_nil assigns(:entries) | 73 assert_not_nil assigns(:entries) |
63 assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name) | 74 assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name) |
64 entry = assigns(:entries).detect {|e| e.name == 'edit.png'} | 75 entry = assigns(:entries).detect {|e| e.name == 'edit.png'} |
65 assert_not_nil entry | 76 assert_not_nil entry |
66 assert_equal 'file', entry.kind | 77 assert_equal 'file', entry.kind |
67 assert_equal 'images/edit.png', entry.path | 78 assert_equal 'images/edit.png', entry.path |
68 end | 79 end |
69 | 80 |
70 def test_browse_at_given_revision | 81 def test_browse_at_given_revision |
71 Project.find(3).repository.fetch_changesets | 82 @repository.fetch_changesets |
72 get :show, :id => 3, :path => ['images'], :rev => 1 | 83 @repository.reload |
84 get :show, :id => PRJ_ID, :path => ['images'], :rev => 1 | |
73 assert_response :success | 85 assert_response :success |
74 assert_template 'show' | 86 assert_template 'show' |
75 assert_not_nil assigns(:entries) | 87 assert_not_nil assigns(:entries) |
76 assert_equal ['delete.png'], assigns(:entries).collect(&:name) | 88 assert_equal ['delete.png'], assigns(:entries).collect(&:name) |
77 end | 89 end |
78 | 90 |
79 def test_changes | 91 def test_changes |
80 get :changes, :id => 3, :path => ['images', 'edit.png'] | 92 @repository.fetch_changesets |
93 @repository.reload | |
94 get :changes, :id => PRJ_ID, :path => ['images', 'edit.png'] | |
81 assert_response :success | 95 assert_response :success |
82 assert_template 'changes' | 96 assert_template 'changes' |
83 assert_tag :tag => 'h2', :content => 'edit.png' | 97 assert_tag :tag => 'h2', :content => 'edit.png' |
84 end | 98 end |
85 | 99 |
86 def test_diff | 100 def test_diff |
87 Project.find(3).repository.fetch_changesets | 101 @repository.fetch_changesets |
102 @repository.reload | |
88 # Full diff of changeset 5 | 103 # Full diff of changeset 5 |
89 get :diff, :id => 3, :rev => 5 | 104 get :diff, :id => PRJ_ID, :rev => 5 |
90 assert_response :success | 105 assert_response :success |
91 assert_template 'diff' | 106 assert_template 'diff' |
92 # Line 22 removed | 107 # Line 22 removed |
93 assert_tag :tag => 'th', | 108 assert_tag :tag => 'th', |
94 :content => /22/, | 109 :content => /22/, |