Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fixes an issue with url generation for namespaced models

  • Loading branch information...
commit 4a5c55918c475bb42ad5d222c3273710719fae45 1 parent bc226c6
Tobias Haar authored August 29, 2012
4  lib/responders/collection_responder.rb
@@ -21,10 +21,10 @@ def navigation_location
21 21
       klass = resources.last.class
22 22
 
23 23
       if klass.respond_to?(:model_name)
24  
-        resources[0...-1] << klass.model_name.plural.to_sym
  24
+        resources[0...-1] << klass.model_name.route_key.to_sym
25 25
       else
26 26
         resources
27 27
       end
28 28
     end
29 29
   end
30  
-end
  30
+end
12  test/collection_responder_test.rb
@@ -26,6 +26,10 @@ def only_symbols
26 26
   def with_location
27 27
     respond_with Address.new, :location => "given_location"
28 28
   end
  29
+
  30
+  def isolated_namespace
  31
+    respond_with MyEngine::Business.new
  32
+  end
29 33
 end
30 34
 
31 35
 class CollectionResponderTest < ActionController::TestCase
@@ -59,4 +63,10 @@ def test_collection_respects_only_symbols
59 63
     post :only_symbols
60 64
     assert_redirected_to "admin_addresses_url"
61 65
   end
62  
-end
  66
+
  67
+  def test_collection_respects_isolated_namespace
  68
+    @controller.expects(:businesses_url).returns("businesses_url")
  69
+    post :isolated_namespace
  70
+    assert_redirected_to "businesses_url"
  71
+  end
  72
+end
9  test/test_helper.rb
@@ -64,3 +64,12 @@ class Address < Model
64 64
 
65 65
 class User < Model
66 66
 end
  67
+
  68
+module MyEngine
  69
+  def self.use_relative_model_naming?
  70
+    true
  71
+  end
  72
+
  73
+  class Business < Model
  74
+  end
  75
+end

0 notes on commit 4a5c559

Please sign in to comment.
Something went wrong with that request. Please try again.