merb 0.5.3 → 0.9.2
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/LICENSE +0 -20
- data/README +0 -277
- data/Rakefile +80 -199
- data/TODO +0 -3
- metadata +19 -438
- data/SVN_REVISION +0 -1
- data/app_generators/merb/USAGE +0 -5
- data/app_generators/merb/merb_generator.rb +0 -108
- data/app_generators/merb/templates/Rakefile +0 -124
- data/app_generators/merb/templates/app/controllers/application.rb +0 -3
- data/app_generators/merb/templates/app/controllers/exceptions.rb +0 -13
- data/app_generators/merb/templates/app/helpers/global_helper.rb +0 -5
- data/app_generators/merb/templates/app/mailers/views/layout/application.html.erb +0 -1
- data/app_generators/merb/templates/app/mailers/views/layout/application.text.erb +0 -1
- data/app_generators/merb/templates/app/parts/views/layout/application.html.erb +0 -1
- data/app_generators/merb/templates/app/views/exceptions/internal_server_error.html.erb +0 -216
- data/app_generators/merb/templates/app/views/exceptions/not_acceptable.html.erb +0 -38
- data/app_generators/merb/templates/app/views/exceptions/not_found.html.erb +0 -40
- data/app_generators/merb/templates/app/views/layout/application.html.erb +0 -11
- data/app_generators/merb/templates/config/boot.rb +0 -11
- data/app_generators/merb/templates/config/dependencies.rb +0 -41
- data/app_generators/merb/templates/config/environments/development.rb +0 -1
- data/app_generators/merb/templates/config/environments/production.rb +0 -1
- data/app_generators/merb/templates/config/environments/test.rb +0 -1
- data/app_generators/merb/templates/config/merb.yml +0 -82
- data/app_generators/merb/templates/config/merb_init.rb +0 -17
- data/app_generators/merb/templates/config/plugins.yml +0 -1
- data/app_generators/merb/templates/config/router.rb +0 -35
- data/app_generators/merb/templates/config/upload.conf +0 -0
- data/app_generators/merb/templates/public/images/merb.jpg +0 -0
- data/app_generators/merb/templates/public/merb.fcgi +0 -6
- data/app_generators/merb/templates/public/stylesheets/master.css +0 -119
- data/app_generators/merb/templates/script/destroy +0 -32
- data/app_generators/merb/templates/script/generate +0 -32
- data/app_generators/merb/templates/script/stop_merb +0 -13
- data/app_generators/merb/templates/script/win_script.cmd +0 -1
- data/app_generators/merb/templates/spec/spec.opts +0 -6
- data/app_generators/merb/templates/spec/spec_helper.rb +0 -15
- data/app_generators/merb/templates/test/test_helper.rb +0 -14
- data/app_generators/merb_plugin/USAGE +0 -5
- data/app_generators/merb_plugin/merb_plugin_generator.rb +0 -68
- data/app_generators/merb_plugin/templates/LICENSE +0 -20
- data/app_generators/merb_plugin/templates/README +0 -4
- data/app_generators/merb_plugin/templates/Rakefile +0 -35
- data/app_generators/merb_plugin/templates/TODO +0 -5
- data/app_generators/merb_plugin/templates/merbtasks.rb +0 -6
- data/app_generators/merb_plugin/templates/sampleplugin.rb +0 -10
- data/app_generators/merb_plugin/templates/sampleplugin_spec.rb +0 -7
- data/app_generators/merb_plugin/templates/spec_helper.rb +0 -2
- data/bin/merb +0 -4
- data/lib/autotest/discover.rb +0 -3
- data/lib/autotest/merb_rspec.rb +0 -80
- data/lib/merb.rb +0 -188
- data/lib/merb/abstract_controller.rb +0 -399
- data/lib/merb/assets.rb +0 -160
- data/lib/merb/assets.rb.orig +0 -119
- data/lib/merb/boot_loader.rb +0 -286
- data/lib/merb/boot_loader.rb.orig +0 -235
- data/lib/merb/caching.rb +0 -5
- data/lib/merb/caching/action_cache.rb +0 -92
- data/lib/merb/caching/fragment_cache.rb +0 -39
- data/lib/merb/caching/store/file_cache.rb +0 -90
- data/lib/merb/caching/store/memory_cache.rb +0 -85
- data/lib/merb/config.rb +0 -290
- data/lib/merb/constants.rb +0 -50
- data/lib/merb/controller.rb +0 -220
- data/lib/merb/cookies.rb +0 -95
- data/lib/merb/core_ext.rb +0 -15
- data/lib/merb/core_ext/array.rb +0 -0
- data/lib/merb/core_ext/class.rb +0 -180
- data/lib/merb/core_ext/enumerable.rb +0 -49
- data/lib/merb/core_ext/get_args.rb +0 -76
- data/lib/merb/core_ext/hash.rb +0 -306
- data/lib/merb/core_ext/inflections.rb +0 -112
- data/lib/merb/core_ext/inflector.rb +0 -275
- data/lib/merb/core_ext/kernel.rb +0 -242
- data/lib/merb/core_ext/mash.rb +0 -88
- data/lib/merb/core_ext/module.rb +0 -67
- data/lib/merb/core_ext/numeric.rb +0 -72
- data/lib/merb/core_ext/object.rb +0 -183
- data/lib/merb/core_ext/string.rb +0 -53
- data/lib/merb/core_ext/symbol.rb +0 -6
- data/lib/merb/dispatcher.rb +0 -109
- data/lib/merb/drb_server.rb +0 -19
- data/lib/merb/erubis_ext.rb +0 -10
- data/lib/merb/exceptions.rb +0 -192
- data/lib/merb/generators/merb_app/merb_app.rb +0 -22
- data/lib/merb/generators/merb_generator_helpers.rb +0 -318
- data/lib/merb/generators/merb_plugin.rb +0 -22
- data/lib/merb/logger.rb +0 -78
- data/lib/merb/mail_controller.rb +0 -268
- data/lib/merb/mailer.rb +0 -87
- data/lib/merb/mixins/basic_authentication.rb +0 -35
- data/lib/merb/mixins/controller.rb +0 -160
- data/lib/merb/mixins/erubis_capture.rb +0 -68
- data/lib/merb/mixins/general_controller.rb +0 -253
- data/lib/merb/mixins/inline_partial.rb +0 -32
- data/lib/merb/mixins/render.rb +0 -465
- data/lib/merb/mixins/responder.rb +0 -449
- data/lib/merb/mixins/view_context.rb +0 -558
- data/lib/merb/mixins/web_controller.rb +0 -36
- data/lib/merb/mongrel_handler.rb +0 -168
- data/lib/merb/part_controller.rb +0 -29
- data/lib/merb/plugins.rb +0 -16
- data/lib/merb/rack_adapter.rb +0 -37
- data/lib/merb/request.rb +0 -465
- data/lib/merb/router.rb +0 -646
- data/lib/merb/server.rb +0 -169
- data/lib/merb/session.rb +0 -23
- data/lib/merb/session/cookie_store.rb +0 -118
- data/lib/merb/session/mem_cache_session.rb +0 -131
- data/lib/merb/session/memory_session.rb +0 -176
- data/lib/merb/template.rb +0 -37
- data/lib/merb/template/erubis.rb +0 -68
- data/lib/merb/template/haml.rb +0 -87
- data/lib/merb/template/markaby.rb +0 -59
- data/lib/merb/template/xml_builder.rb +0 -50
- data/lib/merb/test/fake_request.rb +0 -74
- data/lib/merb/test/helper.rb +0 -260
- data/lib/merb/test/hpricot.rb +0 -136
- data/lib/merb/test/multipart.rb +0 -66
- data/lib/merb/test/rspec.rb +0 -18
- data/lib/merb/test/rspec_matchers/controller_matchers.rb +0 -117
- data/lib/merb/test/rspec_matchers/markup_matchers.rb +0 -98
- data/lib/merb/upload_handler.rb +0 -80
- data/lib/merb/upload_progress.rb +0 -48
- data/lib/merb/version.rb +0 -49
- data/lib/merb/view_context.rb +0 -79
- data/lib/tasks.rb +0 -7
- data/lib/tasks/merb.rake +0 -54
- data/merb_default_generators/model/USAGE +0 -0
- data/merb_default_generators/model/model_generator.rb +0 -16
- data/merb_default_generators/model/templates/new_model_template.erb +0 -5
- data/merb_default_generators/resource_controller/USAGE +0 -0
- data/merb_default_generators/resource_controller/resource_controller_generator.rb +0 -26
- data/merb_default_generators/resource_controller/templates/controller.rb +0 -30
- data/merb_default_generators/resource_controller/templates/edit.html.erb +0 -1
- data/merb_default_generators/resource_controller/templates/helper.rb +0 -5
- data/merb_default_generators/resource_controller/templates/index.html.erb +0 -1
- data/merb_default_generators/resource_controller/templates/new.html.erb +0 -1
- data/merb_default_generators/resource_controller/templates/show.html.erb +0 -1
- data/merb_generators/controller/USAGE +0 -5
- data/merb_generators/controller/controller_generator.rb +0 -16
- data/merb_generators/controller/templates/controller.rb +0 -8
- data/merb_generators/controller/templates/helper.rb +0 -5
- data/merb_generators/controller/templates/index.html.erb +0 -3
- data/merb_generators/part_controller/USAGE +0 -5
- data/merb_generators/part_controller/part_controller_generator.rb +0 -27
- data/merb_generators/part_controller/templates/controller.rb +0 -8
- data/merb_generators/part_controller/templates/helper.rb +0 -5
- data/merb_generators/part_controller/templates/index.html.erb +0 -3
- data/merb_generators/resource/USAGE +0 -0
- data/merb_generators/resource/resource_generator.rb +0 -67
- data/rspec_generators/merb_controller_test/merb_controller_test_generator.rb +0 -67
- data/rspec_generators/merb_controller_test/templates/controller_spec.rb +0 -8
- data/rspec_generators/merb_controller_test/templates/edit_spec.rb +0 -12
- data/rspec_generators/merb_controller_test/templates/helper_spec.rb +0 -5
- data/rspec_generators/merb_controller_test/templates/index_spec.rb +0 -12
- data/rspec_generators/merb_controller_test/templates/new_spec.rb +0 -12
- data/rspec_generators/merb_controller_test/templates/show_spec.rb +0 -5
- data/rspec_generators/merb_model_test/merb_model_test_generator.rb +0 -26
- data/rspec_generators/merb_model_test/templates/model_spec_template.erb +0 -7
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/spec/fixtures/config/environments/environment_config_test.yml +0 -1
- data/spec/fixtures/config/merb.yml +0 -18
- data/spec/fixtures/controllers/dispatch_spec_controllers.rb +0 -235
- data/spec/fixtures/controllers/render_spec_controllers.rb +0 -184
- data/spec/fixtures/foo.rb +0 -3
- data/spec/fixtures/mailers/views/layout/application.html.erb +0 -3
- data/spec/fixtures/mailers/views/layout/application.text.erb +0 -3
- data/spec/fixtures/mailers/views/test_mail_controller/eighth.html.erb +0 -1
- data/spec/fixtures/mailers/views/test_mail_controller/eighth.text.erb +0 -1
- data/spec/fixtures/mailers/views/test_mail_controller/first.html.erb +0 -1
- data/spec/fixtures/mailers/views/test_mail_controller/first.text.erb +0 -1
- data/spec/fixtures/mailers/views/test_mail_controller/ninth.html.erb +0 -1
- data/spec/fixtures/mailers/views/test_mail_controller/ninth.text.erb +0 -1
- data/spec/fixtures/mailers/views/test_mail_controller/second.text.erb +0 -1
- data/spec/fixtures/mailers/views/test_mail_controller/third.html.erb +0 -1
- data/spec/fixtures/models/router_spec_models.rb +0 -30
- data/spec/fixtures/parts/views/layout/todo_part.html.erb +0 -3
- data/spec/fixtures/parts/views/layout/todo_part.xml.erb +0 -3
- data/spec/fixtures/parts/views/todo_part/formatted_output.html.erb +0 -1
- data/spec/fixtures/parts/views/todo_part/formatted_output.js.erb +0 -1
- data/spec/fixtures/parts/views/todo_part/formatted_output.xml.erb +0 -1
- data/spec/fixtures/parts/views/todo_part/list.html.erb +0 -3
- data/spec/fixtures/sample.txt +0 -1
- data/spec/fixtures/views/erubis.html.erb +0 -1
- data/spec/fixtures/views/examples/_erubis.html.erb +0 -1
- data/spec/fixtures/views/examples/_haml.html.haml +0 -1
- data/spec/fixtures/views/examples/_markaby.html.mab +0 -1
- data/spec/fixtures/views/examples/_throw_content.html.erb +0 -6
- data/spec/fixtures/views/examples/hello.xml.builder +0 -1
- data/spec/fixtures/views/examples/js.js.erb +0 -1
- data/spec/fixtures/views/examples/template_catch_content.html.erb +0 -15
- data/spec/fixtures/views/examples/template_catch_content_from_partial.html.erb +0 -6
- data/spec/fixtures/views/examples/template_throw_content.html.erb +0 -10
- data/spec/fixtures/views/examples/template_throw_content_without_block.html.erb +0 -3
- data/spec/fixtures/views/exceptions/admin_access_required.html.erb +0 -1
- data/spec/fixtures/views/extension_template_controller/_nested_js.js.erb +0 -1
- data/spec/fixtures/views/extension_template_controller/_nested_xml.xml.erb +0 -1
- data/spec/fixtures/views/extension_template_controller/_render_partial_multiple_times.html.erb +0 -1
- data/spec/fixtures/views/extension_template_controller/erubis_templates.html.erb +0 -1
- data/spec/fixtures/views/extension_template_controller/erubis_templates.js.erb +0 -1
- data/spec/fixtures/views/extension_template_controller/erubis_templates.rhtml +0 -1
- data/spec/fixtures/views/extension_template_controller/erubis_templates.xml.erb +0 -1
- data/spec/fixtures/views/extension_template_controller/haml_index.html.haml +0 -0
- data/spec/fixtures/views/extension_template_controller/haml_templates.html.haml +0 -1
- data/spec/fixtures/views/extension_template_controller/haml_templates.js.haml +0 -1
- data/spec/fixtures/views/extension_template_controller/haml_templates.xml.haml +0 -1
- data/spec/fixtures/views/extension_template_controller/index.html.erb +0 -0
- data/spec/fixtures/views/extension_template_controller/markaby_index.html.mab +0 -0
- data/spec/fixtures/views/extension_template_controller/markaby_templates.html.mab +0 -1
- data/spec/fixtures/views/extension_template_controller/markaby_templates.js.mab +0 -1
- data/spec/fixtures/views/extension_template_controller/markaby_templates.xml.mab +0 -1
- data/spec/fixtures/views/extension_template_controller/render_multiple_partials.html.erb +0 -4
- data/spec/fixtures/views/extension_template_controller/render_nested_js.js.erb +0 -1
- data/spec/fixtures/views/extension_template_controller/render_nested_xml.xml.erb +0 -1
- data/spec/fixtures/views/haml.html.haml +0 -1
- data/spec/fixtures/views/haml.xml.haml +0 -2
- data/spec/fixtures/views/layout/application.html.erb +0 -1
- data/spec/fixtures/views/layout/application.xml.erb +0 -1
- data/spec/fixtures/views/layout/nested/example.html.erb +0 -1
- data/spec/fixtures/views/markaby.html.mab +0 -1
- data/spec/fixtures/views/nested/example/test.html.erb +0 -1
- data/spec/fixtures/views/partials/_erubis.html.erb +0 -1
- data/spec/fixtures/views/partials/_erubis_collection.html.erb +0 -1
- data/spec/fixtures/views/partials/_erubis_collection_with_locals.html.erb +0 -1
- data/spec/fixtures/views/partials/_erubis_new.html.erb +0 -1
- data/spec/fixtures/views/partials/_haml.html.haml +0 -1
- data/spec/fixtures/views/partials/_haml_collection.html.haml +0 -1
- data/spec/fixtures/views/partials/_haml_collection_with_locals.html.haml +0 -1
- data/spec/fixtures/views/partials/_haml_new.html.haml +0 -1
- data/spec/fixtures/views/partials/_markaby.html.mab +0 -1
- data/spec/fixtures/views/partials/_markaby_collection.html.mab +0 -1
- data/spec/fixtures/views/partials/_markaby_collection_with_locals.html.mab +0 -1
- data/spec/fixtures/views/partials/_markaby_new.html.mab +0 -1
- data/spec/fixtures/views/render_object_controller/render_object_with_template.html.erb +0 -1
- data/spec/fixtures/views/render_object_controller/render_object_with_template.js.erb +0 -1
- data/spec/fixtures/views/render_object_controller/render_object_with_template.xml.erb +0 -1
- data/spec/fixtures/views/template_views/interface__buffer_erubis.html.erb +0 -4
- data/spec/fixtures/views/template_views/interface__buffer_haml.html.haml +0 -7
- data/spec/fixtures/views/template_views/interface__buffer_markaby.html.mab +0 -7
- data/spec/fixtures/views/template_views/interface_capture_erubis.html.erb +0 -15
- data/spec/fixtures/views/template_views/interface_capture_haml.html.haml +0 -15
- data/spec/fixtures/views/template_views/interface_capture_markaby.html.mab +0 -4
- data/spec/fixtures/views/template_views/interface_concat_erubis.html.erb +0 -12
- data/spec/fixtures/views/template_views/interface_concat_haml.html.haml +0 -11
- data/spec/fixtures/views/template_views/interface_concat_markaby.html.mab +0 -14
- data/spec/fixtures/views/test.dir/the_template.html.erb +0 -1
- data/spec/merb/abstract_controller_spec.rb +0 -38
- data/spec/merb/assets_spec.rb +0 -207
- data/spec/merb/caching_spec.rb +0 -102
- data/spec/merb/config_spec.rb +0 -29
- data/spec/merb/controller_filters_spec.rb +0 -253
- data/spec/merb/controller_spec.rb +0 -126
- data/spec/merb/cookie_store_spec.rb +0 -72
- data/spec/merb/cookies_spec.rb +0 -96
- data/spec/merb/core_ext/class_spec.rb +0 -97
- data/spec/merb/core_ext/enumerable_spec.rb +0 -27
- data/spec/merb/core_ext/hash_spec.rb +0 -251
- data/spec/merb/core_ext/inflector_spec.rb +0 -34
- data/spec/merb/core_ext/kernel_spec.rb +0 -25
- data/spec/merb/core_ext/numeric_spec.rb +0 -26
- data/spec/merb/core_ext/object_spec.rb +0 -47
- data/spec/merb/core_ext/string_spec.rb +0 -22
- data/spec/merb/core_ext/symbol_spec.rb +0 -7
- data/spec/merb/dependency_spec.rb +0 -22
- data/spec/merb/dispatch_spec.rb +0 -528
- data/spec/merb/fake_request_spec.rb +0 -80
- data/spec/merb/generator_spec.rb +0 -248
- data/spec/merb/handler_spec.rb +0 -169
- data/spec/merb/mail_controller_spec.rb +0 -177
- data/spec/merb/mailer_spec.rb +0 -87
- data/spec/merb/multipart_spec.rb +0 -50
- data/spec/merb/part_controller_spec.rb +0 -124
- data/spec/merb/plugins_spec.rb +0 -80
- data/spec/merb/render_spec.rb +0 -469
- data/spec/merb/request_spec.rb +0 -287
- data/spec/merb/responder_spec.rb +0 -562
- data/spec/merb/router_spec.rb +0 -900
- data/spec/merb/server_spec.rb +0 -19
- data/spec/merb/template_spec.rb +0 -41
- data/spec/merb/upload_handler_spec.rb +0 -108
- data/spec/merb/version_spec.rb +0 -33
- data/spec/merb/view_context_spec.rb +0 -366
- data/spec/spec_generator_helper.rb +0 -34
- data/spec/spec_helper.rb +0 -101
- data/spec/spec_helpers/url_shared_behaviour.rb +0 -112
- data/test_unit_generators/merb_controller_test/merb_controller_test_generator.rb +0 -53
- data/test_unit_generators/merb_controller_test/templates/functional_test.rb +0 -17
- data/test_unit_generators/merb_controller_test/templates/helper_test.rb +0 -9
- data/test_unit_generators/merb_model_test/merb_model_test_generator.rb +0 -29
- data/test_unit_generators/merb_model_test/templates/model_test_unit_template.erb +0 -9
data/spec/merb/config_spec.rb
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Merb::Config do
|
|
4
|
-
before(:all) do
|
|
5
|
-
@config_yml = File.expand_path(File.dirname(__FILE__) / ".." / "fixtures")
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
it "should have a default configuration" do
|
|
9
|
-
Merb::Config.defaults.should be_is_a(Hash)
|
|
10
|
-
Merb::Config.defaults[:merb_root].should == Dir.pwd
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
it "should not load the config.yml file if it does not exist" do
|
|
14
|
-
Merb::Config.setup.should be_is_a(Hash)
|
|
15
|
-
Merb::Config.setup.should == Merb::Config.defaults
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
it "should load the config.yml file if it exists" do
|
|
19
|
-
Merb::Config.defaults.merge!(:merb_root => @config_yml)
|
|
20
|
-
Merb::Config.setup.should be_is_a(Hash)
|
|
21
|
-
Merb::Config.setup[:host].should == "127.0.0.1"
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it "should accept erb in the config.yml file" do
|
|
25
|
-
Merb::Config.defaults.merge!(:merb_root => @config_yml)
|
|
26
|
-
Merb::Config.setup.should be_is_a(Hash)
|
|
27
|
-
Merb::Config.setup[:environment].should == "test"
|
|
28
|
-
end
|
|
29
|
-
end
|
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
-
|
|
3
|
-
class TestFiltersController < Merb::Controller
|
|
4
|
-
|
|
5
|
-
before :filter1
|
|
6
|
-
before :will_halt, :only => :four
|
|
7
|
-
|
|
8
|
-
before :overwrite_before_filter, :only => :two
|
|
9
|
-
after :overwrite_after_filter, :exclude => :four
|
|
10
|
-
|
|
11
|
-
after :after_will_be_skipped
|
|
12
|
-
before :before_will_be_skipped
|
|
13
|
-
|
|
14
|
-
before Proc.new {|c| c.one }, :exclude => [:one, :three, :uses_params]
|
|
15
|
-
after Proc.new {|c| c.five }, :exclude => [:one, :three, :uses_params]
|
|
16
|
-
after :filter2
|
|
17
|
-
before :modifies_param, :only => :uses_params
|
|
18
|
-
after :restores_param, :only => :uses_params
|
|
19
|
-
|
|
20
|
-
before :overwrite_before_filter, :only => :three
|
|
21
|
-
after :overwrite_after_filter, :exclude => [:one, :two, :uses_param]
|
|
22
|
-
|
|
23
|
-
skip_before :before_will_be_skipped
|
|
24
|
-
skip_after :after_will_be_skipped
|
|
25
|
-
|
|
26
|
-
# filters
|
|
27
|
-
|
|
28
|
-
def will_halt
|
|
29
|
-
throw :halt
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def filters_halted
|
|
33
|
-
"Filters Halted"
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def modifies_param
|
|
37
|
-
params[:the_param] ||= ''
|
|
38
|
-
params[:the_param_original] = params[:the_param]
|
|
39
|
-
params[:the_param] += ' is modified'
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def restores_param
|
|
43
|
-
params[:the_param] = params[:the_param_original] + ' is restored'
|
|
44
|
-
@used_params = params[:the_param]
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def filter1
|
|
48
|
-
@filter1='called'
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def filter2
|
|
52
|
-
@filter2='called'
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def before_will_be_skipped
|
|
56
|
-
@before_skip='called'
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def after_will_be_skipped
|
|
60
|
-
@after_skip='called'
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def overwrite_before_filter
|
|
64
|
-
@overwrite_before_filter='called'
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def overwrite_after_filter
|
|
68
|
-
@overwrite_after_filter='called'
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
# actions
|
|
72
|
-
|
|
73
|
-
def one
|
|
74
|
-
session.data.should == {}
|
|
75
|
-
@one = 'one'
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def two
|
|
79
|
-
@two = 'two'
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
def three
|
|
83
|
-
@three = 'three'
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
def four
|
|
87
|
-
@four = 'four'
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
def five
|
|
91
|
-
@five = 'five'
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
def uses_params
|
|
95
|
-
@uses_params = params[:the_param]
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
class TestDefaultFiltersHalted < Merb::Controller
|
|
101
|
-
before :will_halt
|
|
102
|
-
|
|
103
|
-
def will_halt
|
|
104
|
-
throw :halt
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
def one
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
class TestPrivateActions < Merb::Controller
|
|
113
|
-
|
|
114
|
-
protected
|
|
115
|
-
def notcallable1
|
|
116
|
-
"notcallable"
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
private
|
|
120
|
-
def notcallable2
|
|
121
|
-
"notcallable"
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
describe "Dispatch and before/after filters" do
|
|
127
|
-
|
|
128
|
-
def call_filter_action(action, extra_params = {})
|
|
129
|
-
@c = new_controller( action, TestFiltersController, extra_params )
|
|
130
|
-
@c.dispatch(action)
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
before :each do
|
|
134
|
-
request = Merb::Test::FakeRequest.new
|
|
135
|
-
@status, @response, @headers = 200, request.body, {'Content-Type' =>'text/html'}
|
|
136
|
-
@request, @cookies = request, {}
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
it "should not allow calling protected actions" do
|
|
140
|
-
c = new_controller( 'notcallable1', TestPrivateActions )
|
|
141
|
-
lambda {c.dispatch(:notcallable1)}.should raise_error( Merb::ControllerExceptions::ActionNotFound)
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
it "should not allow calling private actions" do
|
|
145
|
-
c = new_controller( 'notcallable2', TestPrivateActions )
|
|
146
|
-
lambda {c.dispatch(:notcallable2)}.should raise_error( Merb::ControllerExceptions::ActionNotFound)
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
it "should call a :symbol before and after filter" do
|
|
150
|
-
c = new_controller( 'one', TestFiltersController )
|
|
151
|
-
c.dispatch(:one)
|
|
152
|
-
c.body.should == 'one'
|
|
153
|
-
c.instance_variable_get('@one').should == 'one'
|
|
154
|
-
c.instance_variable_get('@two').should == nil
|
|
155
|
-
c.instance_variable_get('@three').should == nil
|
|
156
|
-
c.instance_variable_get('@filter1').should == 'called'
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
it "should be able to see instance variables" do
|
|
160
|
-
call_filter_action "one"
|
|
161
|
-
@c.cookies.should be_is_a(Merb::Cookies)
|
|
162
|
-
@c.session.data.should == {}
|
|
163
|
-
@c.response.read.should == ""
|
|
164
|
-
@c.instance_variable_get("@filter1").should eql( 'called')
|
|
165
|
-
@c.instance_variable_get("@one").should eql( 'one')
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
it "should ignore actions specified by :exclude" do
|
|
169
|
-
call_filter_action "three"
|
|
170
|
-
@c.instance_variable_get("@one").should be_nil
|
|
171
|
-
@c.instance_variable_get("@five").should be_nil
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
it "should be able to see params in the before filter" do
|
|
175
|
-
call_filter_action "uses_params", :the_param => 'the param'
|
|
176
|
-
@c.instance_variable_get("@uses_params").should eql( 'the param is modified')
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
it "should be able to see params in the after filter" do
|
|
180
|
-
call_filter_action "uses_params", :the_param => 'the param'
|
|
181
|
-
@c.instance_variable_get("@used_params").should eql( 'the param is restored')
|
|
182
|
-
end
|
|
183
|
-
|
|
184
|
-
it "should call a Proc before and after filter" do
|
|
185
|
-
c = new_controller( 'two', TestFiltersController )
|
|
186
|
-
c.dispatch(:two)
|
|
187
|
-
c.body.should == 'two'
|
|
188
|
-
c.instance_variable_get('@one').should == 'one'
|
|
189
|
-
c.instance_variable_get('@two').should == 'two'
|
|
190
|
-
c.instance_variable_get('@three').should == nil
|
|
191
|
-
c.instance_variable_get('@five').should == 'five'
|
|
192
|
-
end
|
|
193
|
-
|
|
194
|
-
it "should call filters_halted when throw :halt" do
|
|
195
|
-
c = new_controller( 'four', TestFiltersController )
|
|
196
|
-
c.dispatch(:four)
|
|
197
|
-
c.body.should == "Filters Halted"
|
|
198
|
-
c.instance_variable_get('@one').should == nil
|
|
199
|
-
c.instance_variable_get('@two').should == nil
|
|
200
|
-
c.instance_variable_get('@three').should == nil
|
|
201
|
-
c.instance_variable_get('@filter1').should == 'called'
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
it "should have a default filter halted page" do
|
|
205
|
-
c = new_controller( 'one', TestFiltersController )
|
|
206
|
-
c.dispatch(:one)
|
|
207
|
-
end
|
|
208
|
-
|
|
209
|
-
it "should not allow both :only and :exclude" do
|
|
210
|
-
["before", "after"].each do |filter_type|
|
|
211
|
-
lambda { TestFiltersController.send(filter_type, :x, :only => :foo, :exclude => :bar) }.should raise_error(ArgumentError)
|
|
212
|
-
end
|
|
213
|
-
end
|
|
214
|
-
|
|
215
|
-
it "should not allow a filter that is not a symbol, string, or proc" do
|
|
216
|
-
["before", "after"].each do |filter_type|
|
|
217
|
-
lambda { TestFiltersController.send(filter_type, []) }.should raise_error(ArgumentError)
|
|
218
|
-
end
|
|
219
|
-
end
|
|
220
|
-
|
|
221
|
-
it "should be overwritten by a subsequent call with the same filter" do
|
|
222
|
-
c = new_controller( 'two', TestFiltersController )
|
|
223
|
-
c.dispatch(:two)
|
|
224
|
-
c.body.should == 'two'
|
|
225
|
-
c.instance_variable_get('@overwrite_before_filter').should == nil
|
|
226
|
-
c.instance_variable_get('@overwrite_after_filter').should == nil
|
|
227
|
-
|
|
228
|
-
c = new_controller( 'three', TestFiltersController )
|
|
229
|
-
c.dispatch(:three)
|
|
230
|
-
c.body.should == 'three'
|
|
231
|
-
c.instance_variable_get('@overwrite_before_filter').should == 'called'
|
|
232
|
-
c.instance_variable_get('@overwrite_after_filter').should == 'called'
|
|
233
|
-
end
|
|
234
|
-
|
|
235
|
-
it "should not run if skipped" do
|
|
236
|
-
c = new_controller( 'one', TestFiltersController )
|
|
237
|
-
c.dispatch(:one)
|
|
238
|
-
c.body.should == 'one'
|
|
239
|
-
c.instance_variable_get('@one').should == 'one'
|
|
240
|
-
c.instance_variable_get('@two').should == nil
|
|
241
|
-
c.instance_variable_get('@three').should == nil
|
|
242
|
-
|
|
243
|
-
c.instance_variable_get('@before_skip').should == nil
|
|
244
|
-
c.instance_variable_get('@after_skip').should == nil
|
|
245
|
-
end
|
|
246
|
-
|
|
247
|
-
it "should not allow skipping a filter that is not a symbol or string" do
|
|
248
|
-
["before", "after"].each do |filter_type|
|
|
249
|
-
lambda { TestFiltersController.send('skip_'+filter_type, Proc.new{|c|puts c}) }.should raise_error(ArgumentError)
|
|
250
|
-
end
|
|
251
|
-
end
|
|
252
|
-
|
|
253
|
-
end
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
require 'ostruct'
|
|
2
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
|
3
|
-
|
|
4
|
-
describe "Merb::Controller" do
|
|
5
|
-
|
|
6
|
-
# not sure what this tests
|
|
7
|
-
# it "should instantiate" do
|
|
8
|
-
# c = new_controller
|
|
9
|
-
# @request.env.should == c.request.env
|
|
10
|
-
# end
|
|
11
|
-
|
|
12
|
-
it "should have a default layout of application.rhtml" do
|
|
13
|
-
c = new_controller
|
|
14
|
-
c._layout.should == :application
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it "should have a spec helper to dispatch that skips the router" do
|
|
18
|
-
Merb::Router.should_not_receive(:match)
|
|
19
|
-
dispatch_to(Bar, :foo, :id => "1") do |controller|
|
|
20
|
-
if defined? ParseTreeArray # We have parameterized actions
|
|
21
|
-
controller.should_receive(:foo).with("1")
|
|
22
|
-
else
|
|
23
|
-
controller.should_receive(:foo) # No parameterized actions
|
|
24
|
-
controller.params[:id].should == "1"
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
describe Merb::Controller, "url generator tests" do
|
|
32
|
-
|
|
33
|
-
it_should_behave_like "class with general url generation"
|
|
34
|
-
|
|
35
|
-
def new_url_controller(route, params = {:action => 'show', :controller => 'Test'})
|
|
36
|
-
request = OpenStruct.new
|
|
37
|
-
request.route = route
|
|
38
|
-
request.params = params
|
|
39
|
-
response = OpenStruct.new
|
|
40
|
-
response.read = ""
|
|
41
|
-
|
|
42
|
-
Merb::Controller.build(request, response)
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
it "should generate a default route url with just :action" do
|
|
46
|
-
c = new_url_controller(@default_route, :controller => "foo")
|
|
47
|
-
c.url(:action => "baz").should == "/foo/baz"
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
it "should generate a default route url with just :id" do
|
|
51
|
-
c = new_url_controller(@default_route, :controller => "foo", :action => "bar")
|
|
52
|
-
c.url(:id => "23").should == "/foo/bar/23"
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
it "should generate a default route url with an extra param" do
|
|
56
|
-
c = new_url_controller(@default_route, :controller => "foo", :action => "bar")
|
|
57
|
-
c.url(:controller => :current, :monkey => "quux").should == "/foo/bar?monkey=quux"
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
it "should generate a default route url with extra params" do
|
|
61
|
-
c = new_url_controller(@default_route, :controller => "foo", :action => "bar")
|
|
62
|
-
url = c.url(:controller => :current, :monkey => "quux", :cow => "moo")
|
|
63
|
-
url.should match(%r{/foo/bar?.*monkey=quux})
|
|
64
|
-
url.should match(%r{/foo/bar?.*cow=moo})
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
it "should generate a default route url with extra params and an array" do
|
|
68
|
-
c = new_url_controller(@default_route, :controller => "foo", :action => "bar")
|
|
69
|
-
c.url(:controller => :current, :monkey => [1,2]).should == "/foo/bar?monkey[]=1&monkey[]=2"
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
it "should generate a default route url with extra params and a hash" do
|
|
73
|
-
c = new_url_controller(@default_route, :controller => "foo", :action => "bar")
|
|
74
|
-
c.url(:controller => :current, :animals => {:cow => "moo"}).should == "/foo/bar?animals[cow]=moo"
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
it "should generate a default route url with :action and :format" do
|
|
78
|
-
c = new_url_controller(@default_route, :controller => "foo", :action => "bar")
|
|
79
|
-
c.url(:action => :recent, :format => :txt).should == "/foo/recent.txt"
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
it "should handle nested nested and more nested hashes and arrays" do
|
|
83
|
-
c = new_url_controller(@default_route, :controller => "foo", :action => "bar")
|
|
84
|
-
url = c.url(:controller => :current, :user => {:filter => {:name => "quux*"}, :order => ["name"]})
|
|
85
|
-
url.should match(%r{/foo/bar?.*user\[filter\]\[name\]=quux%2A})
|
|
86
|
-
url.should match(%r{/foo/bar?.*user\[order\]\[\]=name})
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
describe "Controller", "redirect spec helpers" do
|
|
91
|
-
class Redirector < Merb::Controller
|
|
92
|
-
def index
|
|
93
|
-
redirect("/foo")
|
|
94
|
-
end
|
|
95
|
-
def show
|
|
96
|
-
end
|
|
97
|
-
def permanent
|
|
98
|
-
redirect("/foo",:permanent)
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
before(:each) do
|
|
103
|
-
@controller = Redirector.build(fake_request)
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
it "should be able to match redirects" do
|
|
107
|
-
@controller.dispatch('index')
|
|
108
|
-
@controller.status.should be_redirect
|
|
109
|
-
@controller.should redirect
|
|
110
|
-
@controller.should redirect_to("/foo")
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
it "should be able to negative match redirects" do
|
|
114
|
-
@controller.dispatch('show')
|
|
115
|
-
@controller.status.should_not be_redirect
|
|
116
|
-
@controller.should_not redirect
|
|
117
|
-
@controller.should_not redirect_to("/foo")
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
it "should be able to match permanent redirects" do
|
|
121
|
-
@controller.dispatch('permanent')
|
|
122
|
-
@controller.status.should be_redirect
|
|
123
|
-
@controller.should redirect
|
|
124
|
-
@controller.should redirect_to("/foo")
|
|
125
|
-
end
|
|
126
|
-
end
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
-
|
|
3
|
-
require "merb/session/cookie_store"
|
|
4
|
-
|
|
5
|
-
class Merb::Controller
|
|
6
|
-
include ::Merb::SessionMixin
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
class TestCookieSessionController < Merb::Controller
|
|
10
|
-
|
|
11
|
-
def change
|
|
12
|
-
session[:hello] = 'world'
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def no_change
|
|
16
|
-
"test"
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
Merb::Config[:session_secret_key] = 'Secret!'
|
|
22
|
-
|
|
23
|
-
describe Merb::SessionMixin do
|
|
24
|
-
it "should set the cookie if the cookie is changed" do
|
|
25
|
-
c = new_controller( 'change', TestCookieSessionController)
|
|
26
|
-
c.dispatch(:change)
|
|
27
|
-
c.headers['Set-Cookie'].each {|c| c.should =~ %r{_session_id=} }# this could be better
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
describe Merb::CookieStore do
|
|
32
|
-
|
|
33
|
-
before(:each) do
|
|
34
|
-
@secret = 'Keep it secret; keep it safe.'
|
|
35
|
-
@cookies = {
|
|
36
|
-
:empty => ['BAgw--0686dcaccc01040f4bd4f35fe160afe9bc04c330', {}],
|
|
37
|
-
:a_one => ['BAh7BiIGYWkG--5689059497d7f122a7119f171aef81dcfd807fec', { 'a' => 1 }],
|
|
38
|
-
:typical => ['BAh7ByIMdXNlcl9pZGkBeyIKZmxhc2h7BiILbm90aWNlIgxIZXkgbm93--9d20154623b9eeea05c62ab819be0e2483238759', { 'user_id' => 123, 'flash' => { 'notice' => 'Hey now' }}],
|
|
39
|
-
:flashed => ['BAh7ByIMdXNlcl9pZGkBeyIKZmxhc2h7AA%3D%3D--bf9785a666d3c4ac09f7fe3353496b437546cfbf', { 'user_id' => 123, 'flash' => {} }]
|
|
40
|
-
}
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
it "should raise argument error if missing secret key" do
|
|
44
|
-
lambda { Merb::CookieStore.new(nil, nil) }.should raise_error(ArgumentError)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
it "should restore and unmarshal good cookies" do
|
|
48
|
-
@cookies.values_at(:empty, :a_one, :typical).each do |value, expected|
|
|
49
|
-
session = Merb::CookieStore.new(value, @secret)
|
|
50
|
-
session['lazy loads the data hash'].should be_nil
|
|
51
|
-
session.data.should == expected
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
it "should raise error on tampered cookie" do
|
|
56
|
-
lambda { Merb::CookieStore.new('a--b', @secret) }.should
|
|
57
|
-
raise_error(Merb::CookieStore::TamperedWithCookie)
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
it "should raise when data overflows" do
|
|
61
|
-
session = Merb::CookieStore.new(@cookies[:empty].first, @secret)
|
|
62
|
-
session['overflow'] = 'bye!' * 1024
|
|
63
|
-
lambda { session.read_cookie }.should
|
|
64
|
-
raise_error(Merb::CookieStore::CookieOverflow)
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
it "should delete entries in the session" do
|
|
68
|
-
session = Merb::CookieStore.new(@cookies[:a_one].first, @secret)
|
|
69
|
-
session.delete('a').should == 1
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
end
|