2011-10-29 16:19:11 +04:00
|
|
|
#-- encoding: UTF-8
|
2011-05-30 00:11:52 +04:00
|
|
|
#-- copyright
|
|
|
|
# ChiliProject is a project management system.
|
2011-05-30 22:52:25 +04:00
|
|
|
#
|
2011-05-30 00:11:52 +04:00
|
|
|
# Copyright (C) 2010-2011 the ChiliProject Team
|
2011-05-30 22:52:25 +04:00
|
|
|
#
|
2007-12-01 20:15:42 +03:00
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
2011-05-30 22:52:25 +04:00
|
|
|
#
|
2011-05-30 00:11:52 +04:00
|
|
|
# See doc/COPYRIGHT.rdoc for more details.
|
|
|
|
#++
|
2010-12-13 02:24:34 +03:00
|
|
|
require File.expand_path('../../test_helper', __FILE__)
|
2007-12-01 20:15:42 +03:00
|
|
|
require 'repositories_controller'
|
|
|
|
|
|
|
|
# Re-raise errors caught by the controller.
|
|
|
|
class RepositoriesController; def rescue_action(e) raise e end; end
|
|
|
|
|
2009-09-13 21:14:35 +04:00
|
|
|
class RepositoriesControllerTest < ActionController::TestCase
|
2011-03-22 10:48:04 +03:00
|
|
|
fixtures :projects, :users, :roles, :members, :member_roles,
|
|
|
|
:repositories, :issues, :issue_statuses, :changesets, :changes,
|
|
|
|
:issue_categories, :enumerations, :custom_fields, :custom_values, :trackers
|
|
|
|
|
2007-12-01 20:15:42 +03:00
|
|
|
def setup
|
|
|
|
@controller = RepositoriesController.new
|
|
|
|
@request = ActionController::TestRequest.new
|
|
|
|
@response = ActionController::TestResponse.new
|
|
|
|
User.current = nil
|
|
|
|
end
|
2011-03-22 10:48:04 +03:00
|
|
|
|
2007-12-12 23:56:22 +03:00
|
|
|
def test_revisions
|
|
|
|
get :revisions, :id => 1
|
|
|
|
assert_response :success
|
|
|
|
assert_template 'revisions'
|
|
|
|
assert_not_nil assigns(:changesets)
|
|
|
|
end
|
2009-01-26 04:47:51 +03:00
|
|
|
|
2009-09-20 19:20:22 +04:00
|
|
|
def test_revision
|
|
|
|
get :revision, :id => 1, :rev => 1
|
|
|
|
assert_response :success
|
|
|
|
assert_not_nil assigns(:changeset)
|
|
|
|
assert_equal "1", assigns(:changeset).revision
|
|
|
|
end
|
2011-03-22 10:48:04 +03:00
|
|
|
|
2007-12-01 20:15:42 +03:00
|
|
|
def test_revision_with_before_nil_and_afer_normal
|
|
|
|
get :revision, {:id => 1, :rev => 1}
|
|
|
|
assert_response :success
|
|
|
|
assert_template 'revision'
|
|
|
|
assert_no_tag :tag => "div", :attributes => { :class => "contextual" },
|
2009-01-26 04:47:51 +03:00
|
|
|
:child => { :tag => "a", :attributes => { :href => '/projects/ecookbook/repository/revisions/0'}
|
2007-12-01 20:15:42 +03:00
|
|
|
}
|
|
|
|
assert_tag :tag => "div", :attributes => { :class => "contextual" },
|
2009-01-26 04:47:51 +03:00
|
|
|
:child => { :tag => "a", :attributes => { :href => '/projects/ecookbook/repository/revisions/2'}
|
2007-12-01 20:15:42 +03:00
|
|
|
}
|
|
|
|
end
|
2011-03-22 10:48:04 +03:00
|
|
|
|
2007-12-12 23:56:22 +03:00
|
|
|
def test_graph_commits_per_month
|
|
|
|
get :graph, :id => 1, :graph => 'commits_per_month'
|
|
|
|
assert_response :success
|
|
|
|
assert_equal 'image/svg+xml', @response.content_type
|
|
|
|
end
|
2011-03-22 10:48:04 +03:00
|
|
|
|
2007-12-12 23:56:22 +03:00
|
|
|
def test_graph_commits_per_author
|
|
|
|
get :graph, :id => 1, :graph => 'commits_per_author'
|
|
|
|
assert_response :success
|
|
|
|
assert_equal 'image/svg+xml', @response.content_type
|
|
|
|
end
|
2011-03-22 10:48:04 +03:00
|
|
|
|
2008-11-10 21:59:06 +03:00
|
|
|
def test_committers
|
|
|
|
@request.session[:user_id] = 2
|
|
|
|
# add a commit with an unknown user
|
2011-03-22 10:48:04 +03:00
|
|
|
Changeset.create!(
|
|
|
|
:repository => Project.find(1).repository,
|
|
|
|
:committer => 'foo',
|
|
|
|
:committed_on => Time.now,
|
|
|
|
:revision => 100,
|
|
|
|
:comments => 'Committed by foo.'
|
|
|
|
)
|
|
|
|
|
2008-11-10 21:59:06 +03:00
|
|
|
get :committers, :id => 1
|
|
|
|
assert_response :success
|
|
|
|
assert_template 'committers'
|
2011-05-30 22:52:25 +04:00
|
|
|
|
2008-11-10 21:59:06 +03:00
|
|
|
assert_tag :td, :content => 'dlopper',
|
|
|
|
:sibling => { :tag => 'td',
|
2008-12-15 21:02:25 +03:00
|
|
|
:child => { :tag => 'select', :attributes => { :name => %r{^committers\[\d+\]\[\]$} },
|
2008-11-10 21:59:06 +03:00
|
|
|
:child => { :tag => 'option', :content => 'Dave Lopper',
|
|
|
|
:attributes => { :value => '3', :selected => 'selected' }}}}
|
|
|
|
assert_tag :td, :content => 'foo',
|
|
|
|
:sibling => { :tag => 'td',
|
2008-12-15 21:02:25 +03:00
|
|
|
:child => { :tag => 'select', :attributes => { :name => %r{^committers\[\d+\]\[\]$} }}}
|
2008-11-10 21:59:06 +03:00
|
|
|
assert_no_tag :td, :content => 'foo',
|
|
|
|
:sibling => { :tag => 'td',
|
|
|
|
:descendant => { :tag => 'option', :attributes => { :selected => 'selected' }}}
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_map_committers
|
|
|
|
@request.session[:user_id] = 2
|
|
|
|
# add a commit with an unknown user
|
2011-03-22 10:48:04 +03:00
|
|
|
c = Changeset.create!(
|
|
|
|
:repository => Project.find(1).repository,
|
|
|
|
:committer => 'foo',
|
|
|
|
:committed_on => Time.now,
|
|
|
|
:revision => 100,
|
|
|
|
:comments => 'Committed by foo.'
|
|
|
|
)
|
2008-11-10 21:59:06 +03:00
|
|
|
assert_no_difference "Changeset.count(:conditions => 'user_id = 3')" do
|
2008-12-15 21:02:25 +03:00
|
|
|
post :committers, :id => 1, :committers => { '0' => ['foo', '2'], '1' => ['dlopper', '3']}
|
2010-11-14 19:45:32 +03:00
|
|
|
assert_redirected_to '/projects/ecookbook/repository/committers'
|
2008-11-10 21:59:06 +03:00
|
|
|
assert_equal User.find(2), c.reload.user
|
|
|
|
end
|
|
|
|
end
|
2007-12-01 20:15:42 +03:00
|
|
|
end
|