mirror of
https://github.com/redmine/redmine.git
synced 2026-03-05 03:51:38 +01:00
Fixed that content_for does not work in Hook.render_on (#11105).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9785 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -35,6 +35,17 @@ class MenuManagerTest < ActionController::IntegrationTest
|
||||
end
|
||||
end
|
||||
|
||||
class ContentForInsideHook < Redmine::Hook::ViewListener
|
||||
render_on :view_welcome_index_left, :inline => <<-VIEW
|
||||
<% content_for :header_tags do %>
|
||||
<%= javascript_include_tag 'test_plugin.js', :plugin => 'test_plugin' %>
|
||||
<%= stylesheet_link_tag 'test_plugin.css', :plugin => 'test_plugin' %>
|
||||
<% end %>
|
||||
|
||||
<p>ContentForInsideHook content</p>
|
||||
VIEW
|
||||
end
|
||||
|
||||
def setup
|
||||
Redmine::Hook.clear_listeners
|
||||
end
|
||||
@@ -64,4 +75,16 @@ class MenuManagerTest < ActionController::IntegrationTest
|
||||
assert_select 'div#main'
|
||||
assert_select 'div#main.nosidebar', 0
|
||||
end
|
||||
|
||||
def test_hook_with_content_for_should_append_content
|
||||
Redmine::Hook.add_listener(ContentForInsideHook)
|
||||
|
||||
get '/'
|
||||
assert_response :success
|
||||
assert_select 'p', :text => 'ContentForInsideHook content'
|
||||
assert_select 'head' do
|
||||
assert_select 'script[src=/plugin_assets/test_plugin/javascripts/test_plugin.js]'
|
||||
assert_select 'link[href=/plugin_assets/test_plugin/stylesheets/test_plugin.css]'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -89,7 +89,7 @@ class Redmine::Hook::ManagerTest < ActionView::TestCase
|
||||
|
||||
def test_call_hook_with_context
|
||||
@hook_module.add_listener(TestHook3)
|
||||
assert_equal ['Context keys: bar, controller, foo, project, request.'],
|
||||
assert_equal ['Context keys: bar, controller, foo, hook_caller, project, request.'],
|
||||
hook_helper.call_hook(:view_layouts_base_html_head, :foo => 1, :bar => 'a')
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user