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