Mercurial > hg > soundsoftware-site
comparison test/functional/.svn/text-base/repositories_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 | 94944d00e43c |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:513646585e45 |
---|---|
1 # redMine - project management software | |
2 # Copyright (C) 2006-2007 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 RepositoriesControllerTest < ActionController::TestCase | |
25 fixtures :projects, :users, :roles, :members, :member_roles, :repositories, :issues, :issue_statuses, :changesets, :changes, :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers | |
26 | |
27 def setup | |
28 @controller = RepositoriesController.new | |
29 @request = ActionController::TestRequest.new | |
30 @response = ActionController::TestResponse.new | |
31 User.current = nil | |
32 end | |
33 | |
34 def test_revisions | |
35 get :revisions, :id => 1 | |
36 assert_response :success | |
37 assert_template 'revisions' | |
38 assert_not_nil assigns(:changesets) | |
39 end | |
40 | |
41 def test_revision | |
42 get :revision, :id => 1, :rev => 1 | |
43 assert_response :success | |
44 assert_not_nil assigns(:changeset) | |
45 assert_equal "1", assigns(:changeset).revision | |
46 end | |
47 | |
48 def test_revision_with_before_nil_and_afer_normal | |
49 get :revision, {:id => 1, :rev => 1} | |
50 assert_response :success | |
51 assert_template 'revision' | |
52 assert_no_tag :tag => "div", :attributes => { :class => "contextual" }, | |
53 :child => { :tag => "a", :attributes => { :href => '/projects/ecookbook/repository/revisions/0'} | |
54 } | |
55 assert_tag :tag => "div", :attributes => { :class => "contextual" }, | |
56 :child => { :tag => "a", :attributes => { :href => '/projects/ecookbook/repository/revisions/2'} | |
57 } | |
58 end | |
59 | |
60 def test_graph_commits_per_month | |
61 get :graph, :id => 1, :graph => 'commits_per_month' | |
62 assert_response :success | |
63 assert_equal 'image/svg+xml', @response.content_type | |
64 end | |
65 | |
66 def test_graph_commits_per_author | |
67 get :graph, :id => 1, :graph => 'commits_per_author' | |
68 assert_response :success | |
69 assert_equal 'image/svg+xml', @response.content_type | |
70 end | |
71 | |
72 def test_committers | |
73 @request.session[:user_id] = 2 | |
74 # add a commit with an unknown user | |
75 Changeset.create!(:repository => Project.find(1).repository, :committer => 'foo', :committed_on => Time.now, :revision => 100, :comments => 'Committed by foo.') | |
76 | |
77 get :committers, :id => 1 | |
78 assert_response :success | |
79 assert_template 'committers' | |
80 | |
81 assert_tag :td, :content => 'dlopper', | |
82 :sibling => { :tag => 'td', | |
83 :child => { :tag => 'select', :attributes => { :name => %r{^committers\[\d+\]\[\]$} }, | |
84 :child => { :tag => 'option', :content => 'Dave Lopper', | |
85 :attributes => { :value => '3', :selected => 'selected' }}}} | |
86 assert_tag :td, :content => 'foo', | |
87 :sibling => { :tag => 'td', | |
88 :child => { :tag => 'select', :attributes => { :name => %r{^committers\[\d+\]\[\]$} }}} | |
89 assert_no_tag :td, :content => 'foo', | |
90 :sibling => { :tag => 'td', | |
91 :descendant => { :tag => 'option', :attributes => { :selected => 'selected' }}} | |
92 end | |
93 | |
94 def test_map_committers | |
95 @request.session[:user_id] = 2 | |
96 # add a commit with an unknown user | |
97 c = Changeset.create!(:repository => Project.find(1).repository, :committer => 'foo', :committed_on => Time.now, :revision => 100, :comments => 'Committed by foo.') | |
98 | |
99 assert_no_difference "Changeset.count(:conditions => 'user_id = 3')" do | |
100 post :committers, :id => 1, :committers => { '0' => ['foo', '2'], '1' => ['dlopper', '3']} | |
101 assert_redirected_to 'projects/ecookbook/repository/committers' | |
102 assert_equal User.find(2), c.reload.user | |
103 end | |
104 end | |
105 end |