]> source.dussan.org Git - redmine.git/commitdiff
Adds a test for default context of controller hooks (#16930).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 13 Sep 2014 11:09:01 +0000 (11:09 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 13 Sep 2014 11:09:01 +0000 (11:09 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@13394 e93f8b46-1217-0410-a6f0-8f06a7374b81

test/integration/lib/redmine/hook_test.rb

index e7f4d1d138763f13a1ac99ae98b0cec43876dedf..425e9610ec15bd6b2377bf5b8bcb90b36e6dd7a6 100644 (file)
@@ -45,6 +45,15 @@ class HookTest < ActionController::IntegrationTest
 VIEW
   end
 
+  # Hooks that stores the call context
+  class ContextTestHook < Redmine::Hook::ViewListener
+    cattr_accessor :context
+
+    def controller_account_success_authentication_after(context)
+      self.class.context = context
+    end
+  end
+
   def setup
     Redmine::Hook.clear_listeners
   end
@@ -86,4 +95,14 @@ VIEW
       assert_select 'link[href=/plugin_assets/test_plugin/stylesheets/test_plugin.css]'
     end
   end
+
+  def test_controller_hook_context_should_include_request
+    Redmine::Hook.add_listener(ContextTestHook)
+    post '/login', :username => 'admin', :password => 'admin'
+    assert_not_nil ContextTestHook.context
+    context = ContextTestHook.context
+    assert_kind_of ActionDispatch::Request, context[:request]
+    assert_kind_of Hash, context[:request].params
+    assert_kind_of AccountController, context[:hook_caller]
+  end
 end