Mercurial > hg > soundsoftware-site
comparison .svn/pristine/d6/d67c3b233c2de5e381b50b04ecf28037f5dff73a.svn-base @ 1296:038ba2d95de8 redmine-2.2
Fix redmine-2.2 branch update (add missing svn files)
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:05:06 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1294:3e4c3460b6ca | 1296:038ba2d95de8 |
---|---|
1 # Redmine - project management software | |
2 # Copyright (C) 2006-2012 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 require File.expand_path('../../test_helper', __FILE__) | |
19 require 'sys_controller' | |
20 require 'mocha' | |
21 | |
22 # Re-raise errors caught by the controller. | |
23 class SysController; def rescue_action(e) raise e end; end | |
24 | |
25 class SysControllerTest < ActionController::TestCase | |
26 fixtures :projects, :repositories, :enabled_modules | |
27 | |
28 def setup | |
29 @controller = SysController.new | |
30 @request = ActionController::TestRequest.new | |
31 @response = ActionController::TestResponse.new | |
32 Setting.sys_api_enabled = '1' | |
33 Setting.enabled_scm = %w(Subversion Git) | |
34 end | |
35 | |
36 def teardown | |
37 Setting.clear_cache | |
38 end | |
39 | |
40 def test_projects_with_repository_enabled | |
41 get :projects | |
42 assert_response :success | |
43 assert_equal 'application/xml', @response.content_type | |
44 with_options :tag => 'projects' do |test| | |
45 test.assert_tag :children => { :count => Project.active.has_module(:repository).count } | |
46 test.assert_tag 'project', :child => {:tag => 'identifier', :sibling => {:tag => 'is-public'}} | |
47 end | |
48 assert_no_tag 'extra-info' | |
49 assert_no_tag 'extra_info' | |
50 end | |
51 | |
52 def test_create_project_repository | |
53 assert_nil Project.find(4).repository | |
54 | |
55 post :create_project_repository, :id => 4, | |
56 :vendor => 'Subversion', | |
57 :repository => { :url => 'file:///create/project/repository/subproject2'} | |
58 assert_response :created | |
59 assert_equal 'application/xml', @response.content_type | |
60 | |
61 r = Project.find(4).repository | |
62 assert r.is_a?(Repository::Subversion) | |
63 assert_equal 'file:///create/project/repository/subproject2', r.url | |
64 | |
65 assert_tag 'repository-subversion', | |
66 :child => { | |
67 :tag => 'id', :content => r.id.to_s, | |
68 :sibling => {:tag => 'url', :content => r.url} | |
69 } | |
70 assert_no_tag 'extra-info' | |
71 assert_no_tag 'extra_info' | |
72 end | |
73 | |
74 def test_create_already_existing | |
75 post :create_project_repository, :id => 1, | |
76 :vendor => 'Subversion', | |
77 :repository => { :url => 'file:///create/project/repository/subproject2'} | |
78 | |
79 assert_response :conflict | |
80 end | |
81 | |
82 def test_create_with_failure | |
83 post :create_project_repository, :id => 4, | |
84 :vendor => 'Subversion', | |
85 :repository => { :url => 'invalid url'} | |
86 | |
87 assert_response :unprocessable_entity | |
88 end | |
89 | |
90 def test_fetch_changesets | |
91 Repository::Subversion.any_instance.expects(:fetch_changesets).twice.returns(true) | |
92 get :fetch_changesets | |
93 assert_response :success | |
94 end | |
95 | |
96 def test_fetch_changesets_one_project_by_identifier | |
97 Repository::Subversion.any_instance.expects(:fetch_changesets).once.returns(true) | |
98 get :fetch_changesets, :id => 'ecookbook' | |
99 assert_response :success | |
100 end | |
101 | |
102 def test_fetch_changesets_one_project_by_id | |
103 Repository::Subversion.any_instance.expects(:fetch_changesets).once.returns(true) | |
104 get :fetch_changesets, :id => '1' | |
105 assert_response :success | |
106 end | |
107 | |
108 def test_fetch_changesets_unknown_project | |
109 get :fetch_changesets, :id => 'unknown' | |
110 assert_response 404 | |
111 end | |
112 | |
113 def test_disabled_ws_should_respond_with_403_error | |
114 with_settings :sys_api_enabled => '0' do | |
115 get :projects | |
116 assert_response 403 | |
117 end | |
118 end | |
119 | |
120 def test_api_key | |
121 with_settings :sys_api_key => 'my_secret_key' do | |
122 get :projects, :key => 'my_secret_key' | |
123 assert_response :success | |
124 end | |
125 end | |
126 | |
127 def test_wrong_key_should_respond_with_403_error | |
128 with_settings :sys_api_enabled => 'my_secret_key' do | |
129 get :projects, :key => 'wrong_key' | |
130 assert_response 403 | |
131 end | |
132 end | |
133 end |