inherited_resources 1.5.1 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/lib/inherited_resources/version.rb +1 -1
  3. metadata +13 -218
  4. data/.gitignore +0 -1
  5. data/CHANGELOG +0 -172
  6. data/Gemfile +0 -10
  7. data/Gemfile.lock +0 -71
  8. data/Rakefile +0 -24
  9. data/inherited_resources.gemspec +0 -25
  10. data/test/aliases_test.rb +0 -146
  11. data/test/association_chain_test.rb +0 -125
  12. data/test/base_test.rb +0 -334
  13. data/test/belongs_to_test.rb +0 -130
  14. data/test/belongs_to_with_shallow_test.rb +0 -93
  15. data/test/class_methods_test.rb +0 -185
  16. data/test/customized_base_test.rb +0 -168
  17. data/test/customized_belongs_to_test.rb +0 -76
  18. data/test/customized_redirect_to_test.rb +0 -32
  19. data/test/defaults_test.rb +0 -197
  20. data/test/locales/en.yml +0 -17
  21. data/test/multiple_nested_optional_belongs_to_test.rb +0 -369
  22. data/test/nested_belongs_to_test.rb +0 -108
  23. data/test/nested_belongs_to_with_shallow_test.rb +0 -123
  24. data/test/nested_model_with_shallow_test.rb +0 -147
  25. data/test/nested_singleton_test.rb +0 -167
  26. data/test/optional_belongs_to_test.rb +0 -164
  27. data/test/polymorphic_test.rb +0 -215
  28. data/test/redirect_to_test.rb +0 -51
  29. data/test/singleton_test.rb +0 -87
  30. data/test/strong_parameters_test.rb +0 -120
  31. data/test/test_helper.rb +0 -47
  32. data/test/url_helpers_test.rb +0 -988
  33. data/test/views/address/edit.html.erb +0 -1
  34. data/test/views/address/new.html.erb +0 -1
  35. data/test/views/address/show.html.erb +0 -1
  36. data/test/views/cars/edit.html.erb +0 -1
  37. data/test/views/cars/index.html.erb +0 -1
  38. data/test/views/cars/new.html.erb +0 -1
  39. data/test/views/cars/show.html.erb +0 -1
  40. data/test/views/cities/edit.html.erb +0 -1
  41. data/test/views/cities/index.html.erb +0 -1
  42. data/test/views/cities/new.html.erb +0 -1
  43. data/test/views/cities/show.html.erb +0 -1
  44. data/test/views/comments/edit.html.erb +0 -1
  45. data/test/views/comments/index.html.erb +0 -1
  46. data/test/views/comments/new.html.erb +0 -1
  47. data/test/views/comments/show.html.erb +0 -1
  48. data/test/views/educations/new.html.erb +0 -0
  49. data/test/views/employees/edit.html.erb +0 -1
  50. data/test/views/employees/index.html.erb +0 -1
  51. data/test/views/employees/new.html.erb +0 -1
  52. data/test/views/employees/show.html.erb +0 -1
  53. data/test/views/geolocation/show.html.erb +0 -1
  54. data/test/views/groups/edit.html.erb +0 -0
  55. data/test/views/managers/edit.html.erb +0 -1
  56. data/test/views/managers/new.html.erb +0 -1
  57. data/test/views/managers/show.html.erb +0 -1
  58. data/test/views/painters/edit.html.erb +0 -1
  59. data/test/views/painters/index.html.erb +0 -1
  60. data/test/views/painters/new.html.erb +0 -1
  61. data/test/views/painters/show.html.erb +0 -1
  62. data/test/views/pets/edit.html.erb +0 -1
  63. data/test/views/pets/index.html.erb +0 -1
  64. data/test/views/pets/new.html.erb +0 -1
  65. data/test/views/pets/show.html.erb +0 -1
  66. data/test/views/photos/index.html.erb +0 -1
  67. data/test/views/plates/edit.html.erb +0 -1
  68. data/test/views/plates/index.html.erb +0 -1
  69. data/test/views/plates/new.html.erb +0 -1
  70. data/test/views/plates/show.html.erb +0 -1
  71. data/test/views/products/edit.html.erb +0 -1
  72. data/test/views/products/index.html.erb +0 -1
  73. data/test/views/products/new.html.erb +0 -1
  74. data/test/views/products/show.html.erb +0 -1
  75. data/test/views/professors/edit.html.erb +0 -1
  76. data/test/views/professors/index.html.erb +0 -1
  77. data/test/views/professors/new.html.erb +0 -1
  78. data/test/views/professors/show.html.erb +0 -1
  79. data/test/views/projects/edit.html.erb +0 -1
  80. data/test/views/projects/index.html.erb +0 -1
  81. data/test/views/projects/index.json.erb +0 -1
  82. data/test/views/projects/new.html.erb +0 -1
  83. data/test/views/projects/respond_to_skip_default_template.html.erb +0 -1
  84. data/test/views/projects/respond_with_resource.html.erb +0 -1
  85. data/test/views/projects/show.html.erb +0 -1
  86. data/test/views/students/edit.html.erb +0 -1
  87. data/test/views/students/new.html.erb +0 -1
  88. data/test/views/tags/edit.html.erb +0 -1
  89. data/test/views/tags/index.html.erb +0 -1
  90. data/test/views/tags/new.html.erb +0 -1
  91. data/test/views/tags/show.html.erb +0 -1
  92. data/test/views/trees/edit.html.erb +0 -1
  93. data/test/views/trees/index.html.erb +0 -1
  94. data/test/views/trees/new.html.erb +0 -1
  95. data/test/views/trees/show.html.erb +0 -1
  96. data/test/views/university/professors/edit.html.erb +0 -1
  97. data/test/views/university/professors/index.html.erb +0 -1
  98. data/test/views/university/professors/new.html.erb +0 -1
  99. data/test/views/university/professors/show.html.erb +0 -1
  100. data/test/views/users/create.js.erb +0 -1
  101. data/test/views/users/destroy.js.erb +0 -1
  102. data/test/views/users/edit.html.erb +0 -1
  103. data/test/views/users/index.html.erb +0 -1
  104. data/test/views/users/new.html.erb +0 -1
  105. data/test/views/users/show.html.erb +0 -1
  106. data/test/views/users/update.js.erb +0 -1
  107. data/test/views/venue/show.html.erb +0 -1
  108. data/test/views/widgets/new.html.erb +0 -0
@@ -1,164 +0,0 @@
1
- require File.expand_path('test_helper', File.dirname(__FILE__))
2
-
3
- class Brands; end
4
- class Category; end
5
-
6
- class Product
7
- def self.human_name; 'Product'; end
8
- end
9
-
10
- class ProductsController < InheritedResources::Base
11
- belongs_to :brand, :category, :polymorphic => true, :optional => true
12
- end
13
-
14
- class OptionalTest < ActionController::TestCase
15
- tests ProductsController
16
-
17
- def setup
18
- @controller.stubs(:resource_url).returns('/')
19
- @controller.stubs(:collection_url).returns('/')
20
- end
21
-
22
- def test_expose_all_products_as_instance_variable_with_category
23
- Category.expects(:find).with('37').returns(mock_category)
24
- mock_category.expects(:products).returns(Product)
25
- Product.expects(:scoped).returns([mock_product])
26
- get :index, :category_id => '37'
27
- assert_equal mock_category, assigns(:category)
28
- assert_equal [mock_product], assigns(:products)
29
- end
30
-
31
- def test_expose_all_products_as_instance_variable_without_category
32
- Product.expects(:scoped).returns([mock_product])
33
- get :index
34
- assert_equal nil, assigns(:category)
35
- assert_equal [mock_product], assigns(:products)
36
- end
37
-
38
- def test_expose_the_requested_product_with_category
39
- Category.expects(:find).with('37').returns(mock_category)
40
- mock_category.expects(:products).returns(Product)
41
- Product.expects(:find).with('42').returns(mock_product)
42
- get :show, :id => '42', :category_id => '37'
43
- assert_equal mock_category, assigns(:category)
44
- assert_equal mock_product, assigns(:product)
45
- end
46
-
47
- def test_expose_the_requested_product_without_category
48
- Product.expects(:find).with('42').returns(mock_product)
49
- get :show, :id => '42'
50
- assert_equal nil, assigns(:category)
51
- assert_equal mock_product, assigns(:product)
52
- end
53
-
54
- def test_expose_a_new_product_with_category
55
- Category.expects(:find).with('37').returns(mock_category)
56
- mock_category.expects(:products).returns(Product)
57
- Product.expects(:build).returns(mock_product)
58
- get :new, :category_id => '37'
59
- assert_equal mock_category, assigns(:category)
60
- assert_equal mock_product, assigns(:product)
61
- end
62
-
63
- def test_expose_a_new_product_without_category
64
- Product.expects(:new).returns(mock_product)
65
- get :new
66
- assert_equal nil, assigns(:category)
67
- assert_equal mock_product, assigns(:product)
68
- end
69
-
70
- def test_expose_the_requested_product_for_edition_with_category
71
- Category.expects(:find).with('37').returns(mock_category)
72
- mock_category.expects(:products).returns(Product)
73
- Product.expects(:find).with('42').returns(mock_product)
74
- get :edit, :id => '42', :category_id => '37'
75
- assert_equal mock_category, assigns(:category)
76
- assert_equal mock_product, assigns(:product)
77
- end
78
-
79
- def test_expose_the_requested_product_for_edition_without_category
80
- Product.expects(:find).with('42').returns(mock_product)
81
- get :edit, :id => '42'
82
- assert_equal nil, assigns(:category)
83
- assert_equal mock_product, assigns(:product)
84
- end
85
-
86
- def test_expose_a_newly_create_product_with_category
87
- Category.expects(:find).with('37').returns(mock_category)
88
- mock_category.expects(:products).returns(Product)
89
- Product.expects(:build).with({'these' => 'params'}).returns(mock_product(:save => true))
90
- post :create, :category_id => '37', :product => {:these => 'params'}
91
- assert_equal mock_category, assigns(:category)
92
- assert_equal mock_product, assigns(:product)
93
- end
94
-
95
- def test_expose_a_newly_create_product_without_category
96
- Product.expects(:new).with({'these' => 'params'}).returns(mock_product(:save => true))
97
- post :create, :product => {:these => 'params'}
98
- assert_equal nil, assigns(:category)
99
- assert_equal mock_product, assigns(:product)
100
- end
101
-
102
- def test_update_the_requested_object_with_category
103
- Category.expects(:find).with('37').returns(mock_category)
104
- mock_category.expects(:products).returns(Product)
105
- Product.expects(:find).with('42').returns(mock_product)
106
- mock_product.expects(:update_attributes).with({'these' => 'params'}).returns(true)
107
-
108
- put :update, :id => '42', :category_id => '37', :product => {:these => 'params'}
109
- assert_equal mock_category, assigns(:category)
110
- assert_equal mock_product, assigns(:product)
111
- end
112
-
113
- def test_update_the_requested_object_without_category
114
- Product.expects(:find).with('42').returns(mock_product)
115
- mock_product.expects(:update_attributes).with({'these' => 'params'}).returns(true)
116
-
117
- put :update, :id => '42', :product => {:these => 'params'}
118
- assert_equal nil, assigns(:category)
119
- assert_equal mock_product, assigns(:product)
120
- end
121
-
122
- def test_the_requested_product_is_destroyed_with_category
123
- Category.expects(:find).with('37').returns(mock_category)
124
- mock_category.expects(:products).returns(Product)
125
- Product.expects(:find).with('42').returns(mock_product)
126
- mock_product.expects(:destroy).returns(true)
127
- @controller.expects(:collection_url).returns('/')
128
-
129
- delete :destroy, :id => '42', :category_id => '37'
130
- assert_equal mock_category, assigns(:category)
131
- assert_equal mock_product, assigns(:product)
132
- end
133
-
134
- def test_the_requested_product_is_destroyed_without_category
135
- Product.expects(:find).with('42').returns(mock_product)
136
- mock_product.expects(:destroy).returns(true)
137
- @controller.expects(:collection_url).returns('/')
138
-
139
- delete :destroy, :id => '42'
140
- assert_equal nil, assigns(:category)
141
- assert_equal mock_product, assigns(:product)
142
- end
143
-
144
- def test_polymorphic_helpers
145
- Product.expects(:scoped).returns([mock_product])
146
- get :index
147
-
148
- assert !@controller.send(:parent?)
149
- assert_equal nil, assigns(:parent_type)
150
- assert_equal nil, @controller.send(:parent_type)
151
- assert_equal nil, @controller.send(:parent_class)
152
- assert_equal nil, assigns(:category)
153
- assert_equal nil, @controller.send(:parent)
154
- end
155
-
156
- protected
157
- def mock_category(stubs={})
158
- @mock_category ||= mock(stubs)
159
- end
160
-
161
- def mock_product(stubs={})
162
- @mock_product ||= mock(stubs)
163
- end
164
- end
@@ -1,215 +0,0 @@
1
- require File.expand_path('test_helper', File.dirname(__FILE__))
2
-
3
- class Factory; end
4
- class Company; end
5
- class User; end
6
- class Photo; end
7
-
8
- class Employee
9
- def self.human_name; 'Employee'; end
10
- end
11
-
12
- class EmployeesController < InheritedResources::Base
13
- belongs_to :factory, :company, :polymorphic => true
14
- end
15
-
16
- class PhotosController < InheritedResources::Base
17
- belongs_to :user, :task, :polymorphic => true
18
-
19
- def index
20
- parent
21
- # Overwrite index
22
- end
23
- end
24
-
25
- class PolymorphicFactoriesTest < ActionController::TestCase
26
- tests EmployeesController
27
-
28
- def setup
29
- Factory.expects(:find).with('37').returns(mock_factory)
30
- mock_factory.expects(:employees).returns(Employee)
31
-
32
- @controller.stubs(:resource_url).returns('/')
33
- @controller.stubs(:collection_url).returns('/')
34
- end
35
-
36
- def test_expose_all_employees_as_instance_variable_on_index
37
- Employee.expects(:scoped).returns([mock_employee])
38
- get :index, :factory_id => '37'
39
- assert_equal mock_factory, assigns(:factory)
40
- assert_equal [mock_employee], assigns(:employees)
41
- end
42
-
43
- def test_expose_the_requested_employee_on_show
44
- Employee.expects(:find).with('42').returns(mock_employee)
45
- get :show, :id => '42', :factory_id => '37'
46
- assert_equal mock_factory, assigns(:factory)
47
- assert_equal mock_employee, assigns(:employee)
48
- end
49
-
50
- def test_expose_a_new_employee_on_new
51
- Employee.expects(:build).returns(mock_employee)
52
- get :new, :factory_id => '37'
53
- assert_equal mock_factory, assigns(:factory)
54
- assert_equal mock_employee, assigns(:employee)
55
- end
56
-
57
- def test_expose_the_requested_employee_on_edit
58
- Employee.expects(:find).with('42').returns(mock_employee)
59
- get :edit, :id => '42', :factory_id => '37'
60
- assert_equal mock_factory, assigns(:factory)
61
- assert_equal mock_employee, assigns(:employee)
62
- assert_response :success
63
- end
64
-
65
- def test_expose_a_newly_create_employee_on_create
66
- Employee.expects(:build).with({'these' => 'params'}).returns(mock_employee(:save => true))
67
- post :create, :factory_id => '37', :employee => {:these => 'params'}
68
- assert_equal mock_factory, assigns(:factory)
69
- assert_equal mock_employee, assigns(:employee)
70
- end
71
-
72
- def test_update_the_requested_object_on_update
73
- Employee.expects(:find).with('42').returns(mock_employee)
74
- mock_employee.expects(:update_attributes).with({'these' => 'params'}).returns(true)
75
- put :update, :id => '42', :factory_id => '37', :employee => {:these => 'params'}
76
- assert_equal mock_factory, assigns(:factory)
77
- assert_equal mock_employee, assigns(:employee)
78
- end
79
-
80
- def test_the_requested_employee_is_destroyed_on_destroy
81
- Employee.expects(:find).with('42').returns(mock_employee)
82
- mock_employee.expects(:destroy)
83
- delete :destroy, :id => '42', :factory_id => '37'
84
- assert_equal mock_factory, assigns(:factory)
85
- assert_equal mock_employee, assigns(:employee)
86
- end
87
-
88
- def test_polymorphic_helpers
89
- mock_factory.stubs(:class).returns(Factory)
90
-
91
- Employee.expects(:scoped).returns([mock_employee])
92
- get :index, :factory_id => '37'
93
-
94
- assert @controller.send(:parent?)
95
- assert_equal :factory, assigns(:parent_type)
96
- assert_equal :factory, @controller.send(:parent_type)
97
- assert_equal Factory, @controller.send(:parent_class)
98
- assert_equal mock_factory, assigns(:factory)
99
- assert_equal mock_factory, @controller.send(:parent)
100
- end
101
-
102
- protected
103
- def mock_factory(stubs={})
104
- @mock_factory ||= mock(stubs)
105
- end
106
-
107
- def mock_employee(stubs={})
108
- @mock_employee ||= mock(stubs)
109
- end
110
- end
111
-
112
- class PolymorphicCompanyTest < ActionController::TestCase
113
- tests EmployeesController
114
-
115
- def setup
116
- Company.expects(:find).with('37').returns(mock_company)
117
- mock_company.expects(:employees).returns(Employee)
118
-
119
- @controller.stubs(:resource_url).returns('/')
120
- @controller.stubs(:collection_url).returns('/')
121
- end
122
-
123
- def test_expose_all_employees_as_instance_variable_on_index
124
- Employee.expects(:scoped).returns([mock_employee])
125
- get :index, :company_id => '37'
126
- assert_equal mock_company, assigns(:company)
127
- assert_equal [mock_employee], assigns(:employees)
128
- end
129
-
130
- def test_expose_the_requested_employee_on_show
131
- Employee.expects(:find).with('42').returns(mock_employee)
132
- get :show, :id => '42', :company_id => '37'
133
- assert_equal mock_company, assigns(:company)
134
- assert_equal mock_employee, assigns(:employee)
135
- end
136
-
137
- def test_expose_a_new_employee_on_new
138
- Employee.expects(:build).returns(mock_employee)
139
- get :new, :company_id => '37'
140
- assert_equal mock_company, assigns(:company)
141
- assert_equal mock_employee, assigns(:employee)
142
- end
143
-
144
- def test_expose_the_requested_employee_on_edit
145
- Employee.expects(:find).with('42').returns(mock_employee)
146
- get :edit, :id => '42', :company_id => '37'
147
- assert_equal mock_company, assigns(:company)
148
- assert_equal mock_employee, assigns(:employee)
149
- assert_response :success
150
- end
151
-
152
- def test_expose_a_newly_create_employee_on_create
153
- Employee.expects(:build).with({'these' => 'params'}).returns(mock_employee(:save => true))
154
- post :create, :company_id => '37', :employee => {:these => 'params'}
155
- assert_equal mock_company, assigns(:company)
156
- assert_equal mock_employee, assigns(:employee)
157
- end
158
-
159
- def test_update_the_requested_object_on_update
160
- Employee.expects(:find).with('42').returns(mock_employee)
161
- mock_employee.expects(:update_attributes).with({'these' => 'params'}).returns(true)
162
- put :update, :id => '42', :company_id => '37', :employee => {:these => 'params'}
163
- assert_equal mock_company, assigns(:company)
164
- assert_equal mock_employee, assigns(:employee)
165
- end
166
-
167
- def test_the_requested_employee_is_destroyed_on_destroy
168
- Employee.expects(:find).with('42').returns(mock_employee)
169
- mock_employee.expects(:destroy)
170
- delete :destroy, :id => '42', :company_id => '37'
171
- assert_equal mock_company, assigns(:company)
172
- assert_equal mock_employee, assigns(:employee)
173
- end
174
-
175
- def test_polymorphic_helpers
176
- mock_company.stubs(:class).returns(Company)
177
-
178
- Employee.expects(:scoped).returns([mock_employee])
179
- get :index, :company_id => '37'
180
-
181
- assert @controller.send(:parent?)
182
- assert_equal :company, assigns(:parent_type)
183
- assert_equal :company, @controller.send(:parent_type)
184
- assert_equal Company, @controller.send(:parent_class)
185
- assert_equal mock_company, assigns(:company)
186
- assert_equal mock_company, @controller.send(:parent)
187
- end
188
-
189
- protected
190
- def mock_company(stubs={})
191
- @mock_company ||= mock(stubs)
192
- end
193
-
194
- def mock_employee(stubs={})
195
- @mock_employee ||= mock(stubs)
196
- end
197
- end
198
-
199
- class PolymorphicPhotosTest < ActionController::TestCase
200
- tests PhotosController
201
-
202
- def setup
203
- User.expects(:find).with('37').returns(mock_user)
204
- end
205
-
206
- def test_parent_as_instance_variable_on_index_when_method_overwritten
207
- get :index, :user_id => '37'
208
- assert_equal mock_user, assigns(:user)
209
- end
210
-
211
- protected
212
- def mock_user(stubs={})
213
- @mock_user ||= mock(stubs)
214
- end
215
- end
@@ -1,51 +0,0 @@
1
- require File.expand_path('test_helper', File.dirname(__FILE__))
2
-
3
- class Machine;
4
- def self.human_name; 'Machine'; end
5
- end
6
-
7
- class MachinesController < InheritedResources::Base
8
- def create
9
- create!{ complex_url(:create, true, true) }
10
- end
11
-
12
- def update
13
- update!{ complex_url(:update, false, false) }
14
- end
15
-
16
- def destroy
17
- destroy!{ complex_url(:destroy, true, false) }
18
- end
19
-
20
- protected
21
- def complex_url(name, arg2, arg3)
22
- 'http://test.host/' + name.to_s
23
- end
24
- end
25
-
26
- class RedirectToWithBlockTest < ActionController::TestCase
27
- tests MachinesController
28
-
29
- def test_redirect_to_the_given_url_on_create
30
- Machine.stubs(:new).returns(mock_machine(:save => true))
31
- post :create
32
- assert_redirected_to 'http://test.host/create'
33
- end
34
-
35
- def test_redirect_to_the_given_url_on_update
36
- Machine.stubs(:find).returns(mock_machine(:update_attributes => true))
37
- put :update
38
- assert_redirected_to 'http://test.host/update'
39
- end
40
-
41
- def test_redirect_to_the_given_url_on_destroy
42
- Machine.stubs(:find).returns(mock_machine(:destroy => true))
43
- delete :destroy
44
- assert_redirected_to 'http://test.host/destroy'
45
- end
46
-
47
- protected
48
- def mock_machine(stubs={})
49
- @mock_machine ||= mock(stubs)
50
- end
51
- end
@@ -1,87 +0,0 @@
1
- require File.expand_path('test_helper', File.dirname(__FILE__))
2
-
3
- # This test file is instead to test the how controller flow and actions
4
- # using a belongs_to association. This is done using mocks a la rspec.
5
- #
6
- class Store
7
- extend ActiveModel::Naming
8
- end
9
-
10
- class Manager
11
- extend ActiveModel::Naming
12
- # def self.human_name; 'Manager'; end
13
- end
14
-
15
- class ManagersController < InheritedResources::Base
16
- defaults :singleton => true
17
- belongs_to :store
18
- end
19
-
20
- class SingletonTest < ActionController::TestCase
21
- tests ManagersController
22
-
23
- def setup
24
- @controller.stubs(:resource_url).returns('/')
25
- @controller.stubs(:collection_url).returns('/')
26
- end
27
-
28
- def test_expose_the_requested_manager_on_show
29
- Store.expects(:find).with('37').returns(mock_store)
30
- mock_store.expects(:manager).returns(mock_manager)
31
- get :show, :store_id => '37'
32
- assert_equal mock_store, assigns(:store)
33
- assert_equal mock_manager, assigns(:manager)
34
- end
35
-
36
- def test_expose_a_new_manager_on_new
37
- Store.expects(:find).with('37').returns(mock_store)
38
- mock_store.expects(:build_manager).returns(mock_manager)
39
- get :new, :store_id => '37'
40
- assert_equal mock_store, assigns(:store)
41
- assert_equal mock_manager, assigns(:manager)
42
- end
43
-
44
- def test_expose_the_requested_manager_on_edit
45
- Store.expects(:find).with('37').returns(mock_store)
46
- mock_store.expects(:manager).returns(mock_manager)
47
- get :edit, :store_id => '37'
48
- assert_equal mock_store, assigns(:store)
49
- assert_equal mock_manager, assigns(:manager)
50
- assert_response :success
51
- end
52
-
53
- def test_expose_a_newly_create_manager_on_create
54
- Store.expects(:find).with('37').returns(mock_store)
55
- mock_store.expects(:build_manager).with({'these' => 'params'}).returns(mock_manager(:save => true))
56
- post :create, :store_id => '37', :manager => {:these => 'params'}
57
- assert_equal mock_store, assigns(:store)
58
- assert_equal mock_manager, assigns(:manager)
59
- end
60
-
61
- def test_update_the_requested_object_on_update
62
- Store.expects(:find).with('37').returns(mock_store(:manager => mock_manager))
63
- mock_manager.expects(:update_attributes).with({'these' => 'params'}).returns(true)
64
- put :update, :store_id => '37', :manager => {:these => 'params'}
65
- assert_equal mock_store, assigns(:store)
66
- assert_equal mock_manager, assigns(:manager)
67
- end
68
-
69
- def test_the_requested_manager_is_destroyed_on_destroy
70
- Store.expects(:find).with('37').returns(mock_store)
71
- mock_store.expects(:manager).returns(mock_manager)
72
- @controller.expects(:parent_url).returns('http://test.host/')
73
- mock_manager.expects(:destroy)
74
- delete :destroy, :store_id => '37'
75
- assert_equal mock_store, assigns(:store)
76
- assert_equal mock_manager, assigns(:manager)
77
- end
78
-
79
- protected
80
- def mock_store(stubs={})
81
- @mock_store ||= mock(stubs)
82
- end
83
-
84
- def mock_manager(stubs={})
85
- @mock_manager ||= mock(stubs)
86
- end
87
- end