merb 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. data/README +23 -160
  2. data/Rakefile +15 -14
  3. data/app_generators/merb/merb_generator.rb +4 -3
  4. data/app_generators/merb/templates/Rakefile +1 -6
  5. data/app_generators/merb/templates/app/mailers/views/layout/{application.erb → application.html.erb} +0 -0
  6. data/app_generators/merb/templates/app/mailers/views/layout/application.text.erb +1 -0
  7. data/app_generators/merb/templates/app/parts/views/layout/application.html.erb +1 -0
  8. data/app_generators/merb/templates/app/views/layout/application.html.erb +2 -2
  9. data/app_generators/merb/templates/config/dependencies.rb +1 -1
  10. data/app_generators/merb/templates/config/router.rb +4 -1
  11. data/app_generators/merb/templates/spec/spec_helper.rb +2 -3
  12. data/lib/autotest/merb_rspec.rb +1 -0
  13. data/lib/merb/abstract_controller.rb +31 -2
  14. data/lib/merb/controller.rb +5 -5
  15. data/lib/merb/core_ext/get_args.rb +5 -1
  16. data/lib/merb/exceptions.rb +17 -0
  17. data/lib/merb/generators/merb_app/merb_app.rb +4 -1
  18. data/lib/merb/generators/merb_plugin.rb +4 -1
  19. data/lib/merb/logger.rb +5 -1
  20. data/lib/merb/mail_controller.rb +1 -1
  21. data/lib/merb/mailer.rb +2 -2
  22. data/lib/merb/mixins/controller.rb +5 -1
  23. data/lib/merb/mixins/render.rb +57 -27
  24. data/lib/merb/part_controller.rb +1 -1
  25. data/lib/merb/request.rb +2 -2
  26. data/lib/merb/server.rb +33 -5
  27. data/lib/merb/template/erubis.rb +1 -1
  28. data/lib/merb.rb +15 -5
  29. data/merb_generators/resource/resource_generator.rb +9 -2
  30. data/spec/fixtures/config/merb.yml +18 -0
  31. data/spec/fixtures/controllers/dispatch_spec_controllers.rb +227 -0
  32. data/spec/fixtures/controllers/render_spec_controllers.rb +115 -0
  33. data/spec/fixtures/foo.rb +3 -0
  34. data/spec/fixtures/mailers/views/layout/application.html.erb +3 -0
  35. data/spec/fixtures/mailers/views/layout/application.text.erb +3 -0
  36. data/spec/fixtures/mailers/views/test_mail_controller/eighth.html.erb +1 -0
  37. data/spec/fixtures/mailers/views/test_mail_controller/eighth.text.erb +1 -0
  38. data/spec/fixtures/mailers/views/test_mail_controller/first.html.erb +1 -0
  39. data/spec/fixtures/mailers/views/test_mail_controller/first.text.erb +1 -0
  40. data/spec/fixtures/mailers/views/test_mail_controller/ninth.html.erb +1 -0
  41. data/spec/fixtures/mailers/views/test_mail_controller/ninth.text.erb +1 -0
  42. data/spec/fixtures/mailers/views/test_mail_controller/second.text.erb +1 -0
  43. data/spec/fixtures/mailers/views/test_mail_controller/third.html.erb +1 -0
  44. data/spec/fixtures/models/router_spec_models.rb +20 -0
  45. data/spec/fixtures/parts/views/layout/todo_part.html.erb +3 -0
  46. data/spec/fixtures/parts/views/layout/todo_part.xml.erb +3 -0
  47. data/spec/fixtures/parts/views/todo_part/formatted_output.html.erb +1 -0
  48. data/spec/fixtures/parts/views/todo_part/formatted_output.js.erb +1 -0
  49. data/spec/fixtures/parts/views/todo_part/formatted_output.xml.erb +1 -0
  50. data/spec/fixtures/parts/views/todo_part/list.html.erb +3 -0
  51. data/spec/fixtures/sample.txt +1 -0
  52. data/spec/fixtures/views/erubis.html.erb +1 -0
  53. data/spec/fixtures/views/examples/_erubis.html.erb +1 -0
  54. data/spec/fixtures/views/examples/_haml.html.haml +1 -0
  55. data/spec/fixtures/views/examples/_markaby.html.mab +1 -0
  56. data/spec/fixtures/views/examples/_throw_content.html.erb +6 -0
  57. data/spec/fixtures/views/examples/hello.xml.builder +1 -0
  58. data/spec/fixtures/views/examples/js.js.erb +1 -0
  59. data/spec/fixtures/views/examples/template_catch_content.html.erb +15 -0
  60. data/spec/fixtures/views/examples/template_catch_content_from_partial.html.erb +6 -0
  61. data/spec/fixtures/views/examples/template_throw_content.html.erb +10 -0
  62. data/spec/fixtures/views/exceptions/admin_access_required.html.erb +1 -0
  63. data/spec/fixtures/views/extension_template_controller/_nested_js.js.erb +1 -0
  64. data/spec/fixtures/views/extension_template_controller/_nested_xml.xml.erb +1 -0
  65. data/spec/fixtures/views/extension_template_controller/_render_partial_multiple_times.html.erb +1 -0
  66. data/spec/fixtures/views/extension_template_controller/erubis_templates.html.erb +1 -0
  67. data/spec/fixtures/views/extension_template_controller/erubis_templates.js.erb +1 -0
  68. data/spec/fixtures/views/extension_template_controller/erubis_templates.rhtml +1 -0
  69. data/spec/fixtures/views/extension_template_controller/erubis_templates.xml.erb +1 -0
  70. data/spec/fixtures/views/extension_template_controller/haml_index.html.haml +0 -0
  71. data/spec/fixtures/views/extension_template_controller/haml_templates.html.haml +1 -0
  72. data/spec/fixtures/views/extension_template_controller/haml_templates.js.haml +1 -0
  73. data/spec/fixtures/views/extension_template_controller/haml_templates.xml.haml +1 -0
  74. data/spec/fixtures/views/extension_template_controller/index.html.erb +0 -0
  75. data/spec/fixtures/views/extension_template_controller/markaby_index.html.mab +0 -0
  76. data/spec/fixtures/views/extension_template_controller/markaby_templates.html.mab +1 -0
  77. data/spec/fixtures/views/extension_template_controller/markaby_templates.js.mab +1 -0
  78. data/spec/fixtures/views/extension_template_controller/markaby_templates.xml.mab +1 -0
  79. data/spec/fixtures/views/extension_template_controller/render_multiple_partials.html.erb +4 -0
  80. data/spec/fixtures/views/extension_template_controller/render_nested_js.js.erb +1 -0
  81. data/spec/fixtures/views/extension_template_controller/render_nested_xml.xml.erb +1 -0
  82. data/spec/fixtures/views/haml.html.haml +1 -0
  83. data/spec/fixtures/views/haml.xml.haml +2 -0
  84. data/spec/fixtures/views/layout/application.html.erb +1 -0
  85. data/spec/fixtures/views/layout/application.xml.erb +1 -0
  86. data/spec/fixtures/views/layout/nested/example.html.erb +1 -0
  87. data/spec/fixtures/views/markaby.html.mab +1 -0
  88. data/spec/fixtures/views/nested/example/test.html.erb +1 -0
  89. data/spec/fixtures/views/partials/_erubis.html.erb +1 -0
  90. data/spec/fixtures/views/partials/_erubis_collection.html.erb +1 -0
  91. data/spec/fixtures/views/partials/_erubis_collection_with_locals.html.erb +1 -0
  92. data/spec/fixtures/views/partials/_erubis_new.html.erb +1 -0
  93. data/spec/fixtures/views/partials/_haml.html.haml +1 -0
  94. data/spec/fixtures/views/partials/_haml_collection.html.haml +1 -0
  95. data/spec/fixtures/views/partials/_haml_collection_with_locals.html.haml +1 -0
  96. data/spec/fixtures/views/partials/_haml_new.html.haml +1 -0
  97. data/spec/fixtures/views/partials/_markaby.html.mab +1 -0
  98. data/spec/fixtures/views/partials/_markaby_collection.html.mab +1 -0
  99. data/spec/fixtures/views/partials/_markaby_collection_with_locals.html.mab +1 -0
  100. data/spec/fixtures/views/partials/_markaby_new.html.mab +1 -0
  101. data/spec/fixtures/views/render_object_controller/render_object_with_template.html.erb +1 -0
  102. data/spec/fixtures/views/render_object_controller/render_object_with_template.js.erb +1 -0
  103. data/spec/fixtures/views/render_object_controller/render_object_with_template.xml.erb +1 -0
  104. data/spec/fixtures/views/template_views/interface__buffer_erubis.html.erb +4 -0
  105. data/spec/fixtures/views/template_views/interface__buffer_haml.html.haml +7 -0
  106. data/spec/fixtures/views/template_views/interface__buffer_markaby.html.mab +7 -0
  107. data/spec/fixtures/views/template_views/interface_capture_erubis.html.erb +15 -0
  108. data/spec/fixtures/views/template_views/interface_capture_haml.html.haml +15 -0
  109. data/spec/fixtures/views/template_views/interface_capture_markaby.html.mab +4 -0
  110. data/spec/fixtures/views/template_views/interface_concat_erubis.html.erb +12 -0
  111. data/spec/fixtures/views/template_views/interface_concat_haml.html.haml +11 -0
  112. data/spec/fixtures/views/template_views/interface_concat_markaby.html.mab +14 -0
  113. data/spec/fixtures/views/test.dir/the_template.html.erb +1 -0
  114. data/spec/merb/abstract_controller_spec.rb +37 -0
  115. data/spec/merb/caching_spec.rb +102 -0
  116. data/spec/merb/config_spec.rb +29 -0
  117. data/spec/merb/controller_filters_spec.rb +188 -0
  118. data/spec/merb/controller_spec.rb +144 -0
  119. data/spec/merb/cookie_store_spec.rb +85 -0
  120. data/spec/merb/core_ext_spec.rb +430 -0
  121. data/spec/merb/dispatch_spec.rb +514 -0
  122. data/spec/merb/fake_request_spec.rb +72 -0
  123. data/spec/merb/form_control_mixin_spec.rb +431 -0
  124. data/spec/merb/generator_spec.rb +121 -0
  125. data/spec/merb/handler_spec.rb +169 -0
  126. data/spec/merb/mail_controller_spec.rb +144 -0
  127. data/spec/merb/mailer_spec.rb +87 -0
  128. data/spec/merb/multipart_spec.rb +49 -0
  129. data/spec/merb/part_controller_spec.rb +92 -0
  130. data/spec/merb/plugins_spec.rb +80 -0
  131. data/spec/merb/render_spec.rb +378 -0
  132. data/spec/merb/request_spec.rb +243 -0
  133. data/spec/merb/responder_spec.rb +561 -0
  134. data/spec/merb/router_spec.rb +726 -0
  135. data/spec/merb/template_spec.rb +41 -0
  136. data/spec/merb/upload_handler_spec.rb +101 -0
  137. data/spec/merb/view_context_spec.rb +148 -0
  138. data/spec/spec_generator_helper.rb +19 -0
  139. data/spec/spec_helper.rb +88 -0
  140. metadata +203 -65
  141. data/lib/merb/caching/store/memcache.rb +0 -20
  142. data/script/destroy +0 -14
  143. data/script/generate +0 -14
@@ -7,10 +7,14 @@ module Merb
7
7
  def self.included(base)
8
8
  base.class_eval {
9
9
  class_inheritable_accessor :_template_root,
10
- :_layout
10
+ :_layout,
11
+ :_templates,
12
+ :_cached_partials
11
13
 
12
14
  self._layout = :application
13
15
  self._template_root = File.expand_path(MERB_VIEW_ROOT)
16
+ self._templates = {}
17
+ self._cached_partials = {}
14
18
 
15
19
  attr_accessor :template
16
20
  }
@@ -150,18 +154,6 @@ module Merb
150
154
  when status = opts[:nothing]
151
155
  return render_nothing(status)
152
156
 
153
- when partial = opts[:partial]
154
- opts[:format] ||= :html
155
- template = find_partial(partial, opts)
156
- opts[:layout] = :none
157
-
158
- # Add an instance variable that can be used to create the locals in the
159
- # partial
160
- if opts[:locals]
161
- @_merb_partial_locals = opts[:locals]
162
- end
163
- opts[:clean_context] = true
164
-
165
157
  when opts[:inline]
166
158
  text = opts.delete(:inline)
167
159
  return render_inline(text, opts)
@@ -264,6 +256,10 @@ module Merb
264
256
  end
265
257
 
266
258
  def set_status(status)
259
+ if status.kind_of?(Symbol)
260
+ status = Merb::ControllerExceptions::RESPONSE_CODES(status)
261
+ status || raise("Can't find a response code with that name")
262
+ end
267
263
  @_status = status
268
264
  end
269
265
 
@@ -280,11 +276,22 @@ module Merb
280
276
  # you can render partials in other view directories. So
281
277
  # if you create a views/shared directory then you can call
282
278
  # partials that live there like partial('shared/foo')
283
- def partial(template, locals={})
284
- options = {:partial => template, :locals => locals}
285
- options.merge!(:format => @_template_format) if @_template_format
286
- render options
287
- end
279
+ def partial(template, opts={})
280
+ choose_template_format(Merb.available_mime_types, {}) unless @_template_format
281
+ template = _cached_partials["#{template}.#{@_template_format}"] ||= find_partial(template)
282
+ unless template
283
+ raise TemplateNotFound, "No template matched at #{unmatched}"
284
+ end
285
+
286
+ opts[:as] ||= template[(template.rindex('/_') + 2)..-1].split('.').first
287
+
288
+ if opts[:with] # Render a collection or an object
289
+ partial_for_collection(template, opts[:with], opts)
290
+ else # Just render a partial
291
+ engine = Template.engine_for(template)
292
+ render_partial(template, engine, opts || {})
293
+ end
294
+ end
288
295
 
289
296
  # +catch_content+ catches the thrown content from another template
290
297
  # So when you throw_content(:foo) {...} you can catch_content :foo
@@ -294,6 +301,32 @@ module Merb
294
301
  end
295
302
 
296
303
  private
304
+
305
+ def render_partial(template, engine, locals={})
306
+ @_merb_partial_locals = locals
307
+ options = {
308
+ :file => template,
309
+ :view_context => clean_view_context(engine),
310
+ :opts => { :locals => locals }
311
+ }
312
+ engine.transform(options)
313
+ end
314
+
315
+ def partial_for_collection(template, collection, opts={})
316
+ # Delete the internal keys, so that everything else is considered
317
+ # a local declaration in the partial
318
+ local_name = opts.delete(:as)
319
+ opts.delete(:with)
320
+
321
+ engine = Template.engine_for(template)
322
+
323
+ ret = ''
324
+ [ collection ].flatten.each do |object|
325
+ opts.merge!({local_name.to_sym => object})
326
+ ret << render_partial(template, engine, opts)
327
+ end
328
+ ret
329
+ end
297
330
 
298
331
  # this returns a ViewContext object populated with all
299
332
  # the instance variables in your controller. This is used
@@ -364,21 +397,19 @@ module Merb
364
397
  glob_template(path, opts)
365
398
  end
366
399
 
367
- # This method will return a matching template at the specified path, first using the
368
- # template_name.format.engine convention and if that fails, it falls back to the old
369
- # style extensions (herb, jerb etc)
400
+ # This method will return a matching template at the specified path, using the
401
+ # template_name.format.engine convention
370
402
  def glob_template(path, opts = {})
371
- extensions = Template::EXTENSIONS.keys
372
- glob = "#{path}.#{@_template_format}.{#{opts[:ext] || extensions.join(",")}}"
373
- Dir[glob].first || (@_merb_unmatched = glob; nil)
403
+ the_template = "#{path}.#{@_template_format}"
404
+ Merb::AbstractController._template_path_cache[the_template] || (@_merb_unmatched = (the_template + ".*"); nil)
374
405
  end
375
406
 
376
407
  # Chooses the format of the template based on the params hash or the explicit
377
408
  # request of the developer.
378
409
  def choose_template_format(types, opts)
379
410
  opts[:format] ||= content_type
380
- @_template_format = [(opts.keys & types.keys)].flatten.first # Check for render :js => etc
381
- @_template_format ||= opts[:format] || :html
411
+ @_template_format = (opts.keys & types.keys).first # Check for render :js => etc
412
+ @_template_format ||= opts[:format]
382
413
  @_format_value = opts[@_template_format] || opts[:format] # get the value of the option if something
383
414
  # like :js was used
384
415
 
@@ -387,7 +418,6 @@ module Merb
387
418
  @_template_format = @_template_format.to_sym
388
419
  @_format_value = @_format_value.to_sym
389
420
  end
390
-
391
421
  @_template_format
392
422
  end
393
423
 
@@ -1,6 +1,6 @@
1
1
  module Merb
2
2
  class PartController < AbstractController
3
- self._template_root = File.expand_path(self._template_root / "../app/parts/views")
3
+ self._template_root = File.expand_path(self._template_root / "../parts/views")
4
4
  include Merb::WebControllerMixin
5
5
 
6
6
  def initialize(web_controller)
data/lib/merb/request.rb CHANGED
@@ -254,7 +254,7 @@ module Merb
254
254
  end
255
255
 
256
256
  def accept
257
- @env['HTTP_ACCEPT']
257
+ @env['HTTP_ACCEPT'].blank? ? "*/*" : @env['HTTP_ACCEPT']
258
258
  end
259
259
 
260
260
  def connection
@@ -316,7 +316,7 @@ module Merb
316
316
  def query_parse(qs, d = '&;')
317
317
  (qs||'').split(/[#{d}] */n).inject({}) { |h,p|
318
318
  normalize_params(h, *Mongrel::HttpRequest.unescape(p).split('=',2))
319
- }
319
+ }.to_mash
320
320
  end
321
321
 
322
322
  NAME_REGEX = /Content-Disposition:.* name="?([^\";]*)"?/ni.freeze
data/lib/merb/server.rb CHANGED
@@ -261,20 +261,47 @@ module Merb
261
261
  end
262
262
 
263
263
  def load_action_arguments(klasses = Merb::Controller._subclasses)
264
- klasses.each do |controller|
265
- controller = Object.full_const_get(controller)
266
- controller.action_argument_list = {}
267
- controller.callable_actions.each do |action, bool|
268
- controller.action_argument_list[action.to_sym] = ParseTreeArray.translate(controller, action).get_args
264
+ begin
265
+ klasses.each do |controller|
266
+ controller = Object.full_const_get(controller)
267
+ controller.action_argument_list = {}
268
+ controller.callable_actions.each do |action, bool|
269
+ controller.action_argument_list[action.to_sym] = ParseTreeArray.translate(controller, action).get_args
270
+ end
269
271
  end
272
+ rescue
273
+ klasses.each { |controller| controller.action_arguments = {} }
270
274
  end if defined?(ParseTreeArray)
271
275
  end
272
276
 
277
+ def load_controller_template_path_cache
278
+
279
+ # This gets all templates set in the controllers template roots
280
+ template_paths = Merb::AbstractController._abstract_subclasses.map do |klass|
281
+ Object.full_const_get(klass)._template_root
282
+ end.uniq.map do |path|
283
+ Dir["#{path}/**/*"]
284
+ end
285
+
286
+ # This gets the templates that might be created outside controllers
287
+ # template roots. eg app/views/shared/*
288
+ template_paths << Dir["#{MERB_ROOT}/app/views/**/*"]
289
+
290
+ template_paths = template_paths.flatten.compact.uniq
291
+
292
+ Merb::AbstractController.reset_template_path_cache!
293
+
294
+ template_paths.each do |template|
295
+ Merb::AbstractController.add_path_to_template_cache(template)
296
+ end
297
+ end
298
+
273
299
  def load_application
274
300
  MERB_PATHS.each do |glob|
275
301
  Dir[MERB_ROOT + glob].each { |m| require m }
276
302
  end
277
303
  load_action_arguments
304
+ load_controller_template_path_cache
278
305
  @app_loaded = true
279
306
  (@after_app_blocks || []).each { |b| b.call }
280
307
  end
@@ -319,6 +346,7 @@ module Merb
319
346
  load(file)
320
347
  loaded_classes = Merb::Controller._subclasses - old_subclasses
321
348
  load_action_arguments(loaded_classes)
349
+ load_controller_template_path_cache
322
350
  rescue Exception => e
323
351
  puts "Error reloading file #{file}: #{e}"
324
352
  MERB_LOGGER.warn " Error: #{e}"
@@ -35,7 +35,7 @@ module Merb # :nodoc:
35
35
 
36
36
  # Creates a new Erubis object to parse the template given in +path+.
37
37
  def new_eruby_obj(path)
38
- if @@erbs[path] && !cache_template?(path)
38
+ if @@erbs[path] && MERB_ENV == 'production'
39
39
  return @@erbs[path]
40
40
  else
41
41
  begin
data/lib/merb.rb CHANGED
@@ -1,10 +1,20 @@
1
1
  require 'rubygems'
2
2
  if ENV['SWIFT']
3
- require 'swiftcore/swiftiplied_mongrel'
4
- puts "Using Swiftiplied Mongrel"
3
+ begin
4
+ require 'swiftcore/swiftiplied_mongrel'
5
+ puts "Using Swiftiplied Mongrel"
6
+ rescue LoadError
7
+ require 'mongrel'
8
+ puts "SWIFT variable set but not installed - falling back to normal Mongrel"
9
+ end
5
10
  elsif ENV['EVENT']
6
- require 'swiftcore/evented_mongrel'
7
- puts "Using Evented Mongrel"
11
+ begin
12
+ require 'swiftcore/evented_mongrel'
13
+ puts "Using Evented Mongrel"
14
+ rescue LoadError
15
+ require 'mongrel'
16
+ puts "EVENT variable set but swiftiply not installed - falling back to normal Mongrel"
17
+ end
8
18
  else
9
19
  require 'mongrel'
10
20
  end
@@ -23,7 +33,7 @@ autoload :MerbUploadHandler, 'merb/upload_handler'
23
33
  autoload :MerbHandler, 'merb/mongrel_handler'
24
34
 
25
35
  module Merb
26
- VERSION='0.4.0' unless defined?(::Merb::VERSION)
36
+ VERSION='0.4.1' unless defined?(::Merb::VERSION)
27
37
  autoload :Authentication, 'merb/mixins/basic_authentication'
28
38
  autoload :ControllerMixin, 'merb/mixins/controller'
29
39
  autoload :ErubisCaptureMixin, 'merb/mixins/erubis_capture'
@@ -16,8 +16,15 @@ class ResourceGenerator < RubiGen::Base
16
16
 
17
17
  def manifest
18
18
  record do |m|
19
- m.dependency "model", provided_args.dup, options.dup
20
- m.dependency "resource_controller", provided_args.dup, options.dup
19
+ #singularize the model & pluralize the name of the controller
20
+ model_args = provided_args.dup
21
+ controller_args = provided_args.dup
22
+
23
+ model_args[0] = model_args.first.singularize
24
+ controller_args[0] = controller_args.first.pluralize
25
+
26
+ m.dependency "model", model_args, options.dup
27
+ m.dependency "resource_controller", controller_args, options.dup
21
28
  end
22
29
  end
23
30
 
@@ -0,0 +1,18 @@
1
+ ---
2
+ :host: 127.0.0.1
3
+ :port: "4000"
4
+ #:path_prefix: "/my_app"
5
+
6
+ ### Test Erb in config
7
+ :environment: <%= "test" if true %>
8
+
9
+ :session_store: memory
10
+ #:config: config/upload.conf
11
+ #:cache_templates: true
12
+ #:drb_server_port: 32323
13
+ #:basic_auth:
14
+ # :username: ezra
15
+ # :password: test
16
+ # :domain: localhost
17
+ #:daemonize: true
18
+ #:cluster: 3
@@ -0,0 +1,227 @@
1
+ class Foo < Merb::Controller
2
+
3
+ def index
4
+ "index"
5
+ end
6
+
7
+ def bar
8
+ "bar"
9
+ end
10
+
11
+ def error
12
+ raise AdminAccessRequired
13
+ "Hello World!"
14
+ end
15
+
16
+ def raise404
17
+ raise NotFound
18
+ end
19
+ end
20
+
21
+ class Bar < Merb::Controller
22
+
23
+ def foo(id)
24
+ id
25
+ end
26
+
27
+ def bar(a, b = "2")
28
+ "#{a} #{b}"
29
+ end
30
+
31
+ def baz(a, b = "2", c = "3")
32
+ "#{a} #{b} #{c}"
33
+ end
34
+
35
+ end
36
+
37
+ class Baz < Merb::Controller
38
+
39
+ def index
40
+ end
41
+
42
+ end
43
+
44
+ class Bat < Merb::Controller
45
+ end
46
+
47
+ class AdminAccessRequired < Merb::ControllerExceptions::Unauthorized; end
48
+
49
+ class Exceptions < Merb::Controller
50
+ def admin_access_required
51
+ "oh no!"
52
+ end
53
+ end
54
+
55
+ class Posts < Merb::Controller
56
+ # GET /posts
57
+ # GET /posts.xml
58
+ def index() :index end
59
+ # GET /posts/1
60
+ # GET /posts/1.xml
61
+ def show() :show end
62
+ # GET /posts/new
63
+ def new() :new end
64
+ # GET /posts/1;edit
65
+ def edit() :edit end
66
+ # POST /posts
67
+ # POST /posts.xml
68
+ def create() :create end
69
+ # PUT /posts/1
70
+ # PUT /posts/1.xml
71
+ def update() :update end
72
+ # DELETE /posts/1
73
+ # DELETE /posts/1.xml
74
+ def destroy() :destroy end
75
+ # GET /posts/1;stats
76
+ # PUT /posts/1;stats
77
+ def stats() :stats end
78
+ # GET /posts;filter
79
+ def filter() :filter end
80
+ end
81
+
82
+ class As < Merb::Controller
83
+ # GET /as
84
+ # GET /as.xml
85
+ def index() :index end
86
+ # GET /as/1
87
+ # GET /as/1.xml
88
+ def show() :show end
89
+ # GET /as/new
90
+ def new() :new end
91
+ # GET /as/1;edit
92
+ def edit() :edit end
93
+ # POST /as
94
+ # POST /as.xml
95
+ def create() :create end
96
+ # PUT /as/1
97
+ # PUT /as/1.xml
98
+ def update() :update end
99
+ # DELETE /as/1
100
+ # DELETE /as/1.xml
101
+ def destroy() :destroy end
102
+ end
103
+
104
+ class Bs < Merb::Controller
105
+ # GET /as/1/bs
106
+ # GET /as/1/bs.xml
107
+ def index() :index end
108
+ # GET /as/1/bs/1
109
+ # GET /as/1/bs/1.xml
110
+ def show() :show end
111
+ # GET /as/1/bs/new
112
+ def new() :new end
113
+ # GET /as/1/bs/1;edit
114
+ def edit() :edit end
115
+ # POST /as/1/bs
116
+ # POST /as/1/bs.xml
117
+ def create() :create end
118
+ # PUT /as/1/bs/1
119
+ # PUT /as/1/bs/1.xml
120
+ def update() :update end
121
+ # DELETE /as/1/bs/1
122
+ # DELETE /as/1/bs/1.xml
123
+ def destroy() :destroy end
124
+ end
125
+
126
+ class Cs < Merb::Controller
127
+ # GET /as/1/bs/1/cs
128
+ # GET /as/1/bs/1/cs.xml
129
+ def index() :index end
130
+ # GET /as/1/bs/1/cs/1
131
+ # GET /as/1/bs/1/cs/1.xml
132
+ def show() :show end
133
+ # GET /as/1/bs/1/cs/new
134
+ def new() :new end
135
+ # GET /as/1/bs/1/cs/1;edit
136
+ def edit() :edit end
137
+ # POST /as/1/bs/1/cs
138
+ # POST /as/1/bs/1/cs.xml
139
+ def create() :create end
140
+ # PUT /as/1/bs/1/cs/1
141
+ # PUT /as/1/bs/1/cs/1.xml
142
+ def update() :update end
143
+ # DELETE /as/1/bs/1/cs/1
144
+ # DELETE /as/1/bs/1/cs/1.xml
145
+ def destroy() :destroy end
146
+ end
147
+
148
+ class Tags < Merb::Controller
149
+ # GET /tags
150
+ # GET /tags.xml
151
+ def index() :index end
152
+ # GET /tags/1
153
+ # GET /tags/1.xml
154
+ def show() :show end
155
+ # GET /tags/new
156
+ def new() :new end
157
+ # GET /tags/1;edit
158
+ def edit() :edit end
159
+ # POST /tags
160
+ # POST /tags.xml
161
+ def create() :create end
162
+ # PUT /tags/1
163
+ # PUT /tags/1.xml
164
+ def update() :update end
165
+ # DELETE /tags/1
166
+ # DELETE /tags/1.xml
167
+ def destroy() :destroy end
168
+ # GET /tags/1;stats
169
+ # PUT /tags/1;stats
170
+ def stats() :stats end
171
+ # GET /tags;filter
172
+ def filter() :filter end
173
+ end
174
+
175
+ class Comments < Merb::Controller
176
+ # GET /comments
177
+ # GET /comments.xml
178
+ def index() :index end
179
+ # GET /comments/1
180
+ # GET /comments/1.xml
181
+ def show() :show end
182
+ # GET /comments/new
183
+ def new() :new end
184
+ # GET /comments/1;edit
185
+ def edit() :edit end
186
+ # POST /comments
187
+ # POST /comments.xml
188
+ def create() :create end
189
+ # PUT /comments/1
190
+ # PUT /comments/1.xml
191
+ def update() :update end
192
+ # DELETE /comments/1
193
+ # DELETE /comments/1.xml
194
+ def destroy() :destroy end
195
+ # GET /comments/1;stats
196
+ # PUT /comments/1;stats
197
+ def stats() :stats end
198
+ end
199
+
200
+ class Icon < Merb::Controller
201
+ # GET /icon
202
+ # GET /icon.xml
203
+ def show() :show end
204
+ # GET /icon/new
205
+ def new() :new end
206
+ # GET /icon;edit
207
+ def edit() :edit end
208
+ # POST /icon
209
+ # POST /icon.xml
210
+ def create() :create end
211
+ # PUT /icon7
212
+ # PUT /icon.xml
213
+ def update() :update end
214
+ # DELETE /icon
215
+ # DELETE /icon.xml
216
+ def destroy() :destroy end
217
+ # GET /icon;stats
218
+ # PUT /icon;stats
219
+ def stats() :stats end
220
+ end
221
+
222
+ class Profile < Merb::Controller
223
+ def show() :show end
224
+ end
225
+
226
+ # If this throws an error, it's because parameterized args are somehow borked
227
+ Merb::Server.load_application
@@ -0,0 +1,115 @@
1
+ SPEC_VIEW_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', 'views'))
2
+
3
+ module Merb
4
+ class Controller
5
+ self._template_root = SPEC_VIEW_ROOT
6
+ end
7
+ class ControllerExceptions::Base
8
+ def self._template_root; SPEC_VIEW_ROOT; end
9
+ end
10
+ end
11
+
12
+ # Fake class so we can render subdirectories of views
13
+ class Examples < Merb::Controller
14
+
15
+ end
16
+
17
+ module Nested
18
+ class Example < Merb::Controller
19
+ end
20
+ end
21
+
22
+ class FakeModel
23
+
24
+ def to_json
25
+ "{'foo':'bar'}"
26
+ end
27
+
28
+ def to_xml
29
+ "<foo>bar</foo>"
30
+ end
31
+ end
32
+
33
+ class RenderObjectController < Merb::Controller
34
+
35
+
36
+ def render_object
37
+ provides :xml,:json
38
+ @foo = FakeModel.new
39
+ render @foo
40
+ end
41
+
42
+ def render_object_with_template
43
+ provides :xml, :js
44
+ @foo = FakeModel.new
45
+ render @foo
46
+ end
47
+
48
+ end
49
+
50
+ class ExtensionTemplateController < Merb::Controller
51
+ provides :js, :xml
52
+ def erubis_templates
53
+ render
54
+ end
55
+
56
+ def haml_templates
57
+ render
58
+ end
59
+
60
+ def markaby_templates
61
+ render
62
+ end
63
+
64
+ def old_style_erubis
65
+ render
66
+ end
67
+
68
+ def old_style_erubis2
69
+ render
70
+ end
71
+
72
+ def old_style_erubis3
73
+ render
74
+ end
75
+
76
+ def old_style_haml
77
+ render
78
+ end
79
+
80
+ def old_style_markaby
81
+ render
82
+ end
83
+
84
+ def old_style_builder
85
+ render
86
+ end
87
+
88
+ def index
89
+ render
90
+ end
91
+
92
+ def haml_index
93
+ render
94
+ end
95
+
96
+ def markaby_index
97
+ render
98
+ end
99
+
100
+ def render_nested_js
101
+ render :format => :js
102
+ end
103
+
104
+ def render_nested_xml
105
+ render :format => :xml
106
+ end
107
+
108
+ def render_multiple_partials
109
+ render
110
+ end
111
+
112
+ end
113
+
114
+ Merb::Server.load_action_arguments
115
+ Merb::Server.load_controller_template_path_cache
@@ -0,0 +1,3 @@
1
+ class Foo
2
+ attr_accessor :bar
3
+ end
@@ -0,0 +1,3 @@
1
+ BASIC
2
+ <%= catch_content :layout %>
3
+ LAYOUT
@@ -0,0 +1,3 @@
1
+ TEXT
2
+ <%= catch_content :layout %>
3
+ ENDTEXT
@@ -0,0 +1 @@
1
+ <%= params[:x] %>
@@ -0,0 +1 @@
1
+ <%= params[:x] %>