noosfero | people_block: add url_for for views (fix tests)

Bráulio Bhavamitra gitlab at gitlab.com
Tue Mar 3 19:41:04 BRT 2015


Bráulio Bhavamitra pushed to refs/heads/master at <a href="https://gitlab.com/noosfero/noosfero">Noosfero / noosfero</a>

Commits:
<a href="https://gitlab.com/noosfero/noosfero/commit/9928c540f8307c859ee7db1e043b9e56f8d4ec9f">9928c540</a> by Braulio Bhavamitra
people_block: add url_for for views (fix tests)

- - - - -


Changes:

=====================================
plugins/people_block/test/functional/people_block_plugin_profile_controller_test.rb
=====================================
--- a/plugins/people_block/test/functional/people_block_plugin_profile_controller_test.rb
+++ b/plugins/people_block/test/functional/people_block_plugin_profile_controller_test.rb
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/../test_helper'
-require File.dirname(__FILE__) + '/../../controllers/people_block_plugin_profile_controller'
+require_relative '../test_helper'
+require_relative '../../controllers/people_block_plugin_profile_controller'
 
 
 # Re-raise errors caught by the controller.

=====================================
plugins/people_block/test/unit/friends_block_test.rb
=====================================
--- a/plugins/people_block/test/unit/friends_block_test.rb
+++ b/plugins/people_block/test/unit/friends_block_test.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../test_helper'
+require_relative '../test_helper'
 
 class FriendsBlockTest < ActionView::TestCase
 

=====================================
test/test_helper.rb
=====================================
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -154,6 +154,21 @@ class ActiveSupport::TestCase
     self.class.action_view.render(*args)
   end
 
+  def url_for args = {}
+    args
+  end
+
+  # url_for inside views (partials)
+  # from http://stackoverflow.com/a/13704257/670229
+  ActionView::TestCase::TestController.instance_eval do
+    helper Noosfero::Application.routes.url_helpers
+  end
+  ActionView::TestCase::TestController.class_eval do
+    def _routes
+      Noosfero::Application.routes
+    end
+  end
+
   private
 
   def uses_host(name)
@@ -234,10 +249,6 @@ module NoosferoTestHelper
   def will_paginate(arg1, arg2)
   end
 
-  def url_for(args = {})
-    args
-  end
-
   def javascript_tag(any)
     ''
   end

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20150303/966d462b/attachment.html>


More information about the Noosfero-dev mailing list