[ARVADOS] created: 768889aad2bf97586d68b52af4f2b9ccae78251e

git at public.curoverse.com git at public.curoverse.com
Sat Sep 20 21:30:18 EDT 2014


        at  768889aad2bf97586d68b52af4f2b9ccae78251e (commit)


commit 768889aad2bf97586d68b52af4f2b9ccae78251e
Author: radhika <radhika at curoverse.com>
Date:   Sat Sep 20 21:28:29 2014 -0400

    3889: update ActionController::TestCase to monkey patch GET/POST/PUT/DELETE methods

diff --git a/apps/workbench/test/test_helper.rb b/apps/workbench/test/test_helper.rb
index f7cf87f..cb3be10 100644
--- a/apps/workbench/test/test_helper.rb
+++ b/apps/workbench/test/test_helper.rb
@@ -152,6 +152,49 @@ class ApiServerForTests
   end
 end
 
+class ActionController::TestCase
+  def reset_counter
+    $counter = 0
+  end
+
+  def check_counter action
+    $counter += 1
+    if $counter > 1
+      raise "Too many actions on a single instance of ActionController::TestCase #{action}"
+    end
+  end
+
+  alias original_run_callbacks run_callbacks
+  def run_callbacks(kind, &block)
+    reset_counter
+    original_run_callbacks(kind, &block)
+  end
+
+  alias original_get get
+  def get(action, *args)
+    check_counter action
+    original_get(action, *args)
+  end
+
+  alias original_post post
+  def post(action, *args)
+    check_counter action
+    original_post(action, *args)
+  end
+
+  alias original_put put
+  def put(action, *args)
+    check_counter action
+    original_put(action, *args)
+  end
+
+  alias original_delete delete
+  def delete(action, *args)
+    check_counter action
+    original_delete(action, *args)
+  end
+end
+
 if ENV["RAILS_ENV"].eql? 'test'
   ApiServerForTests.run
 end
diff --git a/services/api/test/test_helper.rb b/services/api/test/test_helper.rb
index 72edfad..23bd901 100644
--- a/services/api/test/test_helper.rb
+++ b/services/api/test/test_helper.rb
@@ -80,6 +80,49 @@ class ActiveSupport::TestCase
   end
 end
 
+class ActionController::TestCase
+  def reset_counter
+    $counter = 0
+  end
+
+  def check_counter action
+    $counter += 1
+    if $counter > 1
+      raise "Too many actions on a single instance of ActionController::TestCase #{action}"
+    end
+  end
+
+  alias original_run_callbacks run_callbacks
+  def run_callbacks(kind, &block)
+    reset_counter
+    original_run_callbacks(kind, &block)
+  end
+
+  alias original_get get
+  def get(action, *args)
+    check_counter action
+    original_get(action, *args)
+  end
+
+  alias original_post post
+  def post(action, *args)
+    check_counter action
+    original_post(action, *args)
+  end
+
+  alias original_put put
+  def put(action, *args)
+    check_counter action
+    original_put(action, *args)
+  end
+
+  alias original_delete delete
+  def delete(action, *args)
+    check_counter action
+    original_delete(action, *args)
+  end
+end
+
 class ActionDispatch::IntegrationTest
   teardown do
     Thread.current[:api_client_ip_address] = nil

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list