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