Mercurial > hg > soundsoftware-site
comparison test/functional/repositories_controller_test.rb @ 1526:404aa68d4227
Merge from live branch
author | Chris Cannam |
---|---|
date | Thu, 11 Sep 2014 12:46:20 +0100 |
parents | dffacf8a6908 |
children |
comparison
equal
deleted
inserted
replaced
1493:a5f2bdf3b486 | 1526:404aa68d4227 |
---|---|
1 # Redmine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2012 Jean-Philippe Lang | 2 # Copyright (C) 2006-2014 Jean-Philippe Lang |
3 # | 3 # |
4 # This program is free software; you can redistribute it and/or | 4 # This program is free software; you can redistribute it and/or |
5 # modify it under the terms of the GNU General Public License | 5 # modify it under the terms of the GNU General Public License |
6 # as published by the Free Software Foundation; either version 2 | 6 # as published by the Free Software Foundation; either version 2 |
7 # of the License, or (at your option) any later version. | 7 # of the License, or (at your option) any later version. |
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.expand_path('../../test_helper', __FILE__) | 18 require File.expand_path('../../test_helper', __FILE__) |
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 | 19 |
24 class RepositoriesControllerTest < ActionController::TestCase | 20 class RepositoriesControllerTest < ActionController::TestCase |
25 fixtures :projects, :users, :roles, :members, :member_roles, :enabled_modules, | 21 fixtures :projects, :users, :roles, :members, :member_roles, :enabled_modules, |
26 :repositories, :issues, :issue_statuses, :changesets, :changes, | 22 :repositories, :issues, :issue_statuses, :changesets, :changes, |
27 :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers | 23 :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers |
28 | 24 |
29 def setup | 25 def setup |
30 @controller = RepositoriesController.new | |
31 @request = ActionController::TestRequest.new | |
32 @response = ActionController::TestResponse.new | |
33 User.current = nil | 26 User.current = nil |
34 end | 27 end |
35 | 28 |
36 def test_new | 29 def test_new |
37 @request.session[:user_id] = 1 | 30 @request.session[:user_id] = 1 |
65 post :create, :project_id => 'subproject1', | 58 post :create, :project_id => 'subproject1', |
66 :repository_scm => 'Subversion', | 59 :repository_scm => 'Subversion', |
67 :repository => {:url => 'file:///test', :is_default => '1', :identifier => ''} | 60 :repository => {:url => 'file:///test', :is_default => '1', :identifier => ''} |
68 end | 61 end |
69 assert_response 302 | 62 assert_response 302 |
70 repository = Repository.first(:order => 'id DESC') | 63 repository = Repository.order('id DESC').first |
71 assert_kind_of Repository::Subversion, repository | 64 assert_kind_of Repository::Subversion, repository |
72 assert_equal 'file:///test', repository.url | 65 assert_equal 'file:///test', repository.url |
73 end | 66 end |
74 | 67 |
75 def test_create_with_failure | 68 def test_create_with_failure |
114 assert_difference 'Repository.count', -1 do | 107 assert_difference 'Repository.count', -1 do |
115 delete :destroy, :id => 11 | 108 delete :destroy, :id => 11 |
116 end | 109 end |
117 assert_response 302 | 110 assert_response 302 |
118 assert_nil Repository.find_by_id(11) | 111 assert_nil Repository.find_by_id(11) |
112 end | |
113 | |
114 def test_show_with_autofetch_changesets_enabled_should_fetch_changesets | |
115 Repository::Subversion.any_instance.expects(:fetch_changesets).once | |
116 | |
117 with_settings :autofetch_changesets => '1' do | |
118 get :show, :id => 1 | |
119 end | |
120 end | |
121 | |
122 def test_show_with_autofetch_changesets_disabled_should_not_fetch_changesets | |
123 Repository::Subversion.any_instance.expects(:fetch_changesets).never | |
124 | |
125 with_settings :autofetch_changesets => '0' do | |
126 get :show, :id => 1 | |
127 end | |
128 end | |
129 | |
130 def test_show_with_closed_project_should_not_fetch_changesets | |
131 Repository::Subversion.any_instance.expects(:fetch_changesets).never | |
132 Project.find(1).close | |
133 | |
134 with_settings :autofetch_changesets => '1' do | |
135 get :show, :id => 1 | |
136 end | |
119 end | 137 end |
120 | 138 |
121 def test_revisions | 139 def test_revisions |
122 get :revisions, :id => 1 | 140 get :revisions, :id => 1 |
123 assert_response :success | 141 assert_response :success |
177 assert_equal 'text/javascript', response.content_type | 195 assert_equal 'text/javascript', response.content_type |
178 end | 196 end |
179 assert_equal [2], Changeset.find(103).issue_ids | 197 assert_equal [2], Changeset.find(103).issue_ids |
180 assert_include 'related-issues', response.body | 198 assert_include 'related-issues', response.body |
181 assert_include 'Feature request #2', response.body | 199 assert_include 'Feature request #2', response.body |
200 end | |
201 | |
202 def test_add_related_issue_should_accept_issue_id_with_sharp | |
203 @request.session[:user_id] = 2 | |
204 assert_difference 'Changeset.find(103).issues.size' do | |
205 xhr :post, :add_related_issue, :id => 1, :rev => 4, :issue_id => "#2", :format => 'js' | |
206 end | |
207 assert_equal [2], Changeset.find(103).issue_ids | |
182 end | 208 end |
183 | 209 |
184 def test_add_related_issue_with_invalid_issue_id | 210 def test_add_related_issue_with_invalid_issue_id |
185 @request.session[:user_id] = 2 | 211 @request.session[:user_id] = 2 |
186 assert_no_difference 'Changeset.find(103).issues.size' do | 212 assert_no_difference 'Changeset.find(103).issues.size' do |
260 :committer => 'foo', | 286 :committer => 'foo', |
261 :committed_on => Time.now, | 287 :committed_on => Time.now, |
262 :revision => 100, | 288 :revision => 100, |
263 :comments => 'Committed by foo.' | 289 :comments => 'Committed by foo.' |
264 ) | 290 ) |
265 assert_no_difference "Changeset.count(:conditions => 'user_id = 3')" do | 291 assert_no_difference "Changeset.where(:user_id => 3).count" do |
266 post :committers, :id => 10, :committers => { '0' => ['foo', '2'], '1' => ['dlopper', '3']} | 292 post :committers, :id => 10, :committers => { '0' => ['foo', '2'], '1' => ['dlopper', '3']} |
267 assert_response 302 | 293 assert_response 302 |
268 assert_equal User.find(2), c.reload.user | 294 assert_equal User.find(2), c.reload.user |
269 end | 295 end |
270 end | 296 end |