##// END OF EJS Templates
Fixes functional tests....
Jean-Philippe Lang -
r1802:c77d9712ca9e
parent child
Show More
@@ -1,47 +1,47
1 1 # redMine - project management software
2 2 # Copyright (C) 2006-2007 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 class SysController < ActionController::Base
19 19 wsdl_service_name 'Sys'
20 20 web_service_api SysApi
21 21 web_service_scaffold :invoke
22 22
23 23 before_invocation :check_enabled
24 24
25 25 # Returns the projects list, with their repositories
26 26 def projects_with_repository_enabled
27 Project.repository_enabled(:all, :include => :repository)
27 Project.repository_enabled(:all, :include => :repository, :order => 'identifier')
28 28 end
29 29
30 30 # Registers a repository for the given project identifier
31 31 # (Subversion specific)
32 32 def repository_created(identifier, url)
33 33 project = Project.find_by_identifier(identifier)
34 34 # Do not create the repository if the project has already one
35 35 return 0 unless project && project.repository.nil?
36 36 logger.debug "Repository for #{project.name} was created"
37 37 repository = Repository.factory('Subversion', :project => project, :url => url)
38 38 repository.save
39 39 repository.id || 0
40 40 end
41 41
42 42 protected
43 43
44 44 def check_enabled(name, args)
45 45 Setting.sys_api_enabled?
46 46 end
47 47 end
@@ -1,31 +1,48
1 1 require File.dirname(__FILE__) + '/../test_helper'
2 2 require 'sys_controller'
3 3
4 4 # Re-raise errors caught by the controller.
5 5 class SysController; def rescue_action(e) raise e end; end
6 6
7 7 class SysControllerTest < Test::Unit::TestCase
8 fixtures :projects, :repositories
8 fixtures :projects, :enabled_modules, :repositories
9 9
10 10 def setup
11 11 @controller = SysController.new
12 12 @request = ActionController::TestRequest.new
13 13 @response = ActionController::TestResponse.new
14 14 # Enable WS
15 15 Setting.sys_api_enabled = 1
16 16 end
17 17
18 def test_projects
19 result = invoke :projects
20 assert_equal Project.count, result.size
21 assert result.first.is_a?(Project)
18 def test_projects_with_repository_enabled
19 result = invoke :projects_with_repository_enabled
20 assert_equal EnabledModule.count(:all, :conditions => {:name => 'repository'}), result.size
21
22 project = result.first
23 assert project.is_a?(AWSProjectWithRepository)
24
25 assert project.respond_to?(:id)
26 assert_equal 1, project.id
27
28 assert project.respond_to?(:identifier)
29 assert_equal 'ecookbook', project.identifier
30
31 assert project.respond_to?(:name)
32 assert_equal 'eCookbook', project.name
33
34 assert project.respond_to?(:is_public)
35 assert project.is_public
36
37 assert project.respond_to?(:repository)
38 assert project.repository.is_a?(Repository)
22 39 end
23 40
24 41 def test_repository_created
25 42 project = Project.find(3)
26 43 assert_nil project.repository
27 44 assert invoke(:repository_created, project.identifier, 'http://localhost/svn')
28 45 project.reload
29 46 assert_not_nil project.repository
30 47 end
31 48 end
General Comments 0
You need to be logged in to leave comments. Login now