josevalim-inherited_resources 0.8.3 → 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +1 -1
- data/VERSION +1 -1
- data/lib/inherited_resources/url_helpers.rb +7 -1
- data/test/url_helpers_test.rb +46 -0
- metadata +3 -3
data/README
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.8.
|
1
|
+
0.8.4
|
@@ -44,7 +44,13 @@ module InheritedResources
|
|
44
44
|
resource_config = self.resources_configuration[:self]
|
45
45
|
|
46
46
|
# Add route_prefix if any.
|
47
|
-
|
47
|
+
unless resource_config[:route_prefix].blank?
|
48
|
+
if self.parents_symbols.include?(:polymorphic)
|
49
|
+
resource_ivars << resource_config[:route_prefix].to_s.inspect
|
50
|
+
else
|
51
|
+
resource_segments << resource_config[:route_prefix]
|
52
|
+
end
|
53
|
+
end
|
48
54
|
|
49
55
|
# Deal with belongs_to associations and polymorphic associations.
|
50
56
|
# Remember that we don't have to build the segments in polymorphic cases,
|
data/test/url_helpers_test.rb
CHANGED
@@ -39,6 +39,13 @@ class BedsController < InheritedResources::Base
|
|
39
39
|
optional_belongs_to :house, :building
|
40
40
|
end
|
41
41
|
|
42
|
+
class Desk; end
|
43
|
+
module Admin
|
44
|
+
class DesksController < InheritedResources::Base
|
45
|
+
optional_belongs_to :house
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
42
49
|
class Dish; end
|
43
50
|
class DishesController < InheritedResources::Base
|
44
51
|
belongs_to :house do
|
@@ -302,6 +309,45 @@ class UrlHelpersTest < ActiveSupport::TestCase
|
|
302
309
|
controller.send("edit_resource_url", :arg)
|
303
310
|
end
|
304
311
|
|
312
|
+
def test_url_helpers_on_namespaced_polymorphic_belongs_to
|
313
|
+
house = House.new
|
314
|
+
desk = Desk.new
|
315
|
+
|
316
|
+
new_desk = Desk.new
|
317
|
+
Desk.stubs(:new).returns(new_desk)
|
318
|
+
new_desk.stubs(:new_record?).returns(true)
|
319
|
+
|
320
|
+
controller = Admin::DesksController.new
|
321
|
+
controller.instance_variable_set('@parent_type', :house)
|
322
|
+
controller.instance_variable_set('@house', house)
|
323
|
+
controller.instance_variable_set('@desk', desk)
|
324
|
+
|
325
|
+
[:url, :path].each do |path_or_url|
|
326
|
+
controller.expects("admin_house_desks_#{path_or_url}").with(house).once
|
327
|
+
controller.send("collection_#{path_or_url}")
|
328
|
+
|
329
|
+
controller.expects("admin_house_desk_#{path_or_url}").with(house, desk).once
|
330
|
+
controller.send("resource_#{path_or_url}")
|
331
|
+
|
332
|
+
controller.expects("new_admin_house_desk_#{path_or_url}").with(house).once
|
333
|
+
controller.send("new_resource_#{path_or_url}")
|
334
|
+
|
335
|
+
controller.expects("edit_admin_house_desk_#{path_or_url}").with(house, desk).once
|
336
|
+
controller.send("edit_resource_#{path_or_url}")
|
337
|
+
end
|
338
|
+
|
339
|
+
# With options
|
340
|
+
controller.expects("admin_house_desk_url").with(house, desk, :page => 1).once
|
341
|
+
controller.send("resource_url", :page => 1)
|
342
|
+
|
343
|
+
# With args
|
344
|
+
controller.expects("polymorphic_url").with(['admin', house, :arg], {}).once
|
345
|
+
controller.send("resource_url", :arg)
|
346
|
+
|
347
|
+
controller.expects("edit_polymorphic_url").with(['admin', house, :arg], {}).once
|
348
|
+
controller.send("edit_resource_url", :arg)
|
349
|
+
end
|
350
|
+
|
305
351
|
def test_url_helpers_on_nested_polymorphic_belongs_to
|
306
352
|
house = House.new
|
307
353
|
table = Table.new
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: josevalim-inherited_resources
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Jos\xC3\xA9 Valim"
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-07-
|
12
|
+
date: 2009-07-24 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -60,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
60
|
version:
|
61
61
|
requirements: []
|
62
62
|
|
63
|
-
rubyforge_project:
|
63
|
+
rubyforge_project: inherited_resources
|
64
64
|
rubygems_version: 1.2.0
|
65
65
|
signing_key:
|
66
66
|
specification_version: 3
|