##// END OF EJS Templates
Added request and controller objects to the hooks by default....
Added request and controller objects to the hooks by default. The request and controller objects are now added to all hook contexts by default. This will also make url_for work better in hooks by setting up the default_url_options :host, :port, and :protocol. Finally a new helper method @render_or@ has been added to ViewListener. This will let a hook easily render a partial without a full method definition. Thanks to Thomas Löber for the original patch. #2542 git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2429 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r1812:cc643ce932b2
r2368:5b7a5c39a7da
Show More
sys_api_test.rb
50 lines | 1.5 KiB | text/x-ruby | RubyLexer
require File.dirname(__FILE__) + '/../test_helper'
require 'sys_controller'
# Re-raise errors caught by the controller.
class SysController; def rescue_action(e) raise e end; end
class SysControllerTest < Test::Unit::TestCase
fixtures :projects, :enabled_modules, :repositories
def setup
@controller = SysController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
# Enable WS
Setting.sys_api_enabled = 1
end
def test_projects_with_repository_enabled
result = invoke :projects_with_repository_enabled
assert_equal EnabledModule.count(:all, :conditions => {:name => 'repository'}), result.size
project = result.first
assert project.is_a?(AWSProjectWithRepository)
assert project.respond_to?(:id)
assert_equal 1, project.id
assert project.respond_to?(:identifier)
assert_equal 'ecookbook', project.identifier
assert project.respond_to?(:name)
assert_equal 'eCookbook', project.name
assert project.respond_to?(:is_public)
assert project.is_public
assert project.respond_to?(:repository)
assert project.repository.is_a?(Repository)
end
def test_repository_created
project = Project.find(3)
assert_nil project.repository
assert invoke(:repository_created, project.identifier, 'Subversion', 'http://localhost/svn')
project.reload
assert_not_nil project.repository
assert project.repository.is_a?(Repository::Subversion)
assert_equal 'http://localhost/svn', project.repository.url
end
end