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.
Files changed (80) hide show
  1. data/README +4 -15
  2. data/Rakefile +1 -1
  3. data/VERSION +1 -1
  4. data/{assets/icons → app/assets/images/easy_admin_ui}/classify.png +0 -0
  5. data/{assets/icons → app/assets/images/easy_admin_ui}/connect.png +0 -0
  6. data/{assets/icons → app/assets/images/easy_admin_ui}/delete.png +0 -0
  7. data/{assets/icons → app/assets/images/easy_admin_ui}/disconnect.png +0 -0
  8. data/{assets/icons → app/assets/images/easy_admin_ui}/pencil.png +0 -0
  9. data/{assets/icons → app/assets/images/easy_admin_ui}/show.png +0 -0
  10. data/app/assets/stylesheets/easy_admin_ui/easy_admin_ui.sass +47 -0
  11. data/app/views/easy_admin_ui/destroy.js.erb +1 -0
  12. data/{templates → app/views}/easy_admin_ui/edit.html.erb +0 -0
  13. data/{templates → app/views}/easy_admin_ui/index.html.erb +0 -0
  14. data/{templates → app/views}/easy_admin_ui/new.html.erb +0 -0
  15. data/{templates → app/views}/easy_admin_ui/show.html.erb +0 -0
  16. data/easy_admin_ui.gemspec +80 -21
  17. data/lib/easy_admin_ui/core_ext.rb +1 -3
  18. data/lib/easy_admin_ui/rails/engine.rb +10 -0
  19. data/lib/easy_admin_ui/tasks.rb +0 -10
  20. data/lib/easy_admin_ui/view_helpers.rb +3 -3
  21. data/lib/easy_admin_ui.rb +1 -9
  22. data/vendor/plugins/make_resourceful/.gitignore +1 -0
  23. data/vendor/plugins/make_resourceful/DEFAULTS +148 -0
  24. data/vendor/plugins/make_resourceful/LICENSE +7 -0
  25. data/vendor/plugins/make_resourceful/README.rdoc +239 -0
  26. data/vendor/plugins/make_resourceful/Rakefile +31 -0
  27. data/vendor/plugins/make_resourceful/VERSION +1 -0
  28. data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/resourceful_scaffold_generator.rb +87 -0
  29. data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/controller.rb +5 -0
  30. data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/fixtures.yml +10 -0
  31. data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/functional_test.rb +50 -0
  32. data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/helper.rb +2 -0
  33. data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/migration.rb +13 -0
  34. data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/model.rb +2 -0
  35. data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/unit_test.rb +7 -0
  36. data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/view__form.haml +5 -0
  37. data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/view_edit.haml +11 -0
  38. data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/view_index.haml +5 -0
  39. data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/view_new.haml +9 -0
  40. data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/view_partial.haml +12 -0
  41. data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/view_show.haml +14 -0
  42. data/vendor/plugins/make_resourceful/init.rb +3 -0
  43. data/vendor/plugins/make_resourceful/lib/resourceful/base.rb +63 -0
  44. data/vendor/plugins/make_resourceful/lib/resourceful/builder.rb +385 -0
  45. data/vendor/plugins/make_resourceful/lib/resourceful/default/accessors.rb +402 -0
  46. data/vendor/plugins/make_resourceful/lib/resourceful/default/actions.rb +101 -0
  47. data/vendor/plugins/make_resourceful/lib/resourceful/default/callbacks.rb +51 -0
  48. data/vendor/plugins/make_resourceful/lib/resourceful/default/responses.rb +118 -0
  49. data/vendor/plugins/make_resourceful/lib/resourceful/default/urls.rb +137 -0
  50. data/vendor/plugins/make_resourceful/lib/resourceful/maker.rb +84 -0
  51. data/vendor/plugins/make_resourceful/lib/resourceful/response.rb +33 -0
  52. data/vendor/plugins/make_resourceful/lib/resourceful/serialize.rb +185 -0
  53. data/vendor/plugins/make_resourceful/spec/accessors_spec.rb +474 -0
  54. data/vendor/plugins/make_resourceful/spec/actions_spec.rb +310 -0
  55. data/vendor/plugins/make_resourceful/spec/base_spec.rb +12 -0
  56. data/vendor/plugins/make_resourceful/spec/builder_spec.rb +332 -0
  57. data/vendor/plugins/make_resourceful/spec/callbacks_spec.rb +71 -0
  58. data/vendor/plugins/make_resourceful/spec/integration_spec.rb +394 -0
  59. data/vendor/plugins/make_resourceful/spec/maker_spec.rb +91 -0
  60. data/vendor/plugins/make_resourceful/spec/response_spec.rb +37 -0
  61. data/vendor/plugins/make_resourceful/spec/responses_spec.rb +314 -0
  62. data/vendor/plugins/make_resourceful/spec/rspec-rails/LICENSE +37 -0
  63. data/vendor/plugins/make_resourceful/spec/rspec-rails/redirect_to.rb +113 -0
  64. data/vendor/plugins/make_resourceful/spec/rspec-rails/render_template.rb +90 -0
  65. data/vendor/plugins/make_resourceful/spec/serialize_spec.rb +133 -0
  66. data/vendor/plugins/make_resourceful/spec/spec_helper.rb +319 -0
  67. data/vendor/plugins/make_resourceful/spec/urls_spec.rb +282 -0
  68. data/vendor/plugins/make_resourceful/spec/views/things/create.rjs +1 -0
  69. data/vendor/plugins/make_resourceful/spec/views/things/destroy.rjs +1 -0
  70. data/vendor/plugins/make_resourceful/spec/views/things/edit.html.erb +4 -0
  71. data/vendor/plugins/make_resourceful/spec/views/things/edit.rjs +1 -0
  72. data/vendor/plugins/make_resourceful/spec/views/things/index.html.erb +4 -0
  73. data/vendor/plugins/make_resourceful/spec/views/things/index.rjs +1 -0
  74. data/vendor/plugins/make_resourceful/spec/views/things/new.html.erb +4 -0
  75. data/vendor/plugins/make_resourceful/spec/views/things/new.rjs +1 -0
  76. data/vendor/plugins/make_resourceful/spec/views/things/show.html.erb +4 -0
  77. data/vendor/plugins/make_resourceful/spec/views/things/show.rjs +1 -0
  78. data/vendor/plugins/make_resourceful/spec/views/things/update.rjs +1 -0
  79. metadata +75 -16
  80. data/assets/css/easy_admin_ui.css +0 -69
@@ -0,0 +1,319 @@
1
+ $: << File.dirname(__FILE__) + '/../lib'
2
+
3
+ require 'rubygems'
4
+ %w[spec rails/version action_pack active_record resourceful/maker
5
+ action_controller action_controller/test_process action_controller/integration
6
+ spec/rspec-rails/redirect_to spec/rspec-rails/render_template].each &method(:require)
7
+
8
+ Spec::Runner.configure do |config|
9
+ config.mock_with :mocha
10
+ end
11
+
12
+ module MetaClass
13
+ def metaclass
14
+ class << self; self; end
15
+ end
16
+ end
17
+
18
+ def should_be_called(&block)
19
+ pstub = stub
20
+ pstub.expects(:call).instance_eval(&(block || proc {}))
21
+ proc { |*args| pstub.call(*args) }
22
+ end
23
+
24
+ def stub_model(name)
25
+ model = Class.new do
26
+ include Resourceful::Serialize::Model
27
+
28
+ def self.to_s
29
+ @name
30
+ end
31
+
32
+ def initialize(attrs = {})
33
+ attrs.each do |k, v|
34
+ self.stubs(k).returns(v)
35
+ end
36
+ end
37
+
38
+ def inspect
39
+ "#<#{self.class.send(:instance_variable_get, '@name')}>"
40
+ end
41
+ end
42
+ model.send(:instance_variable_set, '@name', name)
43
+ model
44
+ end
45
+
46
+ def stub_const(name)
47
+ unless Object.const_defined?(name)
48
+ obj = Object.new
49
+ obj.extend MetaClass
50
+ obj.metaclass.send(:define_method, :to_s) { name.to_s }
51
+ obj.metaclass.send(:alias_method, :inspect, :to_s)
52
+ Object.const_set(name, obj)
53
+ end
54
+ Object.const_get(name)
55
+ end
56
+
57
+ def stub_list(size, name = nil, &block)
58
+ list = Array.new(size) { |i| name ? stub("#{name}_#{i}") : stub }
59
+ list.each(&block) if block
60
+ list
61
+ end
62
+
63
+ module Spec::Matchers
64
+ def have_any(&proc)
65
+ satisfy { |a| a.any?(&proc) }
66
+ end
67
+ end
68
+
69
+ module ControllerMocks
70
+ def mock_kontroller(*to_extend)
71
+ options = to_extend.last.is_a?(Hash) ? to_extend.slice!(-1) : {}
72
+ @kontroller = Class.new
73
+ @kontroller.extend Resourceful::Maker
74
+ to_extend.each(&@kontroller.method(:extend))
75
+
76
+ @hidden_actions = Resourceful::ACTIONS.dup
77
+ @kontroller.stubs(:hidden_actions).returns(@hidden_actions)
78
+ @kontroller.stubs(:plural_action?).returns(false)
79
+ @kontroller.stubs(:include)
80
+ @kontroller.stubs(:before_filter)
81
+ @kontroller.stubs(:helper_method)
82
+ end
83
+
84
+ def mock_controller(*to_extend)
85
+ mock_kontroller
86
+ @controller = @kontroller.new
87
+ to_extend.each(&@controller.method(:extend))
88
+ end
89
+
90
+ def mock_builder(inherited = false)
91
+ @builder = stub
92
+ @builder.stubs(:response_for)
93
+ @builder.stubs(:apply)
94
+ @builder.stubs(:instance_eval).yields(@buildercc )
95
+ @builder.stubs(:inherited?).returns(inherited)
96
+ Resourceful::Base.stubs(:made_resourceful).returns([])
97
+ Resourceful::Builder.stubs(:new).returns(@builder)
98
+ end
99
+
100
+ def create_builder
101
+ @builder = Resourceful::Builder.new(@kontroller)
102
+ class << @builder
103
+ alias_method :made_resourceful, :instance_eval
104
+ end
105
+ end
106
+
107
+ def responses
108
+ @kontroller.read_inheritable_attribute(:resourceful_responses)
109
+ end
110
+
111
+ def callbacks
112
+ @kontroller.read_inheritable_attribute(:resourceful_callbacks)
113
+ end
114
+
115
+ def parents
116
+ @kontroller.read_inheritable_attribute(:parents)
117
+ end
118
+
119
+ # Evaluates the made_resourceful block of mod (a module)
120
+ # in the context of @builder.
121
+ # @builder should be initialized via create_builder.
122
+ def made_resourceful(mod)
123
+ mod.included(@builder)
124
+ end
125
+ end
126
+
127
+ module RailsMocks
128
+ attr_reader :response, :request, :controller, :kontroller
129
+
130
+ def included(mod)
131
+ require 'ruby-debug'
132
+ debugger
133
+ end
134
+
135
+ def mock_resourceful(options = {}, &block)
136
+ options = {
137
+ :name => "things"
138
+ }.merge options
139
+
140
+ init_kontroller options
141
+ init_routes options
142
+
143
+ stub_const(options[:name].singularize.camelize)
144
+ kontroller.make_resourceful(&block)
145
+
146
+ init_controller options
147
+ end
148
+
149
+ def assigns(name)
150
+ controller.instance_variable_get("@#{name}")
151
+ end
152
+
153
+ def redirect_to(opts)
154
+ Spec::Rails::Matchers::RedirectTo.new(request, opts)
155
+ end
156
+
157
+ def render_template(path)
158
+ Spec::Rails::Matchers::RenderTemplate.new(path.to_s, @controller)
159
+ end
160
+
161
+ private
162
+
163
+ def init_kontroller(options)
164
+ @kontroller = Class.new ActionController::Base
165
+ @kontroller.extend Resourceful::Maker
166
+ @kontroller.extend MetaClass
167
+
168
+ @kontroller.metaclass.send(:define_method, :controller_name) { options[:name] }
169
+ @kontroller.metaclass.send(:define_method, :controller_path) { options[:name] }
170
+ @kontroller.metaclass.send(:define_method, :inspect) { "#{options[:name].camelize}Controller" }
171
+ @kontroller.metaclass.send(:alias_method, :to_s, :inspect)
172
+
173
+ @kontroller.send(:define_method, :controller_name) { options[:name] }
174
+ @kontroller.send(:define_method, :controller_path) { options[:name] }
175
+ @kontroller.send(:define_method, :inspect) { "#<#{options[:name].camelize}Controller>" }
176
+ @kontroller.send(:alias_method, :to_s, :inspect)
177
+ @kontroller.send(:include, ControllerMethods)
178
+ @kontroller.send(:view_paths=, [File.join(File.dirname(__FILE__), 'views')])
179
+
180
+ @kontroller
181
+ end
182
+
183
+ def init_routes(options)
184
+ ActionController::Routing::Routes.clear!
185
+ route_block = options[:routes] || proc { |map| map.resources options[:name] }
186
+ ActionController::Routing::Routes.draw(&route_block)
187
+ end
188
+
189
+ def init_controller(options)
190
+ @controller = kontroller.new
191
+ @request = ActionController::TestRequest.new
192
+ @response = ActionController::TestResponse.new
193
+
194
+ @controller.request = @request
195
+ @controller.response = @response
196
+ @request.accept = '*/*'
197
+ @request.env['HTTP_REFERER'] = 'http://test.host'
198
+
199
+ @controller
200
+ end
201
+
202
+ def action_params(action, params = {})
203
+ params.merge case action
204
+ when :show, :edit, :destroy: {:id => 12}
205
+ when :update: {:id => 12, :thing => {}}
206
+ when :create: {:thing => {}}
207
+ else {}
208
+ end
209
+ end
210
+
211
+ def action_method(action)
212
+ method case action
213
+ when :index, :show, :edit, :new: :get
214
+ when :update: :put
215
+ when :create: :post
216
+ when :destroy: :delete
217
+ end
218
+ end
219
+
220
+ module ControllerMethods
221
+ # From rspec-rails ControllerExampleGroup
222
+
223
+ def render(options=nil, deprecated_status_or_extra_options=nil, &block)
224
+ if ::Rails::VERSION::STRING >= '2.0.0' && deprecated_status_or_extra_options.nil?
225
+ deprecated_status_or_extra_options = {}
226
+ end
227
+
228
+ unless block_given?
229
+ if @template.respond_to?(:finder)
230
+ (class << @template.finder; self; end).class_eval do
231
+ define_method :file_exists? do; true; end
232
+ end
233
+ else
234
+ (class << @template; self; end).class_eval do
235
+ define_method :file_exists? do; true; end
236
+ end
237
+ end
238
+ (class << @template; self; end).class_eval do
239
+ define_method :render_file do |*args|
240
+ @first_render ||= args[0] unless args[0] =~ /^layouts/
241
+ @_first_render ||= args[0] unless args[0] =~ /^layouts/
242
+ end
243
+
244
+ define_method :_pick_template do |*args|
245
+ @_first_render ||= args[0] unless args[0] =~ /^layouts/
246
+ PickedTemplate.new
247
+ end
248
+ end
249
+ end
250
+
251
+ super(options, deprecated_status_or_extra_options, &block)
252
+ end
253
+
254
+ class PickedTemplate
255
+ def render_template(*ignore_args); end
256
+ def render_partial(*ignore_args); end
257
+ end
258
+ end
259
+
260
+ end
261
+
262
+ module Spec::Example::ExampleGroupMethods
263
+ def should_render_html(action)
264
+ it "should render HTML by default for #{action_string(action)}" do
265
+ action_method(action)[action, action_params(action)]
266
+ response.body.should include("as HTML")
267
+ response.content_type.should == 'text/html'
268
+ end
269
+ end
270
+
271
+ def should_render_js(action)
272
+ it "should render JS for #{action_string(action)}" do
273
+ action_method(action)[action, action_params(action, :format => 'js')]
274
+ response.body.should include("insert(\"#{action}")
275
+ response.should be_success
276
+ response.content_type.should == 'text/javascript'
277
+ end
278
+ end
279
+
280
+ def shouldnt_render_xml(action)
281
+ it "shouldn't render XML for #{action_string(action)}" do
282
+ action_method(action)[action, action_params(action, :format => 'xml')]
283
+ response.should_not be_success
284
+ response.code.should == '406'
285
+ end
286
+ end
287
+
288
+ def action_string(action)
289
+ case action
290
+ when :index: "GET /things"
291
+ when :show: "GET /things/12"
292
+ when :edit: "GET /things/12/edit"
293
+ when :update: "PUT /things/12"
294
+ when :create: "POST /things"
295
+ when :new: "GET /things/new"
296
+ when :destroy: "DELETE /things/12"
297
+ end
298
+ end
299
+ end
300
+
301
+ module Spec::Example
302
+ class IntegrationExampleGroup < Spec::Example::ExampleGroup
303
+ include ActionController::TestProcess
304
+ include ActionController::Assertions
305
+ include RailsMocks
306
+
307
+ # Need this helper, because we made current_objects private
308
+ def current_objects
309
+ controller.instance_eval("current_objects")
310
+ end
311
+
312
+ # Need this helper, because we made current_object private
313
+ def current_object
314
+ controller.instance_eval("current_object")
315
+ end
316
+
317
+ ExampleGroupFactory.register(:integration, self)
318
+ end
319
+ end
@@ -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
@@ -0,0 +1 @@
1
+ page.insert_html 'test', 'create'
@@ -0,0 +1 @@
1
+ page.insert_html 'test', 'destroy'
@@ -0,0 +1,4 @@
1
+ Notice: <%= flash[:notice]%>
2
+ Error: <%= flash[:error]%>
3
+
4
+ Editting object as HTML
@@ -0,0 +1 @@
1
+ page.insert_html 'test', 'edit'
@@ -0,0 +1,4 @@
1
+ Notice: <%= flash[:notice]%>
2
+ Error: <%= flash[:error]%>
3
+
4
+ Objects as HTML
@@ -0,0 +1 @@
1
+ page.insert_html 'test', 'index'
@@ -0,0 +1,4 @@
1
+ Notice: <%= flash[:notice]%>
2
+ Error: <%= flash[:error]%>
3
+
4
+ New object as HTML
@@ -0,0 +1 @@
1
+ page.insert_html 'test', 'new'
@@ -0,0 +1,4 @@
1
+ Notice: <%= flash[:notice]%>
2
+ Error: <%= flash[:error]%>
3
+
4
+ Showing object as HTML
@@ -0,0 +1 @@
1
+ page.insert_html 'test', 'show'
@@ -0,0 +1 @@
1
+ page.insert_html 'test', 'update'