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