inherited_resources 1.2.2 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/test/test_helper.rb CHANGED
@@ -12,7 +12,6 @@ RAILS_ROOT = "anywhere"
12
12
  require "active_support"
13
13
  require "active_model"
14
14
  require "action_controller"
15
- require "rails/railtie"
16
15
 
17
16
  I18n.load_path << File.join(File.dirname(__FILE__), 'locales', 'en.yml')
18
17
  I18n.reload!
@@ -30,10 +29,15 @@ InheritedResources::Routes.draw do
30
29
  match ':controller(/:action(/:id))'
31
30
  match ':controller(/:action)'
32
31
  resources 'posts'
32
+ root :to => 'posts#index'
33
33
  end
34
34
 
35
35
  ActionController::Base.send :include, InheritedResources::Routes.url_helpers
36
36
 
37
+ # Add app base to load path
38
+ $:.unshift File.expand_path(File.dirname(__FILE__) + '/../app/controllers')
39
+ require 'inherited_resources/base'
40
+
37
41
  class ActiveSupport::TestCase
38
42
  setup do
39
43
  @routes = InheritedResources::Routes
@@ -125,6 +125,10 @@ end
125
125
 
126
126
  # Create a TestHelper module with some helpers
127
127
  class UrlHelpersTest < ActiveSupport::TestCase
128
+ def mock_polymorphic(controller, route)
129
+ controller.expects(:url_for).with(:no=>"no")
130
+ controller._routes.url_helpers.expects("hash_for_#{route}").returns({:no=>"no"})
131
+ end
128
132
 
129
133
  def test_url_helpers_on_simple_inherited_resource
130
134
  controller = HousesController.new
@@ -408,30 +412,30 @@ class UrlHelpersTest < ActiveSupport::TestCase
408
412
  controller.instance_variable_set('@bed', bed)
409
413
 
410
414
  [:url, :path].each do |path_or_url|
411
- controller.expects("house_beds_#{path_or_url}").with(house).once
415
+ mock_polymorphic(controller, "house_beds_#{path_or_url}").with(house).once
412
416
  controller.send("collection_#{path_or_url}")
413
417
 
414
- controller.expects("house_bed_#{path_or_url}").with(house, bed).once
418
+ mock_polymorphic(controller, "house_bed_#{path_or_url}").with(house, bed).once
415
419
  controller.send("resource_#{path_or_url}")
416
420
 
417
- controller.expects("new_house_bed_#{path_or_url}").with(house).once
421
+ mock_polymorphic(controller, "new_house_bed_#{path_or_url}").with(house).once
418
422
  controller.send("new_resource_#{path_or_url}")
419
423
 
420
- controller.expects("edit_house_bed_#{path_or_url}").with(house, bed).once
424
+ mock_polymorphic(controller, "edit_house_bed_#{path_or_url}").with(house, bed).once
421
425
  controller.send("edit_resource_#{path_or_url}")
422
426
 
423
- controller.expects("house_#{path_or_url}").with(house).once
427
+ mock_polymorphic(controller, "house_#{path_or_url}").with(house).once
424
428
  controller.send("parent_#{path_or_url}")
425
429
 
426
- controller.expects("edit_house_#{path_or_url}").with(house).once
430
+ mock_polymorphic(controller, "edit_house_#{path_or_url}").with(house).once
427
431
  controller.send("edit_parent_#{path_or_url}")
428
432
  end
429
433
 
430
434
  # With options
431
- controller.expects("house_bed_url").with(house, bed, :page => 1).once
435
+ mock_polymorphic(controller, "house_bed_url").with(house, bed, :page => 1).once
432
436
  controller.send("resource_url", :page => 1)
433
437
 
434
- controller.expects("house_url").with(house, :page => 1).once
438
+ mock_polymorphic(controller, "house_url").with(house, :page => 1).once
435
439
  controller.send("parent_url", :page => 1)
436
440
 
437
441
  # With args
@@ -462,30 +466,30 @@ class UrlHelpersTest < ActiveSupport::TestCase
462
466
  controller.instance_variable_set('@sheep', sheep)
463
467
 
464
468
  [:url, :path].each do |path_or_url|
465
- controller.expects("news_sheep_index_#{path_or_url}").with(news).once
469
+ mock_polymorphic(controller, "news_sheep_index_#{path_or_url}").with(news).once
466
470
  controller.send("collection_#{path_or_url}")
467
471
 
468
- controller.expects("news_sheep_#{path_or_url}").with(news, sheep).once
472
+ mock_polymorphic(controller, "news_sheep_#{path_or_url}").with(news, sheep).once
469
473
  controller.send("resource_#{path_or_url}")
470
474
 
471
- controller.expects("new_news_sheep_#{path_or_url}").with(news).once
475
+ mock_polymorphic(controller, "new_news_sheep_#{path_or_url}").with(news).once
472
476
  controller.send("new_resource_#{path_or_url}")
473
477
 
474
- controller.expects("edit_news_sheep_#{path_or_url}").with(news, sheep).once
478
+ mock_polymorphic(controller, "edit_news_sheep_#{path_or_url}").with(news, sheep).once
475
479
  controller.send("edit_resource_#{path_or_url}")
476
480
 
477
- controller.expects("news_#{path_or_url}").with(news).once
481
+ mock_polymorphic(controller, "news_#{path_or_url}").with(news).once
478
482
  controller.send("parent_#{path_or_url}")
479
483
 
480
- controller.expects("edit_news_#{path_or_url}").with(news).once
484
+ mock_polymorphic(controller, "edit_news_#{path_or_url}").with(news).once
481
485
  controller.send("edit_parent_#{path_or_url}")
482
486
  end
483
487
 
484
488
  # With options
485
- controller.expects("news_sheep_url").with(news, sheep, :page => 1).once
489
+ mock_polymorphic(controller, "news_sheep_url").with(news, sheep, :page => 1).once
486
490
  controller.send("resource_url", :page => 1)
487
491
 
488
- controller.expects("news_url").with(news, :page => 1).once
492
+ mock_polymorphic(controller, "news_url").with(news, :page => 1).once
489
493
  controller.send("parent_url", :page => 1)
490
494
 
491
495
  # With args
@@ -516,30 +520,30 @@ class UrlHelpersTest < ActiveSupport::TestCase
516
520
  controller.instance_variable_set('@desk', desk)
517
521
 
518
522
  [:url, :path].each do |path_or_url|
519
- controller.expects("admin_house_desks_#{path_or_url}").with(house).once
523
+ mock_polymorphic(controller, "admin_house_desks_#{path_or_url}").with(house).once
520
524
  controller.send("collection_#{path_or_url}")
521
525
 
522
- controller.expects("admin_house_desk_#{path_or_url}").with(house, desk).once
526
+ mock_polymorphic(controller, "admin_house_desk_#{path_or_url}").with(house, desk).once
523
527
  controller.send("resource_#{path_or_url}")
524
528
 
525
- controller.expects("new_admin_house_desk_#{path_or_url}").with(house).once
529
+ mock_polymorphic(controller, "new_admin_house_desk_#{path_or_url}").with(house).once
526
530
  controller.send("new_resource_#{path_or_url}")
527
531
 
528
- controller.expects("edit_admin_house_desk_#{path_or_url}").with(house, desk).once
532
+ mock_polymorphic(controller, "edit_admin_house_desk_#{path_or_url}").with(house, desk).once
529
533
  controller.send("edit_resource_#{path_or_url}")
530
534
 
531
- controller.expects("admin_house_#{path_or_url}").with(house).once
535
+ mock_polymorphic(controller, "admin_house_#{path_or_url}").with(house).once
532
536
  controller.send("parent_#{path_or_url}")
533
537
 
534
- controller.expects("edit_admin_house_#{path_or_url}").with(house).once
538
+ mock_polymorphic(controller, "edit_admin_house_#{path_or_url}").with(house).once
535
539
  controller.send("edit_parent_#{path_or_url}")
536
540
  end
537
541
 
538
542
  # With options
539
- controller.expects("admin_house_desk_url").with(house, desk, :page => 1).once
543
+ mock_polymorphic(controller, "admin_house_desk_url").with(house, desk, :page => 1).once
540
544
  controller.send("resource_url", :page => 1)
541
545
 
542
- controller.expects("admin_house_url").with(house, :page => 1).once
546
+ mock_polymorphic(controller, "admin_house_url").with(house, :page => 1).once
543
547
  controller.send("parent_url", :page => 1)
544
548
 
545
549
  # With args
@@ -572,30 +576,30 @@ class UrlHelpersTest < ActiveSupport::TestCase
572
576
  controller.instance_variable_set('@dish', dish)
573
577
 
574
578
  [:url, :path].each do |path_or_url|
575
- controller.expects("house_table_dishes_#{path_or_url}").with(house, table).once
579
+ mock_polymorphic(controller, "house_table_dishes_#{path_or_url}").with(house, table).once
576
580
  controller.send("collection_#{path_or_url}")
577
581
 
578
- controller.expects("house_table_dish_#{path_or_url}").with(house, table, dish).once
582
+ mock_polymorphic(controller, "house_table_dish_#{path_or_url}").with(house, table, dish).once
579
583
  controller.send("resource_#{path_or_url}")
580
584
 
581
- controller.expects("new_house_table_dish_#{path_or_url}").with(house, table).once
585
+ mock_polymorphic(controller, "new_house_table_dish_#{path_or_url}").with(house, table).once
582
586
  controller.send("new_resource_#{path_or_url}")
583
587
 
584
- controller.expects("edit_house_table_dish_#{path_or_url}").with(house, table, dish).once
588
+ mock_polymorphic(controller, "edit_house_table_dish_#{path_or_url}").with(house, table, dish).once
585
589
  controller.send("edit_resource_#{path_or_url}")
586
590
 
587
- controller.expects("house_table_#{path_or_url}").with(house, table).once
591
+ mock_polymorphic(controller, "house_table_#{path_or_url}").with(house, table).once
588
592
  controller.send("parent_#{path_or_url}")
589
593
 
590
- controller.expects("edit_house_table_#{path_or_url}").with(house, table).once
594
+ mock_polymorphic(controller, "edit_house_table_#{path_or_url}").with(house, table).once
591
595
  controller.send("edit_parent_#{path_or_url}")
592
596
  end
593
597
 
594
598
  # With options
595
- controller.expects("house_table_dish_url").with(house, table, dish, :page => 1).once
599
+ mock_polymorphic(controller, "house_table_dish_url").with(house, table, dish, :page => 1).once
596
600
  controller.send("resource_url", :page => 1)
597
601
 
598
- controller.expects("house_table_url").with(house, table, :page => 1).once
602
+ mock_polymorphic(controller, "house_table_url").with(house, table, :page => 1).once
599
603
  controller.send("parent_url", :page => 1)
600
604
 
601
605
  # With args
@@ -624,30 +628,30 @@ class UrlHelpersTest < ActiveSupport::TestCase
624
628
  # controller.instance_variable_set('@center', :center)
625
629
 
626
630
  [:url, :path].each do |path_or_url|
627
- controller.expects("house_table_#{path_or_url}").with(house, table).once
631
+ mock_polymorphic(controller, "house_table_#{path_or_url}").with(house, table).once
628
632
  controller.send("collection_#{path_or_url}")
629
633
 
630
- controller.expects("house_table_center_#{path_or_url}").with(house, table).once
634
+ mock_polymorphic(controller, "house_table_center_#{path_or_url}").with(house, table).once
631
635
  controller.send("resource_#{path_or_url}")
632
636
 
633
- controller.expects("new_house_table_center_#{path_or_url}").with(house, table).once
637
+ mock_polymorphic(controller, "new_house_table_center_#{path_or_url}").with(house, table).once
634
638
  controller.send("new_resource_#{path_or_url}")
635
639
 
636
- controller.expects("edit_house_table_center_#{path_or_url}").with(house, table).once
640
+ mock_polymorphic(controller, "edit_house_table_center_#{path_or_url}").with(house, table).once
637
641
  controller.send("edit_resource_#{path_or_url}")
638
642
 
639
- controller.expects("house_table_#{path_or_url}").with(house, table).once
643
+ mock_polymorphic(controller, "house_table_#{path_or_url}").with(house, table).once
640
644
  controller.send("parent_#{path_or_url}")
641
645
 
642
- controller.expects("edit_house_table_#{path_or_url}").with(house, table).once
646
+ mock_polymorphic(controller, "edit_house_table_#{path_or_url}").with(house, table).once
643
647
  controller.send("edit_parent_#{path_or_url}")
644
648
  end
645
649
 
646
650
  # With options
647
- controller.expects("house_table_center_url").with(house, table, :page => 1)
651
+ mock_polymorphic(controller, "house_table_center_url").with(house, table, :page => 1)
648
652
  controller.send("resource_url", :page => 1)
649
653
 
650
- controller.expects("house_table_url").with(house, table, :page => 1)
654
+ mock_polymorphic(controller, "house_table_url").with(house, table, :page => 1)
651
655
  controller.send("parent_url", :page => 1)
652
656
 
653
657
  # With args
@@ -669,21 +673,21 @@ class UrlHelpersTest < ActiveSupport::TestCase
669
673
  controller.instance_variable_set('@bed', bed)
670
674
 
671
675
  [:url, :path].each do |path_or_url|
672
- controller.expects("beds_#{path_or_url}").with().once
676
+ mock_polymorphic(controller, "beds_#{path_or_url}").with().once
673
677
  controller.send("collection_#{path_or_url}")
674
678
 
675
- controller.expects("bed_#{path_or_url}").with(bed).once
679
+ mock_polymorphic(controller, "bed_#{path_or_url}").with(bed).once
676
680
  controller.send("resource_#{path_or_url}")
677
681
 
678
- controller.expects("new_bed_#{path_or_url}").with().once
682
+ mock_polymorphic(controller, "new_bed_#{path_or_url}").with().once
679
683
  controller.send("new_resource_#{path_or_url}")
680
684
 
681
- controller.expects("edit_bed_#{path_or_url}").with(bed).once
685
+ mock_polymorphic(controller, "edit_bed_#{path_or_url}").with(bed).once
682
686
  controller.send("edit_resource_#{path_or_url}")
683
687
  end
684
688
 
685
689
  # With options
686
- controller.expects("bed_url").with(bed, :page => 1).once
690
+ mock_polymorphic(controller, "bed_url").with(bed, :page => 1).once
687
691
  controller.send("resource_url", :page => 1)
688
692
 
689
693
  # With args
@@ -701,7 +705,6 @@ class UrlHelpersTest < ActiveSupport::TestCase
701
705
  controller.instance_variable_set('@mirror', :mirror)
702
706
 
703
707
  [:url, :path].each do |path_or_url|
704
-
705
708
  controller.expects("house_mirrors_#{path_or_url}").with(:house, {}).once
706
709
  controller.send("collection_#{path_or_url}")
707
710
 
@@ -0,0 +1 @@
1
+ Edit HTML
@@ -0,0 +1 @@
1
+ New HTML
@@ -0,0 +1 @@
1
+ Show HTML
metadata CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
- - 2
9
- - 2
10
- version: 1.2.2
8
+ - 3
9
+ - 0
10
+ version: 1.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Jos\xC3\xA9 Valim"
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-17 00:00:00 +02:00
18
+ date: 2011-09-01 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -66,13 +66,13 @@ files:
66
66
  - MIT-LICENSE
67
67
  - README.rdoc
68
68
  - Rakefile
69
+ - app/controllers/inherited_resources/base.rb
69
70
  - inherited_resources.gemspec
70
71
  - lib/generators/rails/USAGE
71
72
  - lib/generators/rails/inherited_resources_controller_generator.rb
72
73
  - lib/generators/rails/templates/controller.rb
73
74
  - lib/inherited_resources.rb
74
75
  - lib/inherited_resources/actions.rb
75
- - lib/inherited_resources/base.rb
76
76
  - lib/inherited_resources/base_helpers.rb
77
77
  - lib/inherited_resources/belongs_to_helpers.rb
78
78
  - lib/inherited_resources/blank_slate.rb
@@ -95,6 +95,7 @@ files:
95
95
  - test/customized_redirect_to_test.rb
96
96
  - test/defaults_test.rb
97
97
  - test/locales/en.yml
98
+ - test/multiple_nested_optional_belongs_to_test.rb
98
99
  - test/nested_belongs_to_test.rb
99
100
  - test/nested_belongs_to_with_shallow_test.rb
100
101
  - test/nested_model_with_shallow_test.rb
@@ -145,10 +146,13 @@ files:
145
146
  - test/views/professors/index.html.erb
146
147
  - test/views/professors/new.html.erb
147
148
  - test/views/professors/show.html.erb
149
+ - test/views/projects/edit.html.erb
148
150
  - test/views/projects/index.html.erb
149
151
  - test/views/projects/index.json.erb
152
+ - test/views/projects/new.html.erb
150
153
  - test/views/projects/respond_to_skip_default_template.html.erb
151
154
  - test/views/projects/respond_with_resource.html.erb
155
+ - test/views/projects/show.html.erb
152
156
  - test/views/students/edit.html.erb
153
157
  - test/views/students/new.html.erb
154
158
  - test/views/tags/edit.html.erb
@@ -200,7 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
200
204
  requirements: []
201
205
 
202
206
  rubyforge_project: inherited_resources
203
- rubygems_version: 1.5.3
207
+ rubygems_version: 1.6.2
204
208
  signing_key:
205
209
  specification_version: 3
206
210
  summary: Inherited Resources speeds up development by making your controllers inherit all restful actions so you just have to focus on what is important.
@@ -216,6 +220,7 @@ test_files:
216
220
  - test/customized_redirect_to_test.rb
217
221
  - test/defaults_test.rb
218
222
  - test/locales/en.yml
223
+ - test/multiple_nested_optional_belongs_to_test.rb
219
224
  - test/nested_belongs_to_test.rb
220
225
  - test/nested_belongs_to_with_shallow_test.rb
221
226
  - test/nested_model_with_shallow_test.rb
@@ -266,10 +271,13 @@ test_files:
266
271
  - test/views/professors/index.html.erb
267
272
  - test/views/professors/new.html.erb
268
273
  - test/views/professors/show.html.erb
274
+ - test/views/projects/edit.html.erb
269
275
  - test/views/projects/index.html.erb
270
276
  - test/views/projects/index.json.erb
277
+ - test/views/projects/new.html.erb
271
278
  - test/views/projects/respond_to_skip_default_template.html.erb
272
279
  - test/views/projects/respond_with_resource.html.erb
280
+ - test/views/projects/show.html.erb
273
281
  - test/views/students/edit.html.erb
274
282
  - test/views/students/new.html.erb
275
283
  - test/views/tags/edit.html.erb