easy_admin_ui 0.4.0 → 0.5.0
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 +4 -15
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/{assets/icons → app/assets/images/easy_admin_ui}/classify.png +0 -0
- data/{assets/icons → app/assets/images/easy_admin_ui}/connect.png +0 -0
- data/{assets/icons → app/assets/images/easy_admin_ui}/delete.png +0 -0
- data/{assets/icons → app/assets/images/easy_admin_ui}/disconnect.png +0 -0
- data/{assets/icons → app/assets/images/easy_admin_ui}/pencil.png +0 -0
- data/{assets/icons → app/assets/images/easy_admin_ui}/show.png +0 -0
- data/app/assets/stylesheets/easy_admin_ui/easy_admin_ui.sass +47 -0
- data/app/views/easy_admin_ui/destroy.js.erb +1 -0
- data/{templates → app/views}/easy_admin_ui/edit.html.erb +0 -0
- data/{templates → app/views}/easy_admin_ui/index.html.erb +0 -0
- data/{templates → app/views}/easy_admin_ui/new.html.erb +0 -0
- data/{templates → app/views}/easy_admin_ui/show.html.erb +0 -0
- data/easy_admin_ui.gemspec +80 -21
- data/lib/easy_admin_ui/core_ext.rb +1 -3
- data/lib/easy_admin_ui/rails/engine.rb +10 -0
- data/lib/easy_admin_ui/tasks.rb +0 -10
- data/lib/easy_admin_ui/view_helpers.rb +3 -3
- data/lib/easy_admin_ui.rb +1 -9
- data/vendor/plugins/make_resourceful/.gitignore +1 -0
- data/vendor/plugins/make_resourceful/DEFAULTS +148 -0
- data/vendor/plugins/make_resourceful/LICENSE +7 -0
- data/vendor/plugins/make_resourceful/README.rdoc +239 -0
- data/vendor/plugins/make_resourceful/Rakefile +31 -0
- data/vendor/plugins/make_resourceful/VERSION +1 -0
- data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/resourceful_scaffold_generator.rb +87 -0
- data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/controller.rb +5 -0
- data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/fixtures.yml +10 -0
- data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/functional_test.rb +50 -0
- data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/helper.rb +2 -0
- data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/migration.rb +13 -0
- data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/model.rb +2 -0
- data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/unit_test.rb +7 -0
- data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/view__form.haml +5 -0
- data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/view_edit.haml +11 -0
- data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/view_index.haml +5 -0
- data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/view_new.haml +9 -0
- data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/view_partial.haml +12 -0
- data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/view_show.haml +14 -0
- data/vendor/plugins/make_resourceful/init.rb +3 -0
- data/vendor/plugins/make_resourceful/lib/resourceful/base.rb +63 -0
- data/vendor/plugins/make_resourceful/lib/resourceful/builder.rb +385 -0
- data/vendor/plugins/make_resourceful/lib/resourceful/default/accessors.rb +402 -0
- data/vendor/plugins/make_resourceful/lib/resourceful/default/actions.rb +101 -0
- data/vendor/plugins/make_resourceful/lib/resourceful/default/callbacks.rb +51 -0
- data/vendor/plugins/make_resourceful/lib/resourceful/default/responses.rb +118 -0
- data/vendor/plugins/make_resourceful/lib/resourceful/default/urls.rb +137 -0
- data/vendor/plugins/make_resourceful/lib/resourceful/maker.rb +84 -0
- data/vendor/plugins/make_resourceful/lib/resourceful/response.rb +33 -0
- data/vendor/plugins/make_resourceful/lib/resourceful/serialize.rb +185 -0
- data/vendor/plugins/make_resourceful/spec/accessors_spec.rb +474 -0
- data/vendor/plugins/make_resourceful/spec/actions_spec.rb +310 -0
- data/vendor/plugins/make_resourceful/spec/base_spec.rb +12 -0
- data/vendor/plugins/make_resourceful/spec/builder_spec.rb +332 -0
- data/vendor/plugins/make_resourceful/spec/callbacks_spec.rb +71 -0
- data/vendor/plugins/make_resourceful/spec/integration_spec.rb +394 -0
- data/vendor/plugins/make_resourceful/spec/maker_spec.rb +91 -0
- data/vendor/plugins/make_resourceful/spec/response_spec.rb +37 -0
- data/vendor/plugins/make_resourceful/spec/responses_spec.rb +314 -0
- data/vendor/plugins/make_resourceful/spec/rspec-rails/LICENSE +37 -0
- data/vendor/plugins/make_resourceful/spec/rspec-rails/redirect_to.rb +113 -0
- data/vendor/plugins/make_resourceful/spec/rspec-rails/render_template.rb +90 -0
- data/vendor/plugins/make_resourceful/spec/serialize_spec.rb +133 -0
- data/vendor/plugins/make_resourceful/spec/spec_helper.rb +319 -0
- data/vendor/plugins/make_resourceful/spec/urls_spec.rb +282 -0
- data/vendor/plugins/make_resourceful/spec/views/things/create.rjs +1 -0
- data/vendor/plugins/make_resourceful/spec/views/things/destroy.rjs +1 -0
- data/vendor/plugins/make_resourceful/spec/views/things/edit.html.erb +4 -0
- data/vendor/plugins/make_resourceful/spec/views/things/edit.rjs +1 -0
- data/vendor/plugins/make_resourceful/spec/views/things/index.html.erb +4 -0
- data/vendor/plugins/make_resourceful/spec/views/things/index.rjs +1 -0
- data/vendor/plugins/make_resourceful/spec/views/things/new.html.erb +4 -0
- data/vendor/plugins/make_resourceful/spec/views/things/new.rjs +1 -0
- data/vendor/plugins/make_resourceful/spec/views/things/show.html.erb +4 -0
- data/vendor/plugins/make_resourceful/spec/views/things/show.rjs +1 -0
- data/vendor/plugins/make_resourceful/spec/views/things/update.rjs +1 -0
- metadata +75 -16
- data/assets/css/easy_admin_ui.css +0 -69
@@ -0,0 +1,474 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe Resourceful::Default::Accessors, "#current_objects" do
|
4
|
+
include ControllerMocks
|
5
|
+
before :each do
|
6
|
+
mock_controller Resourceful::Default::Accessors
|
7
|
+
@objects = stub_list 5, 'object'
|
8
|
+
@model = stub
|
9
|
+
@controller.stubs(:current_model).returns(@model)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should look up all objects in the current model" do
|
13
|
+
@model.expects(:find).with(:all).returns(@objects)
|
14
|
+
@controller.current_objects.should == @objects
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should cache the result, so subsequent calls won't run multiple queries" do
|
18
|
+
@model.expects(:find).once.returns(@objects)
|
19
|
+
@controller.current_objects
|
20
|
+
@controller.current_objects
|
21
|
+
end
|
22
|
+
|
23
|
+
it "shouldn't run a query if @current_objects is set" do
|
24
|
+
@controller.instance_variable_set('@current_objects', @objects)
|
25
|
+
@model.expects(:find).never
|
26
|
+
@controller.current_objects.should == @objects
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe Resourceful::Default::Accessors, "#load_objects" do
|
31
|
+
include ControllerMocks
|
32
|
+
before :each do
|
33
|
+
mock_controller Resourceful::Default::Accessors
|
34
|
+
@objects = stub_list 5, 'object'
|
35
|
+
@controller.stubs(:current_objects).returns(@objects)
|
36
|
+
@controller.stubs(:instance_variable_name).returns("posts")
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should set the current instance variable to the object collection" do
|
40
|
+
@controller.load_objects
|
41
|
+
@controller.instance_variable_get('@posts').should == @objects
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe Resourceful::Default::Accessors, "#current_object on a plural controller" do
|
46
|
+
include ControllerMocks
|
47
|
+
before :each do
|
48
|
+
mock_controller Resourceful::Default::Accessors
|
49
|
+
@controller.stubs(:plural?).returns(true)
|
50
|
+
@controller.stubs(:params).returns(:id => "12")
|
51
|
+
|
52
|
+
@object = stub
|
53
|
+
@model = stub
|
54
|
+
@controller.stubs(:current_model).returns(@model)
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should look up the object specified by the :id parameter in the current model" do
|
58
|
+
@model.expects(:find).with('12').returns(@object)
|
59
|
+
@controller.current_object.should == @object
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should cache the result, so subsequent calls won't run multiple queries" do
|
63
|
+
@model.expects(:find).once.returns(@object)
|
64
|
+
@controller.current_object
|
65
|
+
@controller.current_object
|
66
|
+
end
|
67
|
+
|
68
|
+
it "shouldn't run a query if @current_object is set" do
|
69
|
+
@controller.instance_variable_set('@current_object', @object)
|
70
|
+
@model.expects(:find).never
|
71
|
+
@controller.current_object.should == @object
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe Resourceful::Default::Accessors, "#current_object on a singular controller" do
|
76
|
+
include ControllerMocks
|
77
|
+
before :each do
|
78
|
+
mock_controller Resourceful::Default::Accessors
|
79
|
+
@controller.stubs(:plural?).returns(false)
|
80
|
+
@controller.stubs(:controller_name).returns("posts")
|
81
|
+
|
82
|
+
@parent = stub('parent')
|
83
|
+
@controller.stubs(:parent_object).returns(@parent)
|
84
|
+
@controller.stubs(:parent?).returns(true)
|
85
|
+
|
86
|
+
@object = stub
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should return the instance object from parent object" do
|
90
|
+
@parent.expects(:post).returns(@object)
|
91
|
+
@controller.current_object.should == @object
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe Resourceful::Default::Accessors, "#load_object" do
|
96
|
+
include ControllerMocks
|
97
|
+
before :each do
|
98
|
+
mock_controller Resourceful::Default::Accessors
|
99
|
+
@object = stub
|
100
|
+
@controller.stubs(:current_object).returns(@object)
|
101
|
+
@controller.stubs(:instance_variable_name).returns("posts")
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should set the current singular instance variable to the current object" do
|
105
|
+
@controller.load_object
|
106
|
+
@controller.instance_variable_get('@post').should == @object
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe Resourceful::Default::Accessors, "#build_object with a #build-able model" do
|
111
|
+
include ControllerMocks
|
112
|
+
before :each do
|
113
|
+
mock_controller Resourceful::Default::Accessors
|
114
|
+
@params = {:name => "Bob", :password => "hideously insecure"}
|
115
|
+
@controller.stubs(:object_parameters).returns(@params)
|
116
|
+
|
117
|
+
@object = stub
|
118
|
+
@model = stub
|
119
|
+
@controller.stubs(:current_model).returns(@model)
|
120
|
+
|
121
|
+
@model.stubs(:build).returns(@object)
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should return a new object built with current_model from the object parameters" do
|
125
|
+
@model.expects(:build).with(@params).returns(@object)
|
126
|
+
@controller.build_object.should == @object
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should make current_object return the newly built object" do
|
130
|
+
@controller.build_object
|
131
|
+
@controller.current_object.should == @object
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
describe Resourceful::Default::Accessors, "#build_object with a non-#build-able model" do
|
136
|
+
include ControllerMocks
|
137
|
+
before :each do
|
138
|
+
mock_controller Resourceful::Default::Accessors
|
139
|
+
@params = {:name => "Bob", :password => "hideously insecure"}
|
140
|
+
@controller.stubs(:object_parameters).returns(@params)
|
141
|
+
|
142
|
+
@controller.stubs(:singular?).returns(false)
|
143
|
+
@controller.stubs(:parent?).returns(false)
|
144
|
+
|
145
|
+
@object = stub
|
146
|
+
@model = stub
|
147
|
+
@controller.stubs(:current_model).returns(@model)
|
148
|
+
|
149
|
+
@model.stubs(:new).returns(@object)
|
150
|
+
end
|
151
|
+
|
152
|
+
it "should return a new instance of the current_model built with the object parameters" do
|
153
|
+
@model.expects(:new).with(@params).returns(@object)
|
154
|
+
@controller.build_object.should == @object
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
describe Resourceful::Default::Accessors, "#current_model_name" do
|
159
|
+
include ControllerMocks
|
160
|
+
before :each do
|
161
|
+
mock_controller Resourceful::Default::Accessors
|
162
|
+
@controller.stubs(:controller_name).returns("funky_posts")
|
163
|
+
end
|
164
|
+
|
165
|
+
it "should return the controller's name, singularized and camel-cased" do
|
166
|
+
@controller.current_model_name.should == "FunkyPost"
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
describe Resourceful::Default::Accessors, "#namespaces" do
|
171
|
+
include ControllerMocks
|
172
|
+
before :each do
|
173
|
+
mock_controller Resourceful::Default::Accessors
|
174
|
+
@kontroller.stubs(:name).returns("FunkyStuff::Admin::Posts")
|
175
|
+
end
|
176
|
+
|
177
|
+
it "should return an array of underscored symbols representing the namespaces of the controller class" do
|
178
|
+
@controller.namespaces.should == [:funky_stuff, :admin]
|
179
|
+
end
|
180
|
+
|
181
|
+
it "should cache the result, so subsequent calls won't run multiple computations" do
|
182
|
+
@kontroller.expects(:name).once.returns("Posts")
|
183
|
+
@controller.namespaces
|
184
|
+
@controller.namespaces
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
describe Resourceful::Default::Accessors, "#instance_variable_name" do
|
189
|
+
include ControllerMocks
|
190
|
+
before :each do
|
191
|
+
mock_controller Resourceful::Default::Accessors
|
192
|
+
@controller.stubs(:controller_name).returns("posts")
|
193
|
+
end
|
194
|
+
|
195
|
+
it "should return controller_name" do
|
196
|
+
@controller.instance_variable_name == "posts"
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
describe Resourceful::Default::Accessors, "#current_model for a singular controller" do
|
201
|
+
include ControllerMocks
|
202
|
+
before :each do
|
203
|
+
mock_controller Resourceful::Default::Accessors
|
204
|
+
stub_const :Post
|
205
|
+
@controller.stubs(:singular?).returns(true)
|
206
|
+
@controller.stubs(:current_model_name).returns("Post")
|
207
|
+
|
208
|
+
@parent = stub('parent')
|
209
|
+
@controller.stubs(:parent_object).returns(@parent)
|
210
|
+
@controller.stubs(:parent?).returns(true)
|
211
|
+
end
|
212
|
+
|
213
|
+
it "should return the constant named by current_model_name" do
|
214
|
+
@controller.current_model.should == Post
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
describe Resourceful::Default::Accessors, "#current_model for a plural controller with no parent" do
|
219
|
+
include ControllerMocks
|
220
|
+
before :each do
|
221
|
+
mock_controller Resourceful::Default::Accessors
|
222
|
+
stub_const :Post
|
223
|
+
@controller.stubs(:singular?).returns(false)
|
224
|
+
@controller.stubs(:current_model_name).returns("Post")
|
225
|
+
@controller.stubs(:parent?).returns(false)
|
226
|
+
end
|
227
|
+
|
228
|
+
it "should return the constant named by current_model_name" do
|
229
|
+
@controller.current_model.should == Post
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
describe Resourceful::Default::Accessors, "#object_parameters" do
|
234
|
+
include ControllerMocks
|
235
|
+
before :each do
|
236
|
+
mock_controller Resourceful::Default::Accessors
|
237
|
+
@params = {"crazy_user" => {:name => "Hampton", :location => "Canada"}}
|
238
|
+
@controller.stubs(:params).returns(@params)
|
239
|
+
@controller.stubs(:current_model_name).returns("CrazyUser")
|
240
|
+
end
|
241
|
+
|
242
|
+
it "should return the element of the params hash with the name of the model" do
|
243
|
+
@controller.object_parameters.should == @params["crazy_user"]
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
describe Resourceful::Default::Accessors, " with two parent classes set on the controller class and one parent parameter supplied" do
|
248
|
+
include ControllerMocks
|
249
|
+
before :each do
|
250
|
+
mock_controller Resourceful::Default::Accessors
|
251
|
+
@parents = %w{post comment}
|
252
|
+
@models = @parents.map(&:camelize).map(&method(:stub_const))
|
253
|
+
@kontroller.write_inheritable_attribute(:parents, @parents)
|
254
|
+
@controller.stubs(:singular?).returns(false)
|
255
|
+
@controller.stubs(:instance_variable_name).returns('lines')
|
256
|
+
|
257
|
+
@params = HashWithIndifferentAccess.new :post_id => 12
|
258
|
+
@controller.stubs(:params).returns(@params)
|
259
|
+
|
260
|
+
@post = stub('Post')
|
261
|
+
Post.stubs(:find).returns(@post)
|
262
|
+
|
263
|
+
@model = stub
|
264
|
+
end
|
265
|
+
|
266
|
+
it "should return true for #parent?" do
|
267
|
+
@controller.parent?.should be_true
|
268
|
+
end
|
269
|
+
|
270
|
+
it "should return the string names of all the parents for #parent_names" do
|
271
|
+
@controller.parent_names.should == @parents
|
272
|
+
end
|
273
|
+
|
274
|
+
it "should return the string name of the current parent for #parent_name" do
|
275
|
+
@controller.parent_name.should == 'post'
|
276
|
+
end
|
277
|
+
|
278
|
+
it "should return the model class for #parent_model" do
|
279
|
+
@controller.parent_model.should == Post
|
280
|
+
end
|
281
|
+
|
282
|
+
it "should return the parent object for #parent_object" do
|
283
|
+
Post.expects(:find).with(12).returns(@post)
|
284
|
+
@controller.parent_object.should == @post
|
285
|
+
end
|
286
|
+
|
287
|
+
it "should cache the value of #parent_object so multiple calls won't cause multiple queries" do
|
288
|
+
Post.expects(:find).returns(@post).once
|
289
|
+
@controller.parent_object
|
290
|
+
@controller.parent_object
|
291
|
+
end
|
292
|
+
|
293
|
+
it "should bind the parent object its proper instance variable" do
|
294
|
+
@controller.load_parent_object
|
295
|
+
@controller.instance_variable_get('@post').should == @post
|
296
|
+
end
|
297
|
+
|
298
|
+
it "should return the parent-scoped model for #current_model" do
|
299
|
+
@post.stubs(:lines).returns(@model)
|
300
|
+
@controller.current_model.should == @model
|
301
|
+
end
|
302
|
+
|
303
|
+
it "should return true for #ensure_parent_exists" do
|
304
|
+
@controller.expects(:render).never
|
305
|
+
@controller.ensure_parent_exists.should be_true
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
describe Resourceful::Default::Accessors, " with two parent classes set on the controller class but no parent parameter supplied" do
|
310
|
+
include ControllerMocks
|
311
|
+
before :each do
|
312
|
+
mock_controller Resourceful::Default::Accessors
|
313
|
+
@parents = %w{post comment}
|
314
|
+
@models = @parents.map(&:camelize).map(&method(:stub_const))
|
315
|
+
@kontroller.write_inheritable_attribute(:parents, @parents)
|
316
|
+
@controller.stubs(:params).returns({})
|
317
|
+
@controller.stubs(:controller_name).returns('line')
|
318
|
+
stub_const('Line')
|
319
|
+
end
|
320
|
+
|
321
|
+
it "should return false for #parent?" do
|
322
|
+
@controller.parent?.should be_false
|
323
|
+
end
|
324
|
+
|
325
|
+
it "should return nil for #parent_name" do
|
326
|
+
@controller.parent_name.should be_nil
|
327
|
+
end
|
328
|
+
|
329
|
+
it "should return the unscoped model for #current_model" do
|
330
|
+
@controller.current_model.should == Line
|
331
|
+
end
|
332
|
+
|
333
|
+
it "should return false and render a 422 error for #ensure_parent_exists" do
|
334
|
+
@controller.expects(:render).with(has_entry(:status, 422))
|
335
|
+
@controller.ensure_parent_exists.should be_false
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
339
|
+
describe Resourceful::Default::Accessors, " with no parents" do
|
340
|
+
include ControllerMocks
|
341
|
+
before :each do
|
342
|
+
mock_controller Resourceful::Default::Accessors
|
343
|
+
@controller.stubs(:parents).returns([])
|
344
|
+
@controller.stubs(:current_model_name).returns('Line')
|
345
|
+
@controller.stubs(:params).returns({})
|
346
|
+
stub_const 'Line'
|
347
|
+
end
|
348
|
+
|
349
|
+
it "should return false for #parent?" do
|
350
|
+
@controller.parent?.should be_false
|
351
|
+
end
|
352
|
+
|
353
|
+
it "should return nil for #parent_name" do
|
354
|
+
@controller.parent_name.should be_nil
|
355
|
+
end
|
356
|
+
|
357
|
+
it "should return the unscoped model for #current_model" do
|
358
|
+
@controller.current_model.should == Line
|
359
|
+
end
|
360
|
+
end
|
361
|
+
|
362
|
+
describe Resourceful::Default::Accessors, " for a singular controller with a parent" do
|
363
|
+
include ControllerMocks
|
364
|
+
before :each do
|
365
|
+
mock_controller Resourceful::Default::Accessors
|
366
|
+
@controller.stubs(:singular?).returns(true)
|
367
|
+
|
368
|
+
@model = stub_model('Thing')
|
369
|
+
@model.send(:attr_accessor, :person_id)
|
370
|
+
@controller.stubs(:current_model).returns(@model)
|
371
|
+
|
372
|
+
@person = stub_model('Person')
|
373
|
+
@person.stubs(:id).returns 42
|
374
|
+
@controller.stubs(:parent_object).returns(@person)
|
375
|
+
@controller.stubs(:parent_name).returns('person')
|
376
|
+
@controller.stubs(:parent?).returns(true)
|
377
|
+
|
378
|
+
@controller.stubs(:object_parameters).returns :thinginess => 12, :bacon => true
|
379
|
+
end
|
380
|
+
|
381
|
+
it "should set assign the parent's id to a newly built object" do
|
382
|
+
thing = @controller.build_object
|
383
|
+
thing.thinginess.should == 12
|
384
|
+
thing.person_id.should == @person.id
|
385
|
+
end
|
386
|
+
end
|
387
|
+
|
388
|
+
describe Resourceful::Default::Accessors, "#save_succeeded!" do
|
389
|
+
include ControllerMocks
|
390
|
+
before :each do
|
391
|
+
mock_controller Resourceful::Default::Accessors
|
392
|
+
@controller.save_succeeded!
|
393
|
+
end
|
394
|
+
|
395
|
+
it "should make #save_succeeded? return true" do
|
396
|
+
@controller.save_succeeded?.should be_true
|
397
|
+
end
|
398
|
+
end
|
399
|
+
|
400
|
+
describe Resourceful::Default::Accessors, "#save_failed!" do
|
401
|
+
include ControllerMocks
|
402
|
+
before :each do
|
403
|
+
mock_controller Resourceful::Default::Accessors
|
404
|
+
@controller.save_failed!
|
405
|
+
end
|
406
|
+
|
407
|
+
it "should make #save_succeeded? return false" do
|
408
|
+
@controller.save_succeeded?.should be_false
|
409
|
+
end
|
410
|
+
end
|
411
|
+
|
412
|
+
describe Resourceful::Default::Accessors, " for a plural action" do
|
413
|
+
include ControllerMocks
|
414
|
+
before :each do
|
415
|
+
mock_controller Resourceful::Default::Accessors
|
416
|
+
@controller.stubs(:params).returns :action => "index"
|
417
|
+
end
|
418
|
+
|
419
|
+
it "should know it's a plural action" do
|
420
|
+
@controller.should be_a_plural_action
|
421
|
+
end
|
422
|
+
|
423
|
+
it "should know it's not a singular action" do
|
424
|
+
@controller.should_not be_a_singular_action
|
425
|
+
end
|
426
|
+
end
|
427
|
+
|
428
|
+
describe Resourceful::Default::Accessors, " for a singular action" do
|
429
|
+
include ControllerMocks
|
430
|
+
before :each do
|
431
|
+
mock_controller Resourceful::Default::Accessors
|
432
|
+
@controller.stubs(:params).returns :action => "show"
|
433
|
+
end
|
434
|
+
|
435
|
+
it "should know it's not a plural action" do
|
436
|
+
@controller.should_not be_a_plural_action
|
437
|
+
end
|
438
|
+
|
439
|
+
it "should know it's a singular action" do
|
440
|
+
@controller.should be_a_singular_action
|
441
|
+
end
|
442
|
+
end
|
443
|
+
|
444
|
+
describe Resourceful::Default::Accessors, " for a singular controller" do
|
445
|
+
include ControllerMocks
|
446
|
+
before :each do
|
447
|
+
mock_controller Resourceful::Default::Accessors
|
448
|
+
@controller.stubs(:instance_variable_name).returns "post"
|
449
|
+
end
|
450
|
+
|
451
|
+
it "should know it's not plural" do
|
452
|
+
@controller.should_not be_plural
|
453
|
+
end
|
454
|
+
|
455
|
+
it "should know it's singular" do
|
456
|
+
@controller.should be_singular
|
457
|
+
end
|
458
|
+
end
|
459
|
+
|
460
|
+
describe Resourceful::Default::Accessors, " for a plural controller" do
|
461
|
+
include ControllerMocks
|
462
|
+
before :each do
|
463
|
+
mock_controller Resourceful::Default::Accessors
|
464
|
+
@controller.stubs(:instance_variable_name).returns "posts"
|
465
|
+
end
|
466
|
+
|
467
|
+
it "should know it's plural" do
|
468
|
+
@controller.should be_plural
|
469
|
+
end
|
470
|
+
|
471
|
+
it "should know it's not singular" do
|
472
|
+
@controller.should_not be_singular
|
473
|
+
end
|
474
|
+
end
|