karsthammer-inherited_resources 1.1.2.1 → 1.2.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.
Files changed (97) hide show
  1. data/.gitignore +1 -0
  2. data/CHANGELOG +11 -0
  3. data/Gemfile +12 -0
  4. data/Gemfile.lock +86 -0
  5. data/README.rdoc +78 -50
  6. data/Rakefile +0 -22
  7. data/karsthammer-inherited_resources.gemspec +24 -0
  8. data/lib/inherited_resources/actions.rb +4 -4
  9. data/lib/inherited_resources/base.rb +11 -10
  10. data/lib/inherited_resources/base_helpers.rb +40 -3
  11. data/lib/inherited_resources/class_methods.rb +100 -9
  12. data/lib/inherited_resources/shallow_helpers.rb +87 -0
  13. data/lib/inherited_resources/url_helpers.rb +44 -4
  14. data/lib/inherited_resources/version.rb +1 -1
  15. data/lib/karsthammer-inherited_resources.rb +7 -2
  16. data/test/base_test.rb +33 -13
  17. data/test/belongs_to_test.rb +29 -4
  18. data/test/belongs_to_with_shallow_test.rb +93 -0
  19. data/test/class_methods_test.rb +13 -11
  20. data/test/customized_belongs_to_test.rb +1 -1
  21. data/test/customized_redirect_to_test.rb +32 -0
  22. data/test/defaults_test.rb +137 -10
  23. data/test/locales/en.yml +17 -0
  24. data/test/nested_belongs_to_with_shallow_test.rb +123 -0
  25. data/test/nested_model_with_shallow_test.rb +147 -0
  26. data/test/optional_belongs_to_test.rb +3 -3
  27. data/test/polymorphic_test.rb +4 -4
  28. data/test/singleton_test.rb +4 -1
  29. data/test/test_helper.rb +4 -3
  30. data/test/url_helpers_test.rb +146 -2
  31. data/test/views/cars/edit.html.erb +1 -0
  32. data/test/views/cars/index.html.erb +1 -0
  33. data/test/views/cars/new.html.erb +1 -0
  34. data/test/views/cars/show.html.erb +1 -0
  35. data/test/views/cities/edit.html.erb +1 -0
  36. data/test/views/cities/index.html.erb +1 -0
  37. data/test/views/cities/new.html.erb +1 -0
  38. data/test/views/cities/show.html.erb +1 -0
  39. data/test/views/comments/edit.html.erb +1 -0
  40. data/test/views/comments/index.html.erb +1 -0
  41. data/test/views/comments/new.html.erb +1 -0
  42. data/test/views/comments/show.html.erb +1 -0
  43. data/test/views/educations/new.html.erb +0 -0
  44. data/test/views/employees/edit.html.erb +1 -0
  45. data/test/views/employees/index.html.erb +1 -0
  46. data/test/views/employees/new.html.erb +1 -0
  47. data/test/views/employees/show.html.erb +1 -0
  48. data/test/views/groups/edit.html.erb +0 -0
  49. data/test/views/managers/edit.html.erb +1 -0
  50. data/test/views/managers/new.html.erb +1 -0
  51. data/test/views/managers/show.html.erb +1 -0
  52. data/test/views/painters/edit.html.erb +1 -0
  53. data/test/views/painters/index.html.erb +1 -0
  54. data/test/views/painters/new.html.erb +1 -0
  55. data/test/views/painters/show.html.erb +1 -0
  56. data/test/views/pets/edit.html.erb +1 -0
  57. data/test/views/pets/index.html.erb +1 -0
  58. data/test/views/pets/new.html.erb +1 -0
  59. data/test/views/pets/show.html.erb +1 -0
  60. data/test/views/plates/edit.html.erb +1 -0
  61. data/test/views/plates/index.html.erb +1 -0
  62. data/test/views/plates/new.html.erb +1 -0
  63. data/test/views/plates/show.html.erb +1 -0
  64. data/test/views/products/edit.html.erb +1 -0
  65. data/test/views/products/index.html.erb +1 -0
  66. data/test/views/products/new.html.erb +1 -0
  67. data/test/views/products/show.html.erb +1 -0
  68. data/test/views/professors/edit.html.erb +1 -0
  69. data/test/views/professors/index.html.erb +1 -0
  70. data/test/views/professors/new.html.erb +1 -0
  71. data/test/views/professors/show.html.erb +1 -0
  72. data/test/views/projects/index.html.erb +1 -0
  73. data/test/views/projects/index.json.erb +1 -0
  74. data/test/views/projects/respond_to_skip_default_template.html.erb +1 -0
  75. data/test/views/projects/respond_with_resource.html.erb +1 -0
  76. data/test/views/students/edit.html.erb +1 -0
  77. data/test/views/students/new.html.erb +1 -0
  78. data/test/views/tags/edit.html.erb +1 -0
  79. data/test/views/tags/index.html.erb +1 -0
  80. data/test/views/tags/new.html.erb +1 -0
  81. data/test/views/tags/show.html.erb +1 -0
  82. data/test/views/trees/edit.html.erb +1 -0
  83. data/test/views/trees/index.html.erb +1 -0
  84. data/test/views/trees/new.html.erb +1 -0
  85. data/test/views/trees/show.html.erb +1 -0
  86. data/test/views/university/professors/edit.html.erb +1 -0
  87. data/test/views/university/professors/index.html.erb +1 -0
  88. data/test/views/university/professors/new.html.erb +1 -0
  89. data/test/views/university/professors/show.html.erb +1 -0
  90. data/test/views/users/create.js.erb +1 -0
  91. data/test/views/users/destroy.js.erb +1 -0
  92. data/test/views/users/edit.html.erb +1 -0
  93. data/test/views/users/index.html.erb +1 -0
  94. data/test/views/users/new.html.erb +1 -0
  95. data/test/views/users/show.html.erb +1 -0
  96. data/test/views/users/update.js.erb +1 -0
  97. metadata +178 -29
@@ -24,7 +24,7 @@ class BelongsToTest < ActionController::TestCase
24
24
  end
25
25
 
26
26
  def test_expose_all_comments_as_instance_variable_on_index
27
- Comment.expects(:all).returns([mock_comment])
27
+ Comment.expects(:scoped).returns([mock_comment])
28
28
  get :index, :post_id => '37'
29
29
  assert_equal mock_post, assigns(:post)
30
30
  assert_equal [mock_comment], assigns(:comments)
@@ -51,6 +51,14 @@ class BelongsToTest < ActionController::TestCase
51
51
  assert_equal mock_comment, assigns(:comment)
52
52
  end
53
53
 
54
+ def test_redirect_to_the_post_on_update_if_show_and_index_undefined
55
+ @controller.class.send(:actions, :all, :except => [:show, :index])
56
+ @controller.expects(:parent_url).returns('http://test.host/')
57
+ Comment.expects(:build).with({'these' => 'params'}).returns(mock_comment(:save => true))
58
+ post :create, :post_id => '37', :comment => {:these => 'params'}
59
+ assert_redirected_to 'http://test.host/'
60
+ end
61
+
54
62
  def test_expose_a_newly_create_comment_on_create
55
63
  Comment.expects(:build).with({'these' => 'params'}).returns(mock_comment(:save => true))
56
64
  post :create, :post_id => '37', :comment => {:these => 'params'}
@@ -58,6 +66,14 @@ class BelongsToTest < ActionController::TestCase
58
66
  assert_equal mock_comment, assigns(:comment)
59
67
  end
60
68
 
69
+ def test_redirect_to_the_post_on_update_if_show_and_index_undefined
70
+ @controller.class.send(:actions, :all, :except => [:show, :index])
71
+ Comment.stubs(:find).returns(mock_comment(:update_attributes => true))
72
+ @controller.expects(:parent_url).returns('http://test.host/')
73
+ put :update, :id => '42', :post_id => '37', :comment => {:these => 'params'}
74
+ assert_redirected_to 'http://test.host/'
75
+ end
76
+
61
77
  def test_update_the_requested_object_on_update
62
78
  Comment.expects(:find).with('42').returns(mock_comment)
63
79
  mock_comment.expects(:update_attributes).with({'these' => 'params'}).returns(true)
@@ -66,6 +82,15 @@ class BelongsToTest < ActionController::TestCase
66
82
  assert_equal mock_comment, assigns(:comment)
67
83
  end
68
84
 
85
+ def test_redirect_to_the_post_on_destroy_if_show_and_index_undefined
86
+ @controller.class.send(:actions, :all, :except => [:show, :index])
87
+ Comment.expects(:find).with('42').returns(mock_comment)
88
+ mock_comment.expects(:destroy)
89
+ @controller.expects(:parent_url).returns('http://test.host/')
90
+ delete :destroy, :id => '42', :post_id => '37'
91
+ assert_redirected_to 'http://test.host/'
92
+ end
93
+
69
94
  def test_the_requested_comment_is_destroyed_on_destroy
70
95
  Comment.expects(:find).with('42').returns(mock_comment)
71
96
  mock_comment.expects(:destroy)
@@ -73,15 +98,15 @@ class BelongsToTest < ActionController::TestCase
73
98
  assert_equal mock_post, assigns(:post)
74
99
  assert_equal mock_comment, assigns(:comment)
75
100
  end
76
-
101
+
77
102
  def helper_methods
78
103
  @controller.class._helpers.instance_methods.map {|m| m.to_s }
79
104
  end
80
-
105
+
81
106
  def test_helpers
82
107
  mock_post.stubs(:class).returns(Post)
83
108
 
84
- Comment.expects(:all).returns([mock_comment])
109
+ Comment.expects(:scoped).returns([mock_comment])
85
110
  get :index, :post_id => '37'
86
111
 
87
112
  assert helper_methods.include?('parent?')
@@ -0,0 +1,93 @@
1
+ require File.expand_path('test_helper', File.dirname(__FILE__))
2
+
3
+ class Post
4
+ extend ActiveModel::Naming
5
+ end
6
+
7
+ class Tag
8
+ extend ActiveModel::Naming
9
+ end
10
+
11
+ class TagsController < InheritedResources::Base
12
+ belongs_to :post, :shallow => true, :finder => :find_by_slug
13
+ end
14
+
15
+ class BelongsToWithShallowTest < ActionController::TestCase
16
+ tests TagsController
17
+
18
+ def setup
19
+ Post.expects(:find_by_slug).with('thirty_seven').returns(mock_post)
20
+ mock_post.expects(:tags).returns(Tag)
21
+
22
+ @controller.stubs(:resource_url).returns('/')
23
+ @controller.stubs(:collection_url).returns('/')
24
+ end
25
+
26
+ def test_expose_all_tags_as_instance_variable_on_index
27
+ Tag.expects(:scoped).returns([mock_tag])
28
+ get :index, :post_id => 'thirty_seven'
29
+ assert_equal mock_post, assigns(:post)
30
+ assert_equal [mock_tag], assigns(:tags)
31
+ end
32
+
33
+ def test_expose_a_new_tag_on_new
34
+ Tag.expects(:build).returns(mock_tag)
35
+ get :new, :post_id => 'thirty_seven'
36
+ assert_equal mock_post, assigns(:post)
37
+ assert_equal mock_tag, assigns(:tag)
38
+ end
39
+
40
+ def test_expose_a_newly_create_tag_on_create
41
+ Tag.expects(:build).with({'these' => 'params'}).returns(mock_tag(:save => true))
42
+ post :create, :post_id => 'thirty_seven', :tag => {:these => 'params'}
43
+ assert_equal mock_post, assigns(:post)
44
+ assert_equal mock_tag, assigns(:tag)
45
+ end
46
+
47
+ def test_expose_the_requested_tag_on_show
48
+ should_find_parents
49
+ get :show, :id => '42'
50
+ assert_equal mock_post, assigns(:post)
51
+ assert_equal mock_tag, assigns(:tag)
52
+ end
53
+
54
+ def test_expose_the_requested_tag_on_edit
55
+ should_find_parents
56
+ get :edit, :id => '42'
57
+ assert_equal mock_post, assigns(:post)
58
+ assert_equal mock_tag, assigns(:tag)
59
+ end
60
+
61
+ def test_update_the_requested_object_on_update
62
+ should_find_parents
63
+ mock_tag.expects(:update_attributes).with({'these' => 'params'}).returns(true)
64
+ put :update, :id => '42', :tag => {:these => 'params'}
65
+ assert_equal mock_post, assigns(:post)
66
+ assert_equal mock_tag, assigns(:tag)
67
+ end
68
+
69
+ def test_the_requested_tag_is_destroyed_on_destroy
70
+ should_find_parents
71
+ mock_tag.expects(:destroy)
72
+ delete :destroy, :id => '42', :post_id => '37'
73
+ assert_equal mock_post, assigns(:post)
74
+ assert_equal mock_tag, assigns(:tag)
75
+ end
76
+
77
+ protected
78
+ def should_find_parents
79
+ mock_tag.expects(:post).returns(mock_post)
80
+ mock_post.expects(:to_param).returns('thirty_seven')
81
+ Tag.expects(:find).with('42').twice.returns(mock_tag)
82
+ end
83
+
84
+ def mock_post(stubs={})
85
+ @mock_post ||= mock(stubs)
86
+ end
87
+
88
+ def mock_tag(stubs={})
89
+ @mock_tag ||= mock(stubs)
90
+ end
91
+
92
+ end
93
+
@@ -4,6 +4,7 @@ class Book; end
4
4
  class Folder; end
5
5
 
6
6
  class BooksController < InheritedResources::Base
7
+ custom_actions :collection => :search, :resource => [:delete]
7
8
  actions :index, :show
8
9
  end
9
10
 
@@ -33,9 +34,9 @@ class ActionsClassMethodTest < ActionController::TestCase
33
34
 
34
35
  def test_actions_are_undefined
35
36
  action_methods = BooksController.send(:action_methods).map(&:to_sym)
36
- assert_equal 2, action_methods.size
37
+ assert_equal 4, action_methods.size
37
38
 
38
- [:index, :show].each do |action|
39
+ [:index, :show, :delete, :search].each do |action|
39
40
  assert action_methods.include?(action)
40
41
  end
41
42
 
@@ -54,6 +55,7 @@ class ActionsClassMethodTest < ActionController::TestCase
54
55
  assert action_methods.include? action
55
56
  end
56
57
  end
58
+
57
59
  end
58
60
 
59
61
  class DefaultsClassMethodTest < ActiveSupport::TestCase
@@ -62,23 +64,23 @@ class DefaultsClassMethodTest < ActiveSupport::TestCase
62
64
  end
63
65
 
64
66
  def test_defaults_are_set
65
- assert Folder, FoldersController.send(:resource_class)
66
- assert :folder, FoldersController.send(:resources_configuration)[:self][:instance_name]
67
- assert :folders, FoldersController.send(:resources_configuration)[:self][:collection_name]
67
+ assert_equal Folder, FoldersController.send(:resource_class)
68
+ assert_equal :folder, FoldersController.send(:resources_configuration)[:self][:instance_name]
69
+ assert_equal :folders, FoldersController.send(:resources_configuration)[:self][:collection_name]
68
70
  end
69
71
 
70
72
  def test_defaults_can_be_overwriten
71
73
  BooksController.send(:defaults, :resource_class => String, :instance_name => 'string', :collection_name => 'strings')
72
74
 
73
- assert String, BooksController.send(:resource_class)
74
- assert :string, BooksController.send(:resources_configuration)[:self][:instance_name]
75
- assert :strings, BooksController.send(:resources_configuration)[:self][:collection_name]
75
+ assert_equal String, BooksController.send(:resource_class)
76
+ assert_equal :string, BooksController.send(:resources_configuration)[:self][:instance_name]
77
+ assert_equal :strings, BooksController.send(:resources_configuration)[:self][:collection_name]
76
78
 
77
79
  BooksController.send(:defaults, :class_name => 'Fixnum', :instance_name => :fixnum, :collection_name => :fixnums)
78
80
 
79
- assert String, BooksController.send(:resource_class)
80
- assert :string, BooksController.send(:resources_configuration)[:self][:instance_name]
81
- assert :strings, BooksController.send(:resources_configuration)[:self][:collection_name]
81
+ assert_equal Fixnum, BooksController.send(:resource_class)
82
+ assert_equal :fixnum, BooksController.send(:resources_configuration)[:self][:instance_name]
83
+ assert_equal :fixnums, BooksController.send(:resources_configuration)[:self][:collection_name]
82
84
  end
83
85
 
84
86
  def test_defaults_raises_invalid_key
@@ -22,7 +22,7 @@ class CustomizedBelongsToTest < ActionController::TestCase
22
22
  end
23
23
 
24
24
  def test_expose_the_requested_school_with_chosen_instance_variable_on_index
25
- Professor.stubs(:all).returns([mock_professor])
25
+ Professor.stubs(:scoped).returns([mock_professor])
26
26
  get :index, :school_title => 'nice'
27
27
  assert_equal mock_school, assigns(:great_school)
28
28
  end
@@ -0,0 +1,32 @@
1
+ require File.expand_path('test_helper', File.dirname(__FILE__))
2
+
3
+ class Post;
4
+ def self.human_name; 'Post'; end
5
+ end
6
+
7
+ class PostsController < InheritedResources::Base
8
+ actions :all, :except => [:show]
9
+ end
10
+
11
+ class RedirectToIndexWithoutShowTest < ActionController::TestCase
12
+ tests PostsController
13
+
14
+ def test_redirect_index_url_after_create
15
+ Post.stubs(:new).returns(mock_machine(:save => true))
16
+ assert !PostsController.respond_to?(:show)
17
+ post :create
18
+ assert_redirected_to 'http://test.host/posts'
19
+ end
20
+
21
+ def test_redirect_to_index_url_after_update
22
+ Post.stubs(:find).returns(mock_machine(:update_attributes => true))
23
+ assert !PostsController.respond_to?(:show)
24
+ put :update
25
+ assert_redirected_to 'http://test.host/posts'
26
+ end
27
+
28
+ protected
29
+ def mock_machine(stubs={})
30
+ @mock_machine ||= mock(stubs)
31
+ end
32
+ end
@@ -2,11 +2,16 @@ require File.expand_path('test_helper', File.dirname(__FILE__))
2
2
 
3
3
  class Malarz
4
4
  def self.human_name; 'Painter'; end
5
+
6
+ def to_param
7
+ self.slug
8
+ end
5
9
  end
6
10
 
7
11
  class PaintersController < InheritedResources::Base
8
12
  defaults :instance_name => 'malarz', :collection_name => 'malarze',
9
- :resource_class => Malarz, :route_prefix => nil
13
+ :resource_class => Malarz, :route_prefix => nil,
14
+ :finder => :find_by_slug
10
15
  end
11
16
 
12
17
  class DefaultsTest < ActionController::TestCase
@@ -18,14 +23,14 @@ class DefaultsTest < ActionController::TestCase
18
23
  end
19
24
 
20
25
  def test_expose_all_painters_as_instance_variable
21
- Malarz.expects(:all).returns([mock_painter])
26
+ Malarz.expects(:scoped).returns([mock_painter])
22
27
  get :index
23
28
  assert_equal [mock_painter], assigns(:malarze)
24
29
  end
25
30
 
26
31
  def test_expose_the_requested_painter_on_show
27
- Malarz.expects(:find).with('42').returns(mock_painter)
28
- get :show, :id => '42'
32
+ Malarz.expects(:find_by_slug).with('forty_two').returns(mock_painter)
33
+ get :show, :id => 'forty_two'
29
34
  assert_equal mock_painter, assigns(:malarz)
30
35
  end
31
36
 
@@ -36,8 +41,8 @@ class DefaultsTest < ActionController::TestCase
36
41
  end
37
42
 
38
43
  def test_expose_the_requested_painter_on_edit
39
- Malarz.expects(:find).with('42').returns(mock_painter)
40
- get :edit, :id => '42'
44
+ Malarz.expects(:find_by_slug).with('forty_two').returns(mock_painter)
45
+ get :edit, :id => 'forty_two'
41
46
  assert_response :success
42
47
  assert_equal mock_painter, assigns(:malarz)
43
48
  end
@@ -49,16 +54,16 @@ class DefaultsTest < ActionController::TestCase
49
54
  end
50
55
 
51
56
  def test_update_the_requested_object
52
- Malarz.expects(:find).with('42').returns(mock_painter)
57
+ Malarz.expects(:find_by_slug).with('forty_two').returns(mock_painter)
53
58
  mock_painter.expects(:update_attributes).with({'these' => 'params'}).returns(true)
54
- put :update, :id => '42', :malarz => {:these => 'params'}
59
+ put :update, :id => 'forty_two', :malarz => {:these => 'params'}
55
60
  assert_equal mock_painter, assigns(:malarz)
56
61
  end
57
62
 
58
63
  def test_the_requested_painter_is_destroyed
59
- Malarz.expects(:find).with('42').returns(mock_painter)
64
+ Malarz.expects(:find_by_slug).with('forty_two').returns(mock_painter)
60
65
  mock_painter.expects(:destroy)
61
- delete :destroy, :id => '42'
66
+ delete :destroy, :id => 'forty_two'
62
67
  assert_equal mock_painter, assigns(:malarz)
63
68
  end
64
69
 
@@ -68,3 +73,125 @@ class DefaultsTest < ActionController::TestCase
68
73
  end
69
74
  end
70
75
 
76
+ class Professor
77
+ def self.human_name; 'Einstein'; end
78
+ end
79
+ module University; end
80
+ class University::ProfessorsController < InheritedResources::Base
81
+ defaults :finder => :find_by_slug
82
+ end
83
+
84
+ class DefaultsNamespaceTest < ActionController::TestCase
85
+ tests University::ProfessorsController
86
+
87
+ def setup
88
+ @controller.stubs(:resource_url).returns('/')
89
+ @controller.stubs(:collection_url).returns('/')
90
+ end
91
+
92
+ def test_expose_all_professors_as_instance_variable
93
+ Professor.expects(:scoped).returns([mock_professor])
94
+ get :index
95
+ assert_equal [mock_professor], assigns(:professors)
96
+ end
97
+
98
+ def test_expose_the_requested_painter_on_show
99
+ Professor.expects(:find_by_slug).with('forty_two').returns(mock_professor)
100
+ get :show, :id => 'forty_two'
101
+ assert_equal mock_professor, assigns(:professor)
102
+ end
103
+
104
+ def test_expose_a_new_painter
105
+ Professor.expects(:new).returns(mock_professor)
106
+ get :new
107
+ assert_equal mock_professor, assigns(:professor)
108
+ end
109
+
110
+ def test_expose_the_requested_painter_on_edit
111
+ Professor.expects(:find_by_slug).with('forty_two').returns(mock_professor)
112
+ get :edit, :id => 'forty_two'
113
+ assert_response :success
114
+ assert_equal mock_professor, assigns(:professor)
115
+ end
116
+
117
+ def test_expose_a_newly_create_professor_when_saved_with_success
118
+ Professor.expects(:new).with({'these' => 'params'}).returns(mock_professor(:save => true))
119
+ post :create, :professor => {:these => 'params'}
120
+ assert_equal mock_professor, assigns(:professor)
121
+ end
122
+
123
+ def test_update_the_professor
124
+ Professor.expects(:find_by_slug).with('forty_two').returns(mock_professor)
125
+ mock_professor.expects(:update_attributes).with({'these' => 'params'}).returns(true)
126
+ put :update, :id => 'forty_two', :professor => {:these => 'params'}
127
+ assert_equal mock_professor, assigns(:professor)
128
+ end
129
+
130
+ def test_the_requested_painter_is_destroyed
131
+ Professor.expects(:find_by_slug).with('forty_two').returns(mock_professor)
132
+ mock_professor.expects(:destroy)
133
+ delete :destroy, :id => 'forty_two'
134
+ assert_equal mock_professor, assigns(:professor)
135
+ end
136
+
137
+ protected
138
+ def mock_professor(stubs={})
139
+ @mock_professor ||= mock(stubs)
140
+ end
141
+ end
142
+
143
+ class Group
144
+ end
145
+ class AdminGroup
146
+ end
147
+ module Admin; end
148
+ class Admin::Group
149
+ end
150
+ class Admin::GroupsController < InheritedResources::Base
151
+ end
152
+ class NamespacedModelForNamespacedController < ActionController::TestCase
153
+ tests Admin::GroupsController
154
+
155
+ def test_that_it_picked_the_namespaced_model
156
+ # make public so we can test it
157
+ Admin::GroupsController.send(:public, *Admin::GroupsController.protected_instance_methods)
158
+ assert_equal Admin::Group, @controller.resource_class
159
+ end
160
+ end
161
+
162
+ class Role
163
+ end
164
+ class AdminRole
165
+ end
166
+ class Admin::RolesController < InheritedResources::Base
167
+ end
168
+ class TwoPartNameModelForNamespacedController < ActionController::TestCase
169
+ tests Admin::RolesController
170
+
171
+ def test_that_it_picked_the_camelcased_model
172
+ # make public so we can test it
173
+ Admin::RolesController.send(:public, *Admin::RolesController.protected_instance_methods)
174
+ assert_equal AdminRole, @controller.resource_class
175
+ end
176
+ end
177
+
178
+ class User
179
+ end
180
+ class Admin::UsersController < InheritedResources::Base
181
+ end
182
+ class TwoPartNameModelForNamespacedController < ActionController::TestCase
183
+ tests Admin::UsersController
184
+
185
+ def setup
186
+ # make public so we can test it
187
+ Admin::UsersController.send(:public, *Admin::UsersController.protected_instance_methods)
188
+ end
189
+
190
+ def test_that_it_picked_the_camelcased_model
191
+ assert_equal User, @controller.resource_class
192
+ end
193
+
194
+ def test_that_it_got_the_rquest_params_right
195
+ assert_equal 'user', @controller.resources_configuration[:self][:request_name]
196
+ end
197
+ end