Mercurial > hg > soundsoftware-site
comparison test/functional/repositories_controller_test.rb @ 524:1248a47e81b3 feature_36
Merge from branch "luisf"
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Mon, 25 Jul 2011 14:39:38 +0100 |
parents | cbce1fd3b1b7 |
children | cbb26bc654de |
comparison
equal
deleted
inserted
replaced
519:3be6bc3c2a17 | 524:1248a47e81b3 |
---|---|
13 # | 13 # |
14 # You should have received a copy of the GNU General Public License | 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 | 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. | 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | 17 |
18 require File.dirname(__FILE__) + '/../test_helper' | 18 require File.expand_path('../../test_helper', __FILE__) |
19 require 'repositories_controller' | 19 require 'repositories_controller' |
20 | 20 |
21 # Re-raise errors caught by the controller. | 21 # Re-raise errors caught by the controller. |
22 class RepositoriesController; def rescue_action(e) raise e end; end | 22 class RepositoriesController; def rescue_action(e) raise e end; end |
23 | 23 |
24 class RepositoriesControllerTest < ActionController::TestCase | 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 | 25 fixtures :projects, :users, :roles, :members, :member_roles, |
26 | 26 :repositories, :issues, :issue_statuses, :changesets, :changes, |
27 :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers | |
28 | |
27 def setup | 29 def setup |
28 @controller = RepositoriesController.new | 30 @controller = RepositoriesController.new |
29 @request = ActionController::TestRequest.new | 31 @request = ActionController::TestRequest.new |
30 @response = ActionController::TestResponse.new | 32 @response = ActionController::TestResponse.new |
31 User.current = nil | 33 User.current = nil |
32 end | 34 end |
33 | 35 |
34 def test_revisions | 36 def test_revisions |
35 get :revisions, :id => 1 | 37 get :revisions, :id => 1 |
36 assert_response :success | 38 assert_response :success |
37 assert_template 'revisions' | 39 assert_template 'revisions' |
38 assert_not_nil assigns(:changesets) | 40 assert_not_nil assigns(:changesets) |
42 get :revision, :id => 1, :rev => 1 | 44 get :revision, :id => 1, :rev => 1 |
43 assert_response :success | 45 assert_response :success |
44 assert_not_nil assigns(:changeset) | 46 assert_not_nil assigns(:changeset) |
45 assert_equal "1", assigns(:changeset).revision | 47 assert_equal "1", assigns(:changeset).revision |
46 end | 48 end |
47 | 49 |
48 def test_revision_with_before_nil_and_afer_normal | 50 def test_revision_with_before_nil_and_afer_normal |
49 get :revision, {:id => 1, :rev => 1} | 51 get :revision, {:id => 1, :rev => 1} |
50 assert_response :success | 52 assert_response :success |
51 assert_template 'revision' | 53 assert_template 'revision' |
52 assert_no_tag :tag => "div", :attributes => { :class => "contextual" }, | 54 assert_no_tag :tag => "div", :attributes => { :class => "contextual" }, |
54 } | 56 } |
55 assert_tag :tag => "div", :attributes => { :class => "contextual" }, | 57 assert_tag :tag => "div", :attributes => { :class => "contextual" }, |
56 :child => { :tag => "a", :attributes => { :href => '/projects/ecookbook/repository/revisions/2'} | 58 :child => { :tag => "a", :attributes => { :href => '/projects/ecookbook/repository/revisions/2'} |
57 } | 59 } |
58 end | 60 end |
59 | 61 |
60 def test_graph_commits_per_month | 62 def test_graph_commits_per_month |
61 get :graph, :id => 1, :graph => 'commits_per_month' | 63 get :graph, :id => 1, :graph => 'commits_per_month' |
62 assert_response :success | 64 assert_response :success |
63 assert_equal 'image/svg+xml', @response.content_type | 65 assert_equal 'image/svg+xml', @response.content_type |
64 end | 66 end |
65 | 67 |
66 def test_graph_commits_per_author | 68 def test_graph_commits_per_author |
67 get :graph, :id => 1, :graph => 'commits_per_author' | 69 get :graph, :id => 1, :graph => 'commits_per_author' |
68 assert_response :success | 70 assert_response :success |
69 assert_equal 'image/svg+xml', @response.content_type | 71 assert_equal 'image/svg+xml', @response.content_type |
70 end | 72 end |
71 | 73 |
72 def test_committers | 74 def test_committers |
73 @request.session[:user_id] = 2 | 75 @request.session[:user_id] = 2 |
74 # add a commit with an unknown user | 76 # 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.') | 77 Changeset.create!( |
76 | 78 :repository => Project.find(1).repository, |
79 :committer => 'foo', | |
80 :committed_on => Time.now, | |
81 :revision => 100, | |
82 :comments => 'Committed by foo.' | |
83 ) | |
84 | |
77 get :committers, :id => 1 | 85 get :committers, :id => 1 |
78 assert_response :success | 86 assert_response :success |
79 assert_template 'committers' | 87 assert_template 'committers' |
80 | 88 |
81 assert_tag :td, :content => 'dlopper', | 89 assert_tag :td, :content => 'dlopper', |
92 end | 100 end |
93 | 101 |
94 def test_map_committers | 102 def test_map_committers |
95 @request.session[:user_id] = 2 | 103 @request.session[:user_id] = 2 |
96 # add a commit with an unknown user | 104 # 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.') | 105 c = Changeset.create!( |
98 | 106 :repository => Project.find(1).repository, |
107 :committer => 'foo', | |
108 :committed_on => Time.now, | |
109 :revision => 100, | |
110 :comments => 'Committed by foo.' | |
111 ) | |
99 assert_no_difference "Changeset.count(:conditions => 'user_id = 3')" do | 112 assert_no_difference "Changeset.count(:conditions => 'user_id = 3')" do |
100 post :committers, :id => 1, :committers => { '0' => ['foo', '2'], '1' => ['dlopper', '3']} | 113 post :committers, :id => 1, :committers => { '0' => ['foo', '2'], '1' => ['dlopper', '3']} |
101 assert_redirected_to '/projects/ecookbook/repository/committers' | 114 assert_redirected_to '/projects/ecookbook/repository/committers' |
102 assert_equal User.find(2), c.reload.user | 115 assert_equal User.find(2), c.reload.user |
103 end | 116 end |