make_resourceful_rails2 1.0.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/Rakefile +31 -0
- data/VERSION +1 -0
- data/lib/make_resourceful.rb +2 -0
- data/lib/resourceful/base.rb +63 -0
- data/lib/resourceful/builder.rb +405 -0
- data/lib/resourceful/default/accessors.rb +418 -0
- data/lib/resourceful/default/actions.rb +101 -0
- data/lib/resourceful/default/callbacks.rb +51 -0
- data/lib/resourceful/default/responses.rb +118 -0
- data/lib/resourceful/default/urls.rb +136 -0
- data/lib/resourceful/generators/resourceful_scaffold/resourceful_scaffold_generator.rb +87 -0
- data/lib/resourceful/generators/resourceful_scaffold/templates/controller.rb +5 -0
- data/lib/resourceful/generators/resourceful_scaffold/templates/fixtures.yml +10 -0
- data/lib/resourceful/generators/resourceful_scaffold/templates/functional_test.rb +50 -0
- data/lib/resourceful/generators/resourceful_scaffold/templates/helper.rb +2 -0
- data/lib/resourceful/generators/resourceful_scaffold/templates/migration.rb +13 -0
- data/lib/resourceful/generators/resourceful_scaffold/templates/model.rb +2 -0
- data/lib/resourceful/generators/resourceful_scaffold/templates/unit_test.rb +7 -0
- data/lib/resourceful/generators/resourceful_scaffold/templates/view__form.haml +5 -0
- data/lib/resourceful/generators/resourceful_scaffold/templates/view_edit.haml +11 -0
- data/lib/resourceful/generators/resourceful_scaffold/templates/view_index.haml +5 -0
- data/lib/resourceful/generators/resourceful_scaffold/templates/view_new.haml +9 -0
- data/lib/resourceful/generators/resourceful_scaffold/templates/view_partial.haml +12 -0
- data/lib/resourceful/generators/resourceful_scaffold/templates/view_show.haml +14 -0
- data/lib/resourceful/maker.rb +92 -0
- data/lib/resourceful/response.rb +33 -0
- data/lib/resourceful/serialize.rb +185 -0
- data/spec/accessors_spec.rb +474 -0
- data/spec/actions_spec.rb +310 -0
- data/spec/base_spec.rb +12 -0
- data/spec/builder_spec.rb +332 -0
- data/spec/callbacks_spec.rb +71 -0
- data/spec/integration_spec.rb +394 -0
- data/spec/maker_spec.rb +91 -0
- data/spec/response_spec.rb +37 -0
- data/spec/responses_spec.rb +314 -0
- data/spec/serialize_spec.rb +133 -0
- data/spec/urls_spec.rb +282 -0
- metadata +114 -0
data/spec/urls_spec.rb
ADDED
@@ -0,0 +1,282 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe Resourceful::Default::URLs, " for a controller with no parents or namespaces" do
|
4
|
+
include ControllerMocks
|
5
|
+
before :each do
|
6
|
+
mock_controller Resourceful::Default::URLs
|
7
|
+
@object = stub_model('Thing')
|
8
|
+
@controller.stubs(:current_object).returns(@object)
|
9
|
+
|
10
|
+
@controller.stubs(:current_model_name).returns('Thing')
|
11
|
+
@controller.stubs(:parent?).returns(false)
|
12
|
+
@controller.stubs(:namespaces).returns([])
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should return nil for #url_helper_prefix" do
|
16
|
+
@controller.url_helper_prefix.should be_nil
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should return the empty string for #collection_url_prefix" do
|
20
|
+
@controller.collection_url_prefix.should == ""
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should get the path of current_object with #object_path" do
|
24
|
+
@controller.expects(:send).with('thing_path', @object)
|
25
|
+
@controller.object_path
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should get the url of current_object with #object_url" do
|
29
|
+
@controller.expects(:send).with('thing_url', @object)
|
30
|
+
@controller.object_url
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should get the path of the passed object with #object_path" do
|
34
|
+
model = stub_model('Thing')
|
35
|
+
@controller.expects(:send).with('thing_path', model)
|
36
|
+
@controller.object_path(model)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should get the url of the passed object with #object_url" do
|
40
|
+
model = stub_model('Thing')
|
41
|
+
@controller.expects(:send).with('thing_url', model)
|
42
|
+
@controller.object_url(model)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should get the path of current_object with #nested_object_path" do
|
46
|
+
@controller.expects(:send).with('thing_path', @object)
|
47
|
+
@controller.nested_object_path
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should get the url of current_object with #nested_object_url" do
|
51
|
+
@controller.expects(:send).with('thing_url', @object)
|
52
|
+
@controller.nested_object_url
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should get the path of the passed object with #nested_object_path" do
|
56
|
+
model = stub_model('Thing')
|
57
|
+
@controller.expects(:send).with('thing_path', model)
|
58
|
+
@controller.nested_object_path(model)
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should get the url of the passed object with #nested_object_url" do
|
62
|
+
model = stub_model('Thing')
|
63
|
+
@controller.expects(:send).with('thing_url', model)
|
64
|
+
@controller.nested_object_url(model)
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should get the edit path of current_object with #edit_object_path" do
|
68
|
+
@controller.expects(:send).with('edit_thing_path', @object)
|
69
|
+
@controller.edit_object_path
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should get the edit url of current_object with #edit_object_url" do
|
73
|
+
@controller.expects(:send).with('edit_thing_url', @object)
|
74
|
+
@controller.edit_object_url
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should get the edit path of the passed object with #edit_object_path" do
|
78
|
+
model = stub_model('Thing')
|
79
|
+
@controller.expects(:send).with('edit_thing_path', model)
|
80
|
+
@controller.edit_object_path(model)
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should get the edit url of the passed object with #edit_object_url" do
|
84
|
+
model = stub_model('Thing')
|
85
|
+
@controller.expects(:send).with('edit_thing_url', model)
|
86
|
+
@controller.edit_object_url(model)
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should get the plural path of the current model with #objects_path" do
|
90
|
+
@controller.expects(:send).with('things_path')
|
91
|
+
@controller.objects_path
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should get the plural url of the current model with #objects_url" do
|
95
|
+
@controller.expects(:send).with('things_url')
|
96
|
+
@controller.objects_url
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should get the new path of the current model with #new_object_path" do
|
100
|
+
@controller.expects(:send).with('new_thing_path')
|
101
|
+
@controller.new_object_path
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should get the new url of the current model with #new_object_url" do
|
105
|
+
@controller.expects(:send).with('new_thing_url')
|
106
|
+
@controller.new_object_url
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe Resourceful::Default::URLs, " for a controller with a parent object" do
|
111
|
+
include ControllerMocks
|
112
|
+
before :each do
|
113
|
+
mock_controller Resourceful::Default::URLs
|
114
|
+
@object = stub_model('Thing')
|
115
|
+
@controller.stubs(:current_object).returns(@object)
|
116
|
+
|
117
|
+
@controller.stubs(:current_model_name).returns('Thing')
|
118
|
+
|
119
|
+
@person = stub_model('Person')
|
120
|
+
@controller.stubs(:parent_object).returns(@person)
|
121
|
+
@controller.stubs(:parent_name).returns('person')
|
122
|
+
@controller.stubs(:parent?).returns(true)
|
123
|
+
@controller.stubs(:parent_class_name).returns('Person')
|
124
|
+
@controller.stubs(:namespaces).returns([])
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should return nil for #url_helper_prefix" do
|
128
|
+
@controller.url_helper_prefix.should be_nil
|
129
|
+
end
|
130
|
+
|
131
|
+
it "should return the underscored parent name for #collection_url_prefix" do
|
132
|
+
@controller.collection_url_prefix.should == "person_"
|
133
|
+
end
|
134
|
+
|
135
|
+
it "should get the path of current_object with #object_path" do
|
136
|
+
@controller.expects(:send).with('person_thing_path', @person, @object)
|
137
|
+
@controller.object_path
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should get the nested path of current_object with #nested_object_path" do
|
141
|
+
@controller.expects(:send).with('person_thing_path', @person, @object)
|
142
|
+
@controller.nested_object_path
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should get the nested url of current_object with #nested_object_url" do
|
146
|
+
@controller.expects(:send).with('person_thing_url', @person, @object)
|
147
|
+
@controller.nested_object_url
|
148
|
+
end
|
149
|
+
|
150
|
+
it "should get the nested path of the passed object with #nested_object_path" do
|
151
|
+
object = stub_model('Thing')
|
152
|
+
@controller.expects(:send).with('person_thing_path', @person, object)
|
153
|
+
@controller.nested_object_path object
|
154
|
+
end
|
155
|
+
|
156
|
+
it "should get the nested url of the passed object with #nested_object_url" do
|
157
|
+
object = stub_model('Thing')
|
158
|
+
@controller.expects(:send).with('person_thing_url', @person, object)
|
159
|
+
@controller.nested_object_url object
|
160
|
+
end
|
161
|
+
|
162
|
+
it "should get the plural path of the current model and its parent with #objects_path" do
|
163
|
+
@controller.expects(:send).with('person_things_path', @person)
|
164
|
+
@controller.objects_path
|
165
|
+
end
|
166
|
+
|
167
|
+
it "should get the edit path of the current model with #edit_object_path" do
|
168
|
+
@controller.expects(:send).with('edit_person_thing_path', @person, @object)
|
169
|
+
@controller.edit_object_path
|
170
|
+
end
|
171
|
+
|
172
|
+
it "should get the new path of the current model and its parent with #new_object_path" do
|
173
|
+
@controller.expects(:send).with('new_person_thing_path', @person)
|
174
|
+
@controller.new_object_path
|
175
|
+
end
|
176
|
+
|
177
|
+
it "should get the path of the parent_object with #parent_path" do
|
178
|
+
pending
|
179
|
+
@controller.expects(:send).with('person_path', @person)
|
180
|
+
@controller.parent_path
|
181
|
+
end
|
182
|
+
|
183
|
+
it "should get the url of the parent_object with #parent_url" do
|
184
|
+
pending
|
185
|
+
@controller.expects(:send).with('person_url', @person)
|
186
|
+
@controller.parent_url
|
187
|
+
end
|
188
|
+
|
189
|
+
it "should get the path of the passed object with #parent_path" do
|
190
|
+
pending
|
191
|
+
model = stub_model('Person')
|
192
|
+
@controller.expects(:send).with('person_path', model)
|
193
|
+
@controller.parent_path model
|
194
|
+
end
|
195
|
+
|
196
|
+
it "should get the url of the passed object with #parent_url" do
|
197
|
+
pending
|
198
|
+
model = stub_model('Person')
|
199
|
+
@controller.expects(:send).with('person_url', model)
|
200
|
+
@controller.parent_url model
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
describe Resourceful::Default::URLs, " for a controller within a namespace" do
|
205
|
+
include ControllerMocks
|
206
|
+
before :each do
|
207
|
+
mock_controller Resourceful::Default::URLs
|
208
|
+
@object = stub_model('Thing')
|
209
|
+
@controller.stubs(:current_object).returns(@object)
|
210
|
+
|
211
|
+
@controller.stubs(:current_model_name).returns('Thing')
|
212
|
+
|
213
|
+
@controller.stubs(:parent?).returns(false)
|
214
|
+
@controller.stubs(:namespaces).returns([:admin, :main])
|
215
|
+
end
|
216
|
+
|
217
|
+
it "should return the underscored list of namespaces for #url_helper_prefix" do
|
218
|
+
@controller.url_helper_prefix.should == "admin_main_"
|
219
|
+
end
|
220
|
+
|
221
|
+
it "should get the namespaced path of current_object with #object_path" do
|
222
|
+
@controller.expects(:send).with('admin_main_thing_path', @object)
|
223
|
+
@controller.object_path
|
224
|
+
end
|
225
|
+
|
226
|
+
it "should get the namespaced plural path of the current model with #objects_path" do
|
227
|
+
@controller.expects(:send).with('admin_main_things_path')
|
228
|
+
@controller.objects_path
|
229
|
+
end
|
230
|
+
|
231
|
+
it "should get the edit path of the current model with #edit_object_path" do
|
232
|
+
@controller.expects(:send).with('edit_admin_main_thing_path', @object)
|
233
|
+
@controller.edit_object_path
|
234
|
+
end
|
235
|
+
|
236
|
+
it "should get the new path of the current model with #new_object_path" do
|
237
|
+
@controller.expects(:send).with('new_admin_main_thing_path')
|
238
|
+
@controller.new_object_path
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
describe Resourceful::Default::URLs, " for a controller with a parent object and within a namespace" do
|
243
|
+
include ControllerMocks
|
244
|
+
before :each do
|
245
|
+
mock_controller Resourceful::Default::URLs
|
246
|
+
@object = stub_model('Thing')
|
247
|
+
@controller.stubs(:current_object).returns(@object)
|
248
|
+
|
249
|
+
@controller.stubs(:current_model_name).returns('Thing')
|
250
|
+
|
251
|
+
@person = stub_model('Person')
|
252
|
+
@controller.stubs(:parent_object).returns(@person)
|
253
|
+
@controller.stubs(:parent_name).returns('person')
|
254
|
+
@controller.stubs(:parent?).returns(true)
|
255
|
+
@controller.stubs(:parent_class_name).returns('Person')
|
256
|
+
@controller.stubs(:namespaces).returns([:admin, :main])
|
257
|
+
end
|
258
|
+
|
259
|
+
it "should return the underscored list of namespaces for #url_helper_prefix" do
|
260
|
+
@controller.url_helper_prefix.should == "admin_main_"
|
261
|
+
end
|
262
|
+
|
263
|
+
it "should get the namespaced path of current_object with #object_path" do
|
264
|
+
@controller.expects(:send).with('admin_main_person_thing_path', @person, @object)
|
265
|
+
@controller.object_path
|
266
|
+
end
|
267
|
+
|
268
|
+
it "should get the namespaced plural path of the current model and its parent with #objects_path" do
|
269
|
+
@controller.expects(:send).with('admin_main_person_things_path', @person)
|
270
|
+
@controller.objects_path
|
271
|
+
end
|
272
|
+
|
273
|
+
it "should get the edit path of the current model with #edit_object_path" do
|
274
|
+
@controller.expects(:send).with('edit_admin_main_person_thing_path', @person, @object)
|
275
|
+
@controller.edit_object_path
|
276
|
+
end
|
277
|
+
|
278
|
+
it "should get the new path of the current model and its parent with #new_object_path" do
|
279
|
+
@controller.expects(:send).with('new_admin_main_person_thing_path', @person)
|
280
|
+
@controller.new_object_path
|
281
|
+
end
|
282
|
+
end
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: make_resourceful_rails2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 21
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 1.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Ben Wagaman
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2013-01-16 00:00:00 -05:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: " Take back control of your Controllers. Make them awesome. Make them sleek. Make them resourceful.\n"
|
23
|
+
email: ben@wagaman.org
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
30
|
+
files:
|
31
|
+
- lib/make_resourceful.rb
|
32
|
+
- lib/resourceful/maker.rb
|
33
|
+
- lib/resourceful/default/accessors.rb
|
34
|
+
- lib/resourceful/default/callbacks.rb
|
35
|
+
- lib/resourceful/default/responses.rb
|
36
|
+
- lib/resourceful/default/actions.rb
|
37
|
+
- lib/resourceful/default/urls.rb
|
38
|
+
- lib/resourceful/builder.rb
|
39
|
+
- lib/resourceful/serialize.rb
|
40
|
+
- lib/resourceful/response.rb
|
41
|
+
- lib/resourceful/base.rb
|
42
|
+
- lib/resourceful/generators/resourceful_scaffold/templates/migration.rb
|
43
|
+
- lib/resourceful/generators/resourceful_scaffold/templates/view_show.haml
|
44
|
+
- lib/resourceful/generators/resourceful_scaffold/templates/view_partial.haml
|
45
|
+
- lib/resourceful/generators/resourceful_scaffold/templates/model.rb
|
46
|
+
- lib/resourceful/generators/resourceful_scaffold/templates/controller.rb
|
47
|
+
- lib/resourceful/generators/resourceful_scaffold/templates/view__form.haml
|
48
|
+
- lib/resourceful/generators/resourceful_scaffold/templates/helper.rb
|
49
|
+
- lib/resourceful/generators/resourceful_scaffold/templates/view_edit.haml
|
50
|
+
- lib/resourceful/generators/resourceful_scaffold/templates/fixtures.yml
|
51
|
+
- lib/resourceful/generators/resourceful_scaffold/templates/view_index.haml
|
52
|
+
- lib/resourceful/generators/resourceful_scaffold/templates/view_new.haml
|
53
|
+
- lib/resourceful/generators/resourceful_scaffold/templates/unit_test.rb
|
54
|
+
- lib/resourceful/generators/resourceful_scaffold/templates/functional_test.rb
|
55
|
+
- lib/resourceful/generators/resourceful_scaffold/resourceful_scaffold_generator.rb
|
56
|
+
- Rakefile
|
57
|
+
- VERSION
|
58
|
+
- spec/serialize_spec.rb
|
59
|
+
- spec/maker_spec.rb
|
60
|
+
- spec/base_spec.rb
|
61
|
+
- spec/response_spec.rb
|
62
|
+
- spec/integration_spec.rb
|
63
|
+
- spec/callbacks_spec.rb
|
64
|
+
- spec/builder_spec.rb
|
65
|
+
- spec/responses_spec.rb
|
66
|
+
- spec/accessors_spec.rb
|
67
|
+
- spec/urls_spec.rb
|
68
|
+
- spec/actions_spec.rb
|
69
|
+
has_rdoc: true
|
70
|
+
homepage: http://github.com/jamin4jc/make_resourceful
|
71
|
+
licenses: []
|
72
|
+
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options: []
|
75
|
+
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
hash: 3
|
84
|
+
segments:
|
85
|
+
- 0
|
86
|
+
version: "0"
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
hash: 3
|
93
|
+
segments:
|
94
|
+
- 0
|
95
|
+
version: "0"
|
96
|
+
requirements: []
|
97
|
+
|
98
|
+
rubyforge_project:
|
99
|
+
rubygems_version: 1.5.3
|
100
|
+
signing_key:
|
101
|
+
specification_version: 3
|
102
|
+
summary: An elegant, structured way to build ActionPack Controllers (forked to work with Rails 2.x)
|
103
|
+
test_files:
|
104
|
+
- spec/serialize_spec.rb
|
105
|
+
- spec/maker_spec.rb
|
106
|
+
- spec/base_spec.rb
|
107
|
+
- spec/response_spec.rb
|
108
|
+
- spec/integration_spec.rb
|
109
|
+
- spec/callbacks_spec.rb
|
110
|
+
- spec/builder_spec.rb
|
111
|
+
- spec/responses_spec.rb
|
112
|
+
- spec/accessors_spec.rb
|
113
|
+
- spec/urls_spec.rb
|
114
|
+
- spec/actions_spec.rb
|