emmanuel-inherited_resources 0.9.1
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/CHANGELOG +95 -0
- data/MIT-LICENSE +20 -0
- data/README +528 -0
- data/Rakefile +37 -0
- data/VERSION +1 -0
- data/lib/inherited_resources/actions.rb +74 -0
- data/lib/inherited_resources/base.rb +42 -0
- data/lib/inherited_resources/base_helpers.rb +333 -0
- data/lib/inherited_resources/belongs_to_helpers.rb +89 -0
- data/lib/inherited_resources/class_methods.rb +334 -0
- data/lib/inherited_resources/dumb_responder.rb +20 -0
- data/lib/inherited_resources/has_scope_helpers.rb +65 -0
- data/lib/inherited_resources/legacy/respond_to.rb +151 -0
- data/lib/inherited_resources/legacy/responder.rb +181 -0
- data/lib/inherited_resources/polymorphic_helpers.rb +155 -0
- data/lib/inherited_resources/singleton_helpers.rb +95 -0
- data/lib/inherited_resources/url_helpers.rb +173 -0
- data/lib/inherited_resources.rb +23 -0
- data/test/aliases_test.rb +139 -0
- data/test/base_helpers_test.rb +76 -0
- data/test/base_test.rb +219 -0
- data/test/belongs_to_test.rb +87 -0
- data/test/class_methods_test.rb +137 -0
- data/test/customized_belongs_to_test.rb +76 -0
- data/test/defaults_test.rb +70 -0
- data/test/flash_test.rb +88 -0
- data/test/has_scope_test.rb +112 -0
- data/test/nested_belongs_to_test.rb +108 -0
- data/test/optional_belongs_to_test.rb +164 -0
- data/test/polymorphic_test.rb +186 -0
- data/test/redirect_to_test.rb +51 -0
- data/test/respond_to_test.rb +155 -0
- data/test/singleton_test.rb +83 -0
- data/test/test_helper.rb +30 -0
- data/test/url_helpers_test.rb +471 -0
- metadata +86 -0
@@ -0,0 +1,471 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
class Universe; end
|
4
|
+
class UniversesController < InheritedResources::Base
|
5
|
+
defaults :singleton => true, :route_instance_name => 'universum'
|
6
|
+
end
|
7
|
+
|
8
|
+
class House; end
|
9
|
+
class HousesController < InheritedResources::Base
|
10
|
+
end
|
11
|
+
|
12
|
+
class Backpack; end
|
13
|
+
module Admin; end
|
14
|
+
class Admin::BackpacksController < InheritedResources::Base
|
15
|
+
defaults :route_collection_name => 'tour_backpacks'
|
16
|
+
end
|
17
|
+
|
18
|
+
class Table; end
|
19
|
+
class TablesController < InheritedResources::Base
|
20
|
+
belongs_to :house
|
21
|
+
end
|
22
|
+
|
23
|
+
class RoomsController < InheritedResources::Base
|
24
|
+
belongs_to :house, :route_name => 'big_house'
|
25
|
+
end
|
26
|
+
|
27
|
+
class ChairsController < InheritedResources::Base
|
28
|
+
belongs_to :house do
|
29
|
+
belongs_to :table
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class OwnersController < InheritedResources::Base
|
34
|
+
singleton_belongs_to :house
|
35
|
+
end
|
36
|
+
|
37
|
+
class Bed; end
|
38
|
+
class BedsController < InheritedResources::Base
|
39
|
+
optional_belongs_to :house, :building
|
40
|
+
end
|
41
|
+
|
42
|
+
class Desk; end
|
43
|
+
module Admin
|
44
|
+
class DesksController < InheritedResources::Base
|
45
|
+
optional_belongs_to :house
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
class Dish; end
|
50
|
+
class DishesController < InheritedResources::Base
|
51
|
+
belongs_to :house do
|
52
|
+
polymorphic_belongs_to :table, :kitchen
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
class Center; end
|
57
|
+
class CentersController < InheritedResources::Base
|
58
|
+
acts_as_singleton!
|
59
|
+
|
60
|
+
belongs_to :house do
|
61
|
+
belongs_to :table, :kitchen, :polymorphic => true
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# Create a TestHelper module with some helpers
|
66
|
+
class UrlHelpersTest < ActiveSupport::TestCase
|
67
|
+
|
68
|
+
def test_url_helpers_on_simple_inherited_resource
|
69
|
+
controller = HousesController.new
|
70
|
+
controller.instance_variable_set('@house', :house)
|
71
|
+
|
72
|
+
[:url, :path].each do |path_or_url|
|
73
|
+
controller.expects("houses_#{path_or_url}").with({}).once
|
74
|
+
controller.send("collection_#{path_or_url}")
|
75
|
+
|
76
|
+
controller.expects("house_#{path_or_url}").with(:house, {}).once
|
77
|
+
controller.send("resource_#{path_or_url}")
|
78
|
+
|
79
|
+
controller.expects("new_house_#{path_or_url}").with({}).once
|
80
|
+
controller.send("new_resource_#{path_or_url}")
|
81
|
+
|
82
|
+
controller.expects("edit_house_#{path_or_url}").with(:house, {}).once
|
83
|
+
controller.send("edit_resource_#{path_or_url}")
|
84
|
+
|
85
|
+
# With arg
|
86
|
+
controller.expects("house_#{path_or_url}").with(:arg, {}).once
|
87
|
+
controller.send("resource_#{path_or_url}", :arg)
|
88
|
+
|
89
|
+
controller.expects("house_#{path_or_url}").with(:arg, {}).once
|
90
|
+
controller.send("resource_#{path_or_url}", :arg)
|
91
|
+
|
92
|
+
# With options
|
93
|
+
controller.expects("house_#{path_or_url}").with(:arg, :page => 1).once
|
94
|
+
controller.send("resource_#{path_or_url}", :arg, :page => 1)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_url_helpers_on_simple_inherited_namespaced_resource
|
99
|
+
controller = Admin::BackpacksController.new
|
100
|
+
controller.instance_variable_set('@backpack', :backpack)
|
101
|
+
|
102
|
+
assert_equal 'admin', controller.class.resources_configuration[:self][:route_prefix]
|
103
|
+
|
104
|
+
[:url, :path].each do |path_or_url|
|
105
|
+
controller.expects("admin_tour_backpacks_#{path_or_url}").with({}).once
|
106
|
+
controller.send("collection_#{path_or_url}")
|
107
|
+
|
108
|
+
controller.expects("admin_backpack_#{path_or_url}").with(:backpack, {}).once
|
109
|
+
controller.send("resource_#{path_or_url}")
|
110
|
+
|
111
|
+
controller.expects("new_admin_backpack_#{path_or_url}").with({}).once
|
112
|
+
controller.send("new_resource_#{path_or_url}")
|
113
|
+
|
114
|
+
controller.expects("edit_admin_backpack_#{path_or_url}").with(:backpack, {}).once
|
115
|
+
controller.send("edit_resource_#{path_or_url}")
|
116
|
+
|
117
|
+
# With arg
|
118
|
+
controller.expects("admin_backpack_#{path_or_url}").with(:arg, {}).once
|
119
|
+
controller.send("resource_#{path_or_url}", :arg)
|
120
|
+
|
121
|
+
controller.expects("admin_backpack_#{path_or_url}").with(:arg, {}).once
|
122
|
+
controller.send("resource_#{path_or_url}", :arg)
|
123
|
+
|
124
|
+
# With options
|
125
|
+
controller.expects("admin_backpack_#{path_or_url}").with(:arg, :page => 1).once
|
126
|
+
controller.send("resource_#{path_or_url}", :arg, :page => 1)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_url_helpers_on_simple_inherited_singleton_resource
|
131
|
+
controller = UniversesController.new
|
132
|
+
controller.instance_variable_set('@universe', :universe)
|
133
|
+
|
134
|
+
[:url, :path].each do |path_or_url|
|
135
|
+
controller.expects("root_#{path_or_url}").with({}).once
|
136
|
+
controller.send("collection_#{path_or_url}")
|
137
|
+
|
138
|
+
controller.expects("universum_#{path_or_url}").with({}).once
|
139
|
+
controller.send("resource_#{path_or_url}")
|
140
|
+
|
141
|
+
controller.expects("new_universum_#{path_or_url}").with({}).once
|
142
|
+
controller.send("new_resource_#{path_or_url}")
|
143
|
+
|
144
|
+
controller.expects("edit_universum_#{path_or_url}").with({}).once
|
145
|
+
controller.send("edit_resource_#{path_or_url}")
|
146
|
+
|
147
|
+
# With options
|
148
|
+
# Also tests that argument sent are not used
|
149
|
+
controller.expects("universum_#{path_or_url}").with(:page => 1).once
|
150
|
+
controller.send("resource_#{path_or_url}", :arg, :page => 1)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_url_helpers_on_belongs_to
|
155
|
+
controller = TablesController.new
|
156
|
+
controller.instance_variable_set('@house', :house)
|
157
|
+
controller.instance_variable_set('@table', :table)
|
158
|
+
|
159
|
+
[:url, :path].each do |path_or_url|
|
160
|
+
controller.expects("house_tables_#{path_or_url}").with(:house, {}).once
|
161
|
+
controller.send("collection_#{path_or_url}")
|
162
|
+
|
163
|
+
controller.expects("house_table_#{path_or_url}").with(:house, :table, {}).once
|
164
|
+
controller.send("resource_#{path_or_url}")
|
165
|
+
|
166
|
+
controller.expects("new_house_table_#{path_or_url}").with(:house, {}).once
|
167
|
+
controller.send("new_resource_#{path_or_url}")
|
168
|
+
|
169
|
+
controller.expects("edit_house_table_#{path_or_url}").with(:house, :table, {}).once
|
170
|
+
controller.send("edit_resource_#{path_or_url}")
|
171
|
+
|
172
|
+
# With arg
|
173
|
+
controller.expects("house_table_#{path_or_url}").with(:house, :arg, {}).once
|
174
|
+
controller.send("resource_#{path_or_url}", :arg)
|
175
|
+
|
176
|
+
controller.expects("edit_house_table_#{path_or_url}").with(:house, :arg, {}).once
|
177
|
+
controller.send("edit_resource_#{path_or_url}", :arg)
|
178
|
+
|
179
|
+
# With options
|
180
|
+
controller.expects("house_table_#{path_or_url}").with(:house, :arg, :page => 1).once
|
181
|
+
controller.send("resource_#{path_or_url}", :arg, :page => 1)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
def test_url_helpers_on_not_default_belongs_to
|
186
|
+
controller = RoomsController.new
|
187
|
+
controller.instance_variable_set('@house', :house)
|
188
|
+
controller.instance_variable_set('@room', :room)
|
189
|
+
|
190
|
+
[:url, :path].each do |path_or_url|
|
191
|
+
controller.expects("big_house_rooms_#{path_or_url}").with(:house, {}).once
|
192
|
+
controller.send("collection_#{path_or_url}")
|
193
|
+
|
194
|
+
controller.expects("big_house_room_#{path_or_url}").with(:house, :room, {}).once
|
195
|
+
controller.send("resource_#{path_or_url}")
|
196
|
+
|
197
|
+
controller.expects("new_big_house_room_#{path_or_url}").with(:house, {}).once
|
198
|
+
controller.send("new_resource_#{path_or_url}")
|
199
|
+
|
200
|
+
controller.expects("edit_big_house_room_#{path_or_url}").with(:house, :room, {}).once
|
201
|
+
controller.send("edit_resource_#{path_or_url}")
|
202
|
+
|
203
|
+
# With args
|
204
|
+
controller.expects("big_house_room_#{path_or_url}").with(:house, :arg, {}).once
|
205
|
+
controller.send("resource_#{path_or_url}", :arg)
|
206
|
+
|
207
|
+
controller.expects("edit_big_house_room_#{path_or_url}").with(:house, :arg, {}).once
|
208
|
+
controller.send("edit_resource_#{path_or_url}", :arg)
|
209
|
+
|
210
|
+
# With options
|
211
|
+
controller.expects("big_house_room_#{path_or_url}").with(:house, :arg, :page => 1).once
|
212
|
+
controller.send("resource_#{path_or_url}", :arg, :page => 1)
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
def test_url_helpers_on_nested_belongs_to
|
217
|
+
controller = ChairsController.new
|
218
|
+
controller.instance_variable_set('@house', :house)
|
219
|
+
controller.instance_variable_set('@table', :table)
|
220
|
+
controller.instance_variable_set('@chair', :chair)
|
221
|
+
|
222
|
+
[:url, :path].each do |path_or_url|
|
223
|
+
controller.expects("house_table_chairs_#{path_or_url}").with(:house, :table, {}).once
|
224
|
+
controller.send("collection_#{path_or_url}")
|
225
|
+
|
226
|
+
controller.expects("house_table_chair_#{path_or_url}").with(:house, :table, :chair, {}).once
|
227
|
+
controller.send("resource_#{path_or_url}")
|
228
|
+
|
229
|
+
controller.expects("new_house_table_chair_#{path_or_url}").with(:house, :table, {}).once
|
230
|
+
controller.send("new_resource_#{path_or_url}")
|
231
|
+
|
232
|
+
controller.expects("edit_house_table_chair_#{path_or_url}").with(:house, :table, :chair, {}).once
|
233
|
+
controller.send("edit_resource_#{path_or_url}")
|
234
|
+
|
235
|
+
# With args
|
236
|
+
controller.expects("edit_house_table_chair_#{path_or_url}").with(:house, :table, :arg, {}).once
|
237
|
+
controller.send("edit_resource_#{path_or_url}", :arg)
|
238
|
+
|
239
|
+
controller.expects("house_table_chair_#{path_or_url}").with(:house, :table, :arg, {}).once
|
240
|
+
controller.send("resource_#{path_or_url}", :arg)
|
241
|
+
|
242
|
+
# With options
|
243
|
+
controller.expects("edit_house_table_chair_#{path_or_url}").with(:house, :table, :arg, :page => 1).once
|
244
|
+
controller.send("edit_resource_#{path_or_url}", :arg, :page => 1)
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
def test_url_helpers_on_singletons_with_belongs_to
|
249
|
+
controller = OwnersController.new
|
250
|
+
controller.instance_variable_set('@house', :house)
|
251
|
+
controller.instance_variable_set('@owner', :owner)
|
252
|
+
|
253
|
+
[:url, :path].each do |path_or_url|
|
254
|
+
controller.expects("house_#{path_or_url}").with(:house, {}).once
|
255
|
+
controller.send("collection_#{path_or_url}")
|
256
|
+
|
257
|
+
controller.expects("house_owner_#{path_or_url}").with(:house, {}).once
|
258
|
+
controller.send("resource_#{path_or_url}")
|
259
|
+
|
260
|
+
controller.expects("new_house_owner_#{path_or_url}").with(:house, {}).once
|
261
|
+
controller.send("new_resource_#{path_or_url}")
|
262
|
+
|
263
|
+
controller.expects("edit_house_owner_#{path_or_url}").with(:house, {}).once
|
264
|
+
controller.send("edit_resource_#{path_or_url}")
|
265
|
+
|
266
|
+
# With options
|
267
|
+
# Also tests that argument sent are not used
|
268
|
+
controller.expects("house_owner_#{path_or_url}").with(:house, :page => 1).once
|
269
|
+
controller.send("resource_#{path_or_url}", :arg, :page => 1)
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
def test_url_helpers_on_polymorphic_belongs_to
|
274
|
+
house = House.new
|
275
|
+
bed = Bed.new
|
276
|
+
|
277
|
+
new_bed = Bed.new
|
278
|
+
Bed.stubs(:new).returns(new_bed)
|
279
|
+
new_bed.stubs(:new_record?).returns(true)
|
280
|
+
|
281
|
+
controller = BedsController.new
|
282
|
+
controller.instance_variable_set('@parent_type', :house)
|
283
|
+
controller.instance_variable_set('@house', house)
|
284
|
+
controller.instance_variable_set('@bed', bed)
|
285
|
+
|
286
|
+
[:url, :path].each do |path_or_url|
|
287
|
+
controller.expects("house_beds_#{path_or_url}").with(house).once
|
288
|
+
controller.send("collection_#{path_or_url}")
|
289
|
+
|
290
|
+
controller.expects("house_bed_#{path_or_url}").with(house, bed).once
|
291
|
+
controller.send("resource_#{path_or_url}")
|
292
|
+
|
293
|
+
controller.expects("new_house_bed_#{path_or_url}").with(house).once
|
294
|
+
controller.send("new_resource_#{path_or_url}")
|
295
|
+
|
296
|
+
controller.expects("edit_house_bed_#{path_or_url}").with(house, bed).once
|
297
|
+
controller.send("edit_resource_#{path_or_url}")
|
298
|
+
end
|
299
|
+
|
300
|
+
# With options
|
301
|
+
controller.expects("house_bed_url").with(house, bed, :page => 1).once
|
302
|
+
controller.send("resource_url", :page => 1)
|
303
|
+
|
304
|
+
# With args
|
305
|
+
controller.expects("polymorphic_url").with([:arg, new_bed], {}).once
|
306
|
+
controller.send("collection_url", :arg)
|
307
|
+
|
308
|
+
controller.expects("polymorphic_url").with([house, :arg], {}).once
|
309
|
+
controller.send("resource_url", :arg)
|
310
|
+
|
311
|
+
controller.expects("edit_polymorphic_url").with([house, :arg], {}).once
|
312
|
+
controller.send("edit_resource_url", :arg)
|
313
|
+
end
|
314
|
+
|
315
|
+
def test_url_helpers_on_namespaced_polymorphic_belongs_to
|
316
|
+
house = House.new
|
317
|
+
desk = Desk.new
|
318
|
+
|
319
|
+
new_desk = Desk.new
|
320
|
+
Desk.stubs(:new).returns(new_desk)
|
321
|
+
new_desk.stubs(:new_record?).returns(true)
|
322
|
+
|
323
|
+
controller = Admin::DesksController.new
|
324
|
+
controller.instance_variable_set('@parent_type', :house)
|
325
|
+
controller.instance_variable_set('@house', house)
|
326
|
+
controller.instance_variable_set('@desk', desk)
|
327
|
+
|
328
|
+
[:url, :path].each do |path_or_url|
|
329
|
+
controller.expects("admin_house_desks_#{path_or_url}").with(house).once
|
330
|
+
controller.send("collection_#{path_or_url}")
|
331
|
+
|
332
|
+
controller.expects("admin_house_desk_#{path_or_url}").with(house, desk).once
|
333
|
+
controller.send("resource_#{path_or_url}")
|
334
|
+
|
335
|
+
controller.expects("new_admin_house_desk_#{path_or_url}").with(house).once
|
336
|
+
controller.send("new_resource_#{path_or_url}")
|
337
|
+
|
338
|
+
controller.expects("edit_admin_house_desk_#{path_or_url}").with(house, desk).once
|
339
|
+
controller.send("edit_resource_#{path_or_url}")
|
340
|
+
end
|
341
|
+
|
342
|
+
# With options
|
343
|
+
controller.expects("admin_house_desk_url").with(house, desk, :page => 1).once
|
344
|
+
controller.send("resource_url", :page => 1)
|
345
|
+
|
346
|
+
# With args
|
347
|
+
controller.expects("polymorphic_url").with(['admin', :arg, new_desk], {}).once
|
348
|
+
controller.send("collection_url", :arg)
|
349
|
+
|
350
|
+
controller.expects("polymorphic_url").with(['admin', house, :arg], {}).once
|
351
|
+
controller.send("resource_url", :arg)
|
352
|
+
|
353
|
+
controller.expects("edit_polymorphic_url").with(['admin', house, :arg], {}).once
|
354
|
+
controller.send("edit_resource_url", :arg)
|
355
|
+
end
|
356
|
+
|
357
|
+
def test_url_helpers_on_nested_polymorphic_belongs_to
|
358
|
+
house = House.new
|
359
|
+
table = Table.new
|
360
|
+
dish = Dish.new
|
361
|
+
|
362
|
+
new_dish = Dish.new
|
363
|
+
Dish.stubs(:new).returns(new_dish)
|
364
|
+
new_dish.stubs(:new_record?).returns(true)
|
365
|
+
|
366
|
+
controller = DishesController.new
|
367
|
+
controller.instance_variable_set('@parent_type', :table)
|
368
|
+
controller.instance_variable_set('@house', house)
|
369
|
+
controller.instance_variable_set('@table', table)
|
370
|
+
controller.instance_variable_set('@dish', dish)
|
371
|
+
|
372
|
+
[:url, :path].each do |path_or_url|
|
373
|
+
controller.expects("house_table_dishes_#{path_or_url}").with(house, table).once
|
374
|
+
controller.send("collection_#{path_or_url}")
|
375
|
+
|
376
|
+
controller.expects("house_table_dish_#{path_or_url}").with(house, table, dish).once
|
377
|
+
controller.send("resource_#{path_or_url}")
|
378
|
+
|
379
|
+
controller.expects("new_house_table_dish_#{path_or_url}").with(house, table).once
|
380
|
+
controller.send("new_resource_#{path_or_url}")
|
381
|
+
|
382
|
+
controller.expects("edit_house_table_dish_#{path_or_url}").with(house, table, dish).once
|
383
|
+
controller.send("edit_resource_#{path_or_url}")
|
384
|
+
end
|
385
|
+
|
386
|
+
# With options
|
387
|
+
controller.expects("house_table_dish_url").with(house, table, dish, :page => 1).once
|
388
|
+
controller.send("resource_url", :page => 1)
|
389
|
+
|
390
|
+
# With args
|
391
|
+
controller.expects("polymorphic_url").with([house, table, :arg], {}).once
|
392
|
+
controller.send("resource_url", :arg)
|
393
|
+
|
394
|
+
controller.expects("edit_polymorphic_url").with([house, table, :arg], {}).once
|
395
|
+
controller.send("edit_resource_url", :arg)
|
396
|
+
end
|
397
|
+
|
398
|
+
def test_url_helpers_on_singleton_nested_polymorphic_belongs_to
|
399
|
+
# This must not be usefull in singleton controllers...
|
400
|
+
# Center.new
|
401
|
+
house = House.new
|
402
|
+
table = Table.new
|
403
|
+
|
404
|
+
controller = CentersController.new
|
405
|
+
controller.instance_variable_set('@parent_type', :table)
|
406
|
+
controller.instance_variable_set('@house', house)
|
407
|
+
controller.instance_variable_set('@table', table)
|
408
|
+
|
409
|
+
# This must not be useful in singleton controllers...
|
410
|
+
# controller.instance_variable_set('@center', :center)
|
411
|
+
|
412
|
+
[:url, :path].each do |path_or_url|
|
413
|
+
controller.expects("house_table_#{path_or_url}").with(house, table).once
|
414
|
+
controller.send("collection_#{path_or_url}")
|
415
|
+
|
416
|
+
controller.expects("house_table_center_#{path_or_url}").with(house, table).once
|
417
|
+
controller.send("resource_#{path_or_url}")
|
418
|
+
|
419
|
+
controller.expects("new_house_table_center_#{path_or_url}").with(house, table).once
|
420
|
+
controller.send("new_resource_#{path_or_url}")
|
421
|
+
|
422
|
+
controller.expects("edit_house_table_center_#{path_or_url}").with(house, table).once
|
423
|
+
controller.send("edit_resource_#{path_or_url}")
|
424
|
+
end
|
425
|
+
|
426
|
+
# With options
|
427
|
+
controller.expects("house_table_center_url").with(house, table, :page => 1)
|
428
|
+
controller.send("resource_url", :page => 1)
|
429
|
+
|
430
|
+
# With args
|
431
|
+
controller.expects("polymorphic_url").with([house, table, :center], {}).once
|
432
|
+
controller.send("resource_url", :arg)
|
433
|
+
end
|
434
|
+
|
435
|
+
def test_url_helpers_on_optional_polymorphic_belongs_to
|
436
|
+
bed = Bed.new
|
437
|
+
new_bed = Bed.new
|
438
|
+
Bed.stubs(:new).returns(new_bed)
|
439
|
+
new_bed.stubs(:new_record?).returns(true)
|
440
|
+
|
441
|
+
controller = BedsController.new
|
442
|
+
controller.instance_variable_set('@parent_type', nil)
|
443
|
+
controller.instance_variable_set('@bed', bed)
|
444
|
+
|
445
|
+
[:url, :path].each do |path_or_url|
|
446
|
+
controller.expects("beds_#{path_or_url}").with().once
|
447
|
+
controller.send("collection_#{path_or_url}")
|
448
|
+
|
449
|
+
controller.expects("bed_#{path_or_url}").with(bed).once
|
450
|
+
controller.send("resource_#{path_or_url}")
|
451
|
+
|
452
|
+
controller.expects("new_bed_#{path_or_url}").with().once
|
453
|
+
controller.send("new_resource_#{path_or_url}")
|
454
|
+
|
455
|
+
controller.expects("edit_bed_#{path_or_url}").with(bed).once
|
456
|
+
controller.send("edit_resource_#{path_or_url}")
|
457
|
+
end
|
458
|
+
|
459
|
+
# With options
|
460
|
+
controller.expects("bed_url").with(bed, :page => 1).once
|
461
|
+
controller.send("resource_url", :page => 1)
|
462
|
+
|
463
|
+
# With args
|
464
|
+
controller.expects("polymorphic_url").with([:arg], {}).once
|
465
|
+
controller.send("resource_url", :arg)
|
466
|
+
|
467
|
+
controller.expects("edit_polymorphic_url").with([:arg], {}).once
|
468
|
+
controller.send("edit_resource_url", :arg)
|
469
|
+
end
|
470
|
+
|
471
|
+
end
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: emmanuel-inherited_resources
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- "Jos\xC3\xA9 Valim"
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-08-25 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Inherited Resources speeds up development by making your controllers inherit all restful actions so you just have to focus on what is important.
|
17
|
+
email: jose.valim@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README
|
24
|
+
files:
|
25
|
+
- CHANGELOG
|
26
|
+
- MIT-LICENSE
|
27
|
+
- README
|
28
|
+
- Rakefile
|
29
|
+
- VERSION
|
30
|
+
- lib/inherited_resources.rb
|
31
|
+
- lib/inherited_resources/actions.rb
|
32
|
+
- lib/inherited_resources/base.rb
|
33
|
+
- lib/inherited_resources/base_helpers.rb
|
34
|
+
- lib/inherited_resources/belongs_to_helpers.rb
|
35
|
+
- lib/inherited_resources/class_methods.rb
|
36
|
+
- lib/inherited_resources/dumb_responder.rb
|
37
|
+
- lib/inherited_resources/has_scope_helpers.rb
|
38
|
+
- lib/inherited_resources/legacy/respond_to.rb
|
39
|
+
- lib/inherited_resources/legacy/responder.rb
|
40
|
+
- lib/inherited_resources/polymorphic_helpers.rb
|
41
|
+
- lib/inherited_resources/singleton_helpers.rb
|
42
|
+
- lib/inherited_resources/url_helpers.rb
|
43
|
+
has_rdoc: true
|
44
|
+
homepage: http://github.com/josevalim/inherited_resources
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options:
|
47
|
+
- --charset=UTF-8
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: "0"
|
55
|
+
version:
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: "0"
|
61
|
+
version:
|
62
|
+
requirements: []
|
63
|
+
|
64
|
+
rubyforge_project: inherited_resources
|
65
|
+
rubygems_version: 1.2.0
|
66
|
+
signing_key:
|
67
|
+
specification_version: 3
|
68
|
+
summary: Inherited Resources speeds up development by making your controllers inherit all restful actions so you just have to focus on what is important.
|
69
|
+
test_files:
|
70
|
+
- test/respond_to_test.rb
|
71
|
+
- test/customized_belongs_to_test.rb
|
72
|
+
- test/nested_belongs_to_test.rb
|
73
|
+
- test/base_test.rb
|
74
|
+
- test/redirect_to_test.rb
|
75
|
+
- test/has_scope_test.rb
|
76
|
+
- test/class_methods_test.rb
|
77
|
+
- test/aliases_test.rb
|
78
|
+
- test/flash_test.rb
|
79
|
+
- test/url_helpers_test.rb
|
80
|
+
- test/base_helpers_test.rb
|
81
|
+
- test/belongs_to_test.rb
|
82
|
+
- test/polymorphic_test.rb
|
83
|
+
- test/defaults_test.rb
|
84
|
+
- test/singleton_test.rb
|
85
|
+
- test/optional_belongs_to_test.rb
|
86
|
+
- test/test_helper.rb
|