annotate .svn/pristine/8e/8eb3da3ac94d3ec30a1122590be0b6f235d41250.svn-base @ 1519:afce8026aaeb redmine-2.4-integration

Merge from branch "live"
author Chris Cannam
date Tue, 09 Sep 2014 09:34:53 +0100
parents cbb26bc654de
children
rev   line source
Chris@909 1 # Redmine - project management software
Chris@909 2 # Copyright (C) 2006-2011 Jean-Philippe Lang
Chris@909 3 #
Chris@909 4 # This program is free software; you can redistribute it and/or
Chris@909 5 # modify it under the terms of the GNU General Public License
Chris@909 6 # as published by the Free Software Foundation; either version 2
Chris@909 7 # of the License, or (at your option) any later version.
Chris@909 8 #
Chris@909 9 # This program is distributed in the hope that it will be useful,
Chris@909 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@909 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@909 12 # GNU General Public License for more details.
Chris@909 13 #
Chris@909 14 # You should have received a copy of the GNU General Public License
Chris@909 15 # along with this program; if not, write to the Free Software
Chris@909 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@909 17
Chris@909 18 require File.expand_path('../../test_helper', __FILE__)
Chris@909 19 require 'repositories_controller'
Chris@909 20
Chris@909 21 # Re-raise errors caught by the controller.
Chris@909 22 class RepositoriesController; def rescue_action(e) raise e end; end
Chris@909 23
Chris@909 24 class RepositoriesControllerTest < ActionController::TestCase
Chris@909 25 fixtures :projects, :users, :roles, :members, :member_roles,
Chris@909 26 :repositories, :issues, :issue_statuses, :changesets, :changes,
Chris@909 27 :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers
Chris@909 28
Chris@909 29 def setup
Chris@909 30 @controller = RepositoriesController.new
Chris@909 31 @request = ActionController::TestRequest.new
Chris@909 32 @response = ActionController::TestResponse.new
Chris@909 33 User.current = nil
Chris@909 34 end
Chris@909 35
Chris@909 36 def test_revisions
Chris@909 37 get :revisions, :id => 1
Chris@909 38 assert_response :success
Chris@909 39 assert_template 'revisions'
Chris@909 40 assert_not_nil assigns(:changesets)
Chris@909 41 end
Chris@909 42
Chris@909 43 def test_revision
Chris@909 44 get :revision, :id => 1, :rev => 1
Chris@909 45 assert_response :success
Chris@909 46 assert_not_nil assigns(:changeset)
Chris@909 47 assert_equal "1", assigns(:changeset).revision
Chris@909 48 end
Chris@909 49
Chris@909 50 def test_revision_with_before_nil_and_afer_normal
Chris@909 51 get :revision, {:id => 1, :rev => 1}
Chris@909 52 assert_response :success
Chris@909 53 assert_template 'revision'
Chris@909 54 assert_no_tag :tag => "div", :attributes => { :class => "contextual" },
Chris@909 55 :child => { :tag => "a", :attributes => { :href => '/projects/ecookbook/repository/revisions/0'}
Chris@909 56 }
Chris@909 57 assert_tag :tag => "div", :attributes => { :class => "contextual" },
Chris@909 58 :child => { :tag => "a", :attributes => { :href => '/projects/ecookbook/repository/revisions/2'}
Chris@909 59 }
Chris@909 60 end
Chris@909 61
Chris@909 62 def test_graph_commits_per_month
Chris@909 63 get :graph, :id => 1, :graph => 'commits_per_month'
Chris@909 64 assert_response :success
Chris@909 65 assert_equal 'image/svg+xml', @response.content_type
Chris@909 66 end
Chris@909 67
Chris@909 68 def test_graph_commits_per_author
Chris@909 69 get :graph, :id => 1, :graph => 'commits_per_author'
Chris@909 70 assert_response :success
Chris@909 71 assert_equal 'image/svg+xml', @response.content_type
Chris@909 72 end
Chris@909 73
Chris@909 74 def test_committers
Chris@909 75 @request.session[:user_id] = 2
Chris@909 76 # add a commit with an unknown user
Chris@909 77 Changeset.create!(
Chris@909 78 :repository => Project.find(1).repository,
Chris@909 79 :committer => 'foo',
Chris@909 80 :committed_on => Time.now,
Chris@909 81 :revision => 100,
Chris@909 82 :comments => 'Committed by foo.'
Chris@909 83 )
Chris@909 84
Chris@909 85 get :committers, :id => 1
Chris@909 86 assert_response :success
Chris@909 87 assert_template 'committers'
Chris@909 88
Chris@909 89 assert_tag :td, :content => 'dlopper',
Chris@909 90 :sibling => { :tag => 'td',
Chris@909 91 :child => { :tag => 'select', :attributes => { :name => %r{^committers\[\d+\]\[\]$} },
Chris@909 92 :child => { :tag => 'option', :content => 'Dave Lopper',
Chris@909 93 :attributes => { :value => '3', :selected => 'selected' }}}}
Chris@909 94 assert_tag :td, :content => 'foo',
Chris@909 95 :sibling => { :tag => 'td',
Chris@909 96 :child => { :tag => 'select', :attributes => { :name => %r{^committers\[\d+\]\[\]$} }}}
Chris@909 97 assert_no_tag :td, :content => 'foo',
Chris@909 98 :sibling => { :tag => 'td',
Chris@909 99 :descendant => { :tag => 'option', :attributes => { :selected => 'selected' }}}
Chris@909 100 end
Chris@909 101
Chris@909 102 def test_map_committers
Chris@909 103 @request.session[:user_id] = 2
Chris@909 104 # add a commit with an unknown user
Chris@909 105 c = Changeset.create!(
Chris@909 106 :repository => Project.find(1).repository,
Chris@909 107 :committer => 'foo',
Chris@909 108 :committed_on => Time.now,
Chris@909 109 :revision => 100,
Chris@909 110 :comments => 'Committed by foo.'
Chris@909 111 )
Chris@909 112 assert_no_difference "Changeset.count(:conditions => 'user_id = 3')" do
Chris@909 113 post :committers, :id => 1, :committers => { '0' => ['foo', '2'], '1' => ['dlopper', '3']}
Chris@909 114 assert_redirected_to '/projects/ecookbook/repository/committers'
Chris@909 115 assert_equal User.find(2), c.reload.user
Chris@909 116 end
Chris@909 117 end
Chris@909 118 end