rad_core 0.0.13 → 0.0.14
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 +4 -3
- data/lib/components/config.rb +6 -0
- data/lib/components/controller.rb +5 -0
- data/lib/components/controller.yml +3 -0
- data/lib/components/conveyors.rb +7 -0
- data/lib/components/environment.rb +5 -0
- data/lib/components/environment.yml +3 -0
- data/lib/components/flash.rb +5 -0
- data/lib/components/html.rb +4 -0
- data/lib/components/html.yml +3 -0
- data/lib/components/http.rb +6 -0
- data/lib/components/http.yml +13 -0
- data/lib/components/logger.rb +5 -0
- data/lib/components/mailer.rb +9 -0
- data/lib/components/remote.rb +4 -0
- data/lib/components/router.rb +13 -0
- data/lib/components/router.yml +2 -0
- data/lib/components/template.rb +8 -0
- data/lib/components/template.yml +1 -0
- data/lib/components/web.rb +8 -0
- data/lib/components/workspace.rb +1 -0
- data/lib/rad/{support → _support}/active_support/locales/en/actionpack.yml +0 -0
- data/lib/rad/{support → _support}/active_support/locales/en/activesupport.yml +0 -0
- data/lib/rad/_support/active_support/locales/ru/actionview.yml +162 -0
- data/lib/rad/_support/active_support/locales/ru/activesupport.yml +16 -0
- data/lib/rad/_support/active_support/locales/ru/datetime.yml +49 -0
- data/lib/rad/{support → _support}/active_support/micelaneous.rb +0 -0
- data/lib/rad/{support → _support}/active_support/time.rb +0 -0
- data/lib/rad/{support → _support}/active_support.rb +14 -2
- data/lib/rad/{support → _support}/addressable.rb +0 -0
- data/lib/rad/_support/callbacks.rb +166 -0
- data/lib/rad/_support/class_loader.rb +9 -0
- data/lib/rad/_support/encoding.rb +3 -0
- data/lib/rad/_support/exception.rb +45 -0
- data/lib/rad/_support/extensions.rb +20 -0
- data/lib/rad/_support/filters.rb +32 -0
- data/lib/rad/{support → _support}/hacks_and_fixes.rb +0 -0
- data/lib/rad/{support → _support}/mime.rb +6 -0
- data/lib/rad/{support → _support}/module.rb +7 -9
- data/lib/rad/_support/require.rb +62 -0
- data/lib/rad/{support → _support}/rson.rb +0 -0
- data/lib/rad/{support → _support}/ruby_ext_with_active_support.rb +0 -0
- data/lib/rad/{support → _support}/string.rb +9 -1
- data/lib/rad/controller/_abstract/micelaneous.rb +27 -0
- data/lib/rad/controller/_abstract/render.rb +159 -0
- data/lib/rad/controller/_abstract/responder.rb +13 -0
- data/lib/rad/controller/_abstract.rb +37 -0
- data/lib/rad/controller/_context.rb +15 -0
- data/lib/rad/controller/_http.rb +50 -0
- data/lib/rad/controller/_require.rb +19 -0
- data/lib/rad/controller/abstract.rb +1 -0
- data/lib/rad/controller/context.rb +1 -0
- data/lib/rad/controller/http.rb +1 -0
- data/lib/rad/controller/processors/controller_caller.rb +22 -24
- data/lib/rad/controller/processors/controller_error_handling.rb +46 -48
- data/lib/rad/controller/processors/controller_logger.rb +7 -9
- data/lib/rad/controller.rb +1 -28
- data/lib/rad/conveyors/_conveyor.rb +73 -0
- data/lib/rad/conveyors/_conveyors.rb +19 -0
- data/lib/rad/conveyors/_params.rb +10 -0
- data/lib/rad/conveyors/_processor.rb +13 -0
- data/lib/rad/conveyors/_require.rb +10 -0
- data/lib/rad/conveyors/_workspace.rb +34 -0
- data/lib/rad/conveyors/params.rb +1 -0
- data/lib/rad/conveyors/processor.rb +1 -0
- data/lib/rad/conveyors/processors/conveyor_logger.rb +23 -0
- data/lib/rad/conveyors/workspace.rb +1 -0
- data/lib/rad/conveyors.rb +1 -0
- data/lib/rad/core_web/_controller_micelaneous_helper.rb +17 -0
- data/lib/rad/core_web/_require.rb +25 -0
- data/lib/rad/core_web/_router/abstract_routing_helper.rb +20 -0
- data/lib/rad/core_web/_router/controller_routing_helper.rb +56 -0
- data/lib/rad/core_web/_router/view_routing_helper.rb +57 -0
- data/lib/rad/environment/_config.rb +27 -0
- data/lib/rad/environment/_environment.rb +17 -0
- data/lib/rad/environment/_files_helper.rb +55 -0
- data/lib/rad/environment/_logger.rb +53 -0
- data/lib/rad/environment/_require.rb +24 -0
- data/lib/rad/environment/config.rb +1 -111
- data/lib/rad/environment.rb +1 -55
- data/lib/{rad_core → rad}/gems.rb +2 -3
- data/lib/rad/html/_flash.rb +40 -0
- data/lib/rad/html/_helpers/basic_html_helper.rb +72 -0
- data/lib/rad/html/_helpers/flash_helper.rb +3 -0
- data/lib/rad/html/_helpers/form_helper.rb +114 -0
- data/lib/rad/html/_helpers/html_helper.rb +3 -0
- data/lib/rad/html/_helpers/javascript_helper.rb +27 -0
- data/lib/rad/html/_helpers/model_helper.rb +143 -0
- data/lib/rad/html/_require.rb +15 -0
- data/lib/rad/html/processors/prepare_flash.rb +22 -23
- data/lib/rad/html/processors/scoped_params.rb +18 -21
- data/lib/rad/html.rb +1 -26
- data/lib/rad/http/_http.rb +11 -0
- data/lib/rad/http/_http_adapter.rb +44 -0
- data/lib/rad/http/_request.rb +50 -0
- data/lib/rad/http/_require.rb +33 -0
- data/lib/rad/http/_response.rb +84 -0
- data/lib/rad/http/{support → _support}/rack/fixes.rb +0 -0
- data/lib/rad/http/_support/rack/rack_adapter.rb +57 -0
- data/lib/rad/http/processors/evaluate_format.rb +16 -19
- data/lib/rad/http/processors/http_logger.rb +10 -12
- data/lib/rad/http/processors/http_writer.rb +24 -26
- data/lib/rad/http/processors/prepare_params.rb +19 -18
- data/lib/rad/http/request.rb +1 -0
- data/lib/rad/http/response.rb +1 -0
- data/lib/rad/http.rb +1 -48
- data/lib/rad/mailer/_letter.rb +28 -0
- data/lib/rad/mailer/_mailer.rb +13 -0
- data/lib/rad/mailer/_mailer_controller.rb +38 -0
- data/lib/rad/mailer/_require.rb +7 -0
- data/lib/rad/mailer/mailer_controller.rb +1 -0
- data/lib/rad/mailer/processors/letter_builder.rb +34 -0
- data/lib/rad/mailer.rb +1 -0
- data/lib/rad/profiles/mailer.rb +5 -0
- data/lib/rad/profiles/web.rb +29 -52
- data/lib/rad/remote/_remote_controller.rb +9 -0
- data/lib/rad/remote/_require.rb +6 -0
- data/lib/rad/remote/processors/remote_caller.rb +44 -46
- data/lib/rad/remote/processors/remote_logger.rb +8 -10
- data/lib/rad/remote/remote_controller.rb +1 -0
- data/lib/rad/remote.rb +1 -9
- data/lib/rad/router/_abstract_router.rb +50 -0
- data/lib/rad/router/_alias_router.rb +124 -0
- data/lib/rad/router/_basic_router.rb +72 -0
- data/lib/rad/router/_configurator.rb +19 -0
- data/lib/rad/router/_core_routing_helper.rb +39 -0
- data/lib/rad/router/_default_format_processor.rb +10 -0
- data/lib/rad/router/_object_router.rb +184 -0
- data/lib/rad/router/_require.rb +31 -0
- data/lib/rad/router/_restful_router.rb +124 -0
- data/lib/rad/router/_router.rb +294 -0
- data/lib/rad/router/_simple_router.rb +21 -0
- data/lib/rad/router/abstract_router.rb +1 -0
- data/lib/rad/router/alias_router.rb +1 -0
- data/lib/rad/router/configurator.rb +1 -0
- data/lib/rad/router/micelaneous_router.rb +1 -0
- data/lib/rad/router/object_router.rb +1 -0
- data/lib/rad/router/processors/router.rb +23 -0
- data/lib/rad/router/restful_router.rb +1 -0
- data/lib/rad/{html/include_into_controller.rb → router/simple_router.rb} +0 -0
- data/lib/rad/router.rb +1 -29
- data/lib/rad/spec/controller.rb +20 -11
- data/lib/rad/spec/environment.rb +22 -38
- data/lib/rad/spec/http.rb +13 -86
- data/lib/rad/spec/http_controller.rb +105 -0
- data/lib/rad/spec/mailer.rb +27 -0
- data/lib/rad/spec/remote.rb +2 -2
- data/lib/rad/spec/router.rb +9 -11
- data/lib/rad/spec/template.rb +8 -2
- data/lib/rad/spec/xhtml.rb +0 -2
- data/lib/rad/spec.rb +4 -2
- data/lib/rad/template/_context.rb +92 -0
- data/lib/rad/template/_relative_path_resolver.rb +8 -0
- data/lib/rad/template/_require.rb +15 -0
- data/lib/rad/template/{support → _support}/tilt.rb +0 -0
- data/lib/rad/template/{support → _support}/tilt_fixes.rb +0 -0
- data/lib/rad/template/_template.rb +175 -0
- data/lib/rad/template/template_context.rb +1 -62
- data/lib/rad/template.rb +1 -25
- data/lib/rad.rb +8 -0
- data/readme.md +40 -12
- data/spec/controller/{abstract_controller_spec → abstract_spec}/views/OperationsOrderSpec/action.erb +0 -0
- data/spec/controller/{abstract_controller_spec → abstract_spec}/views/ViewVariablesSpec/action.erb +0 -0
- data/spec/controller/abstract_spec.rb +126 -0
- data/spec/controller/{controller_context_spec/views/ItemSpec → context_spec/views/NamespaceSpec/ClassSpec}/show.erb +0 -0
- data/spec/controller/{controller_context_spec/views/ItemSpec → context_spec/views/item_spec}/actions.erb +0 -0
- data/spec/controller/{controller_context_spec/views/NamespaceSpec/ClassSpec → context_spec/views/item_spec}/show.erb +0 -0
- data/spec/controller/{controller_context_spec/views/ItemSpec → context_spec/views/item_spec}/update.erb +0 -0
- data/spec/controller/{controller_context_spec → context_spec}/views/namespace_spec/class_spec/update.erb +0 -0
- data/spec/controller/{controller_context_spec/views/PageSpec → context_spec/views/page_spec}/actions.erb +0 -0
- data/spec/controller/{controller_context_spec/views/PageSpec → context_spec/views/page_spec}/show.erb +0 -0
- data/spec/controller/context_spec.rb +123 -0
- data/spec/controller/error_handling_spec.rb +21 -27
- data/spec/controller/{controller_helper_spec → helper_spec}/views/HelperMethodSpec/action.erb +0 -0
- data/spec/controller/{controller_helper_spec → helper_spec}/views/HelperSpec/action.erb +0 -0
- data/spec/controller/{controller_helper_spec.rb → helper_spec.rb} +7 -13
- data/spec/controller/{http_controller_spec.rb → http_spec.rb} +17 -23
- data/spec/controller/{controller_render_spec/views/AlreadyRenderedSpec → render_spec/views/already_rendered_spec}/action.erb +0 -0
- data/spec/controller/{controller_render_spec/views/AlreadyRenderedSpec → render_spec/views/already_rendered_spec}/custom_template.erb +0 -0
- data/spec/controller/{controller_render_spec/views/AnotherActionSpec → render_spec/views/another_action_spec}/another_action.erb +0 -0
- data/spec/controller/{controller_render_spec/views/AnotherLayout → render_spec/views/another_layout}/action.erb +0 -0
- data/spec/controller/{controller_render_spec/views/ForbidPartialAsActionSpec → render_spec/views/forbid_partial_as_action_spec}/_action.erb +0 -0
- data/spec/controller/{controller_render_spec/views/FormatSpec → render_spec/views/format_spec}/action.html.erb +0 -0
- data/spec/controller/{controller_render_spec/views/FormatSpec → render_spec/views/format_spec}/action.js.erb +0 -0
- data/spec/controller/{controller_render_spec/views/LayoutFiltersSpec → render_spec/views/layout_filters_spec}/action_with_layout.erb +0 -0
- data/spec/controller/{controller_render_spec/views/LayoutFiltersSpec → render_spec/views/layout_filters_spec}/action_without_layout.erb +0 -0
- data/spec/controller/{controller_render_spec/views/LayoutSpec → render_spec/views/layout_spec}/action.erb +0 -0
- data/spec/controller/{controller_render_spec → render_spec}/views/layouts/admin.erb +0 -0
- data/spec/controller/{controller_render_spec → render_spec}/views/layouts/app.html.erb +0 -0
- data/spec/controller/{controller_render_spec → render_spec}/views/layouts/app.js.erb +0 -0
- data/spec/controller/{controller_render_spec/views/MultipleActions → render_spec/views/multiple_actions}/actions.haml +0 -0
- data/spec/controller/render_spec/views/relative_spec/a/form.erb +1 -0
- data/spec/controller/render_spec/views/relative_spec/a/show.erb +1 -0
- data/spec/controller/render_spec/views/relative_spec/b/form.erb +1 -0
- data/spec/controller/{controller_render_spec → render_spec}/views/some_template.erb +0 -0
- data/spec/controller/{controller_render_spec → render_spec}/views/standalone.html.erb +0 -0
- data/spec/controller/{controller_render_spec.rb → render_spec.rb} +37 -27
- data/spec/{conveyor/conveyor_spec.rb → conveyors/conveyors_spec.rb} +36 -14
- data/spec/environment/config_spec.rb +13 -21
- data/spec/environment/environment_spec.rb +14 -41
- data/spec/environment/logger_spec.rb +4 -13
- data/spec/environment/minimal_app_spec/app.rb +1 -1
- data/spec/environment/minimal_app_spec.rb +12 -14
- data/spec/environment/standard_app_spec/app/lib/app/init.rb +1 -1
- data/spec/environment/standard_app_spec/plugin_a/lib/plugin_a/init.rb +1 -1
- data/spec/environment/standard_app_spec.rb +17 -25
- data/spec/html/basic_html_helper_spec.rb +7 -4
- data/spec/html/form_helper_spec.rb +5 -5
- data/spec/html/javascript_helper_spec.rb +9 -5
- data/spec/html/model_helper_spec.rb +9 -6
- data/spec/html/scoped_params_spec.rb +2 -2
- data/spec/html/spec_helper.rb +16 -24
- data/spec/http/http_spec.rb +14 -35
- data/spec/http/micelaneous_spec.rb +3 -3
- data/spec/{mail → mailer}/mail_controller_spec/views/body_template_spec/signup.erb +0 -0
- data/spec/{mail → mailer}/mail_controller_spec.rb +36 -12
- data/spec/mailer/spec_helper.rb +5 -0
- data/spec/remote/remote_spec.rb +23 -8
- data/spec/router/alias_router_spec.rb +29 -30
- data/spec/router/basic_router_spec.rb +44 -0
- data/spec/router/configurator_spec.rb +9 -6
- data/spec/router/integration_spec.rb +10 -7
- data/spec/router/object_router_spec.rb +186 -0
- data/spec/router/persistent_params_spec.rb +4 -4
- data/spec/router/restful_router_spec.rb +61 -53
- data/spec/router/{basic_spec.rb → router_spec.rb} +26 -23
- data/spec/router/routing_helper_spec.rb +5 -6
- data/spec/spec_helper.rb +4 -0
- data/spec/support/callbacks_spec.rb +1 -1
- data/spec/support/filters_spec.rb +2 -2
- data/spec/support/spec_helper.rb +1 -1
- data/spec/template/template_spec/views/format_for_partials/dialog.js.erb +1 -1
- data/spec/template/template_spec/views/nested/format/a.erb +1 -1
- data/spec/template/template_spec/views/nested/format/b.js.erb +1 -0
- data/spec/template/template_spec/views/nesting_format/dialog.js.erb +1 -1
- data/spec/template/template_spec.rb +62 -48
- data/spec/template/tilt_spec/views/concat_and_capture.erb +1 -1
- data/spec/template/tilt_spec/views/concat_and_capture.haml +1 -1
- data/spec/template/tilt_spec.rb +17 -19
- data/spec/{integration → web}/basic_spec/views/smoke_test_spec/action.erb +0 -0
- data/spec/{integration → web}/basic_spec.rb +31 -12
- data/spec/{integration → web}/controller_routing_helper_spec.rb +13 -11
- data/spec/{integration → web}/flash_spec.rb +57 -42
- data/spec/{integration → web}/spec_helper_spec.rb +11 -10
- data/spec/{integration → web}/view_routing_helper_spec.rb +44 -36
- metadata +338 -318
- data/lib/rad/controller/abstract_controller/micelaneous.rb +0 -31
- data/lib/rad/controller/abstract_controller/render.rb +0 -160
- data/lib/rad/controller/abstract_controller/responder.rb +0 -17
- data/lib/rad/controller/abstract_controller.rb +0 -64
- data/lib/rad/controller/controller_context.rb +0 -15
- data/lib/rad/controller/http_controller.rb +0 -48
- data/lib/rad/conveyor/conveyor.rb +0 -74
- data/lib/rad/conveyor/conveyors.rb +0 -20
- data/lib/rad/conveyor/params.rb +0 -14
- data/lib/rad/conveyor/processor.rb +0 -68
- data/lib/rad/conveyor/processors/conveyor_logger.rb +0 -25
- data/lib/rad/conveyor/workspace.rb +0 -36
- data/lib/rad/conveyor.rb +0 -29
- data/lib/rad/environment/dependency_resolver.rb +0 -107
- data/lib/rad/environment/environment.rb +0 -29
- data/lib/rad/environment/files_helper.rb +0 -55
- data/lib/rad/environment/logger.rb +0 -21
- data/lib/rad/html/flash.rb +0 -42
- data/lib/rad/html/helpers/basic_html_helper.rb +0 -83
- data/lib/rad/html/helpers/flash_helper.rb +0 -5
- data/lib/rad/html/helpers/form_helper.rb +0 -115
- data/lib/rad/html/helpers/html_helper.rb +0 -5
- data/lib/rad/html/helpers/javascript_helper.rb +0 -18
- data/lib/rad/html/helpers/model_helper.rb +0 -135
- data/lib/rad/http/http.rb +0 -21
- data/lib/rad/http/http_adapter.rb +0 -36
- data/lib/rad/http/middleware/static_files.rb +0 -21
- data/lib/rad/http/support/rack/rack_adapter.rb +0 -67
- data/lib/rad/http/support/rack/request.rb +0 -42
- data/lib/rad/http/support/rack/response.rb +0 -86
- data/lib/rad/integration/controller_micelaneous_helper.rb +0 -19
- data/lib/rad/integration/router/abstract_routing_helper.rb +0 -22
- data/lib/rad/integration/router/controller_routing_helper.rb +0 -58
- data/lib/rad/integration/router/view_routing_helper.rb +0 -104
- data/lib/rad/integration.rb +0 -30
- data/lib/rad/mail/letter.rb +0 -30
- data/lib/rad/mail/mail_controller.rb +0 -31
- data/lib/rad/mail/mailer.rb +0 -23
- data/lib/rad/mail/processors/letter_builder.rb +0 -36
- data/lib/rad/mail.rb +0 -15
- data/lib/rad/profiles/mail.rb +0 -16
- data/lib/rad/profiles/web_require.rb +0 -5
- data/lib/rad/remote/remote.rb +0 -15
- data/lib/rad/router/core/configurator.rb +0 -25
- data/lib/rad/router/core/core_routing_helper.rb +0 -41
- data/lib/rad/router/core/default_format_processor.rb +0 -12
- data/lib/rad/router/core/processors/router.rb +0 -29
- data/lib/rad/router/core/router.rb +0 -271
- data/lib/rad/router/core/simple_router.rb +0 -23
- data/lib/rad/router/routers/abstract_router.rb +0 -62
- data/lib/rad/router/routers/alias_router.rb +0 -113
- data/lib/rad/router/routers/restful_router.rb +0 -113
- data/lib/rad/spec/mail.rb +0 -31
- data/lib/rad/spec/view.rb +0 -10
- data/lib/rad/support/buffered_logger.rb +0 -44
- data/lib/rad/support/callbacks.rb +0 -168
- data/lib/rad/support/exception.rb +0 -31
- data/lib/rad/support/filters.rb +0 -34
- data/lib/rad/support/format.rb +0 -17
- data/lib/rad/support/micon.rb +0 -13
- data/lib/rad/support.rb +0 -63
- data/lib/rad/template/template.rb +0 -250
- data/spec/controller/abstract_controller_spec.rb +0 -132
- data/spec/controller/controller_context_spec.rb +0 -123
- data/spec/controller/controller_render_spec/views/rem ExplicitRenderSpec/action.erb +0 -1
- data/spec/controller/controller_render_spec/views/rem ExplicitRenderSpec/another_action.erb +0 -1
- data/spec/controller/spec_helper.rb +0 -19
- data/spec/conveyor/spec_helper.rb +0 -3
- data/spec/environment/config_spec/config.default.yml +0 -3
- data/spec/environment/config_spec/config.development.yml +0 -3
- data/spec/environment/config_spec/config.yml +0 -5
- data/spec/environment/spec_helper.rb +0 -1
- data/spec/http/http_spec/app/lib/app/init.rb +0 -10
- data/spec/http/http_spec/app/runtime/public/emptygit +0 -0
- data/spec/http/http_spec/plugin_a/lib/plugin_a/init.rb +0 -0
- data/spec/http/http_spec/plugin_b/lib/plugin_b/init.rb +0 -5
- data/spec/http/http_spec/plugin_b/static/emptygit +0 -0
- data/spec/http/spec_helper.rb +0 -5
- data/spec/integration/spec_helper.rb +0 -5
- data/spec/mail/spec_helper.rb +0 -7
- data/spec/remote/spec_helper.rb +0 -17
- data/spec/router/spec_helper.rb +0 -20
- data/spec/template/spec_helper.rb +0 -6
- data/spec/template/template_spec/views/nested/format/b.erb +0 -1
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
require '
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe "Router Basic" do
|
|
4
|
-
|
|
5
|
-
before :all do
|
|
3
|
+
describe "Router Basic" do
|
|
4
|
+
before :all do
|
|
6
5
|
class ::BlogsController
|
|
7
|
-
include Rad::CoreRoutingHelper
|
|
6
|
+
include Rad::Router::CoreRoutingHelper
|
|
8
7
|
|
|
9
8
|
def show; end
|
|
10
9
|
end
|
|
@@ -14,42 +13,40 @@ describe "Router Basic" do
|
|
|
14
13
|
remove_constants %w(BlogsController)
|
|
15
14
|
end
|
|
16
15
|
|
|
17
|
-
before
|
|
16
|
+
before do
|
|
18
17
|
@router = Rad::Router.new :class
|
|
19
18
|
|
|
20
|
-
@params = Rad::Params.new
|
|
19
|
+
@params = Rad::Conveyors::Params.new
|
|
21
20
|
@router.stub(:safe_workspace).and_return({params: @params}.to_openobject)
|
|
22
21
|
end
|
|
23
22
|
|
|
24
23
|
it "encode" do
|
|
25
24
|
@router.encode(BlogsController, :show, format: 'json').should == ["/blogs_controller/show.json", {}]
|
|
26
25
|
end
|
|
27
|
-
|
|
26
|
+
|
|
28
27
|
it "encode_method" do
|
|
29
|
-
lambda{@router.encode_method :class_method}.should raise_error(/route method/)
|
|
30
|
-
@router.
|
|
31
|
-
@router.encode_method(:class_method).should == [BlogsController, :show]
|
|
28
|
+
lambda{@router.encode_method :class_method, false}.should raise_error(/route method/)
|
|
29
|
+
@router.routers.first.should_receive(:encode_method).and_return([BlogsController, :show])
|
|
30
|
+
@router.encode_method(:class_method, false).should == [BlogsController, :show]
|
|
32
31
|
end
|
|
33
32
|
|
|
34
33
|
it "decode" do
|
|
35
34
|
@router.decode("/blogs_controller/show", {}).should == [BlogsController, :show, {}]
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
it "skip" do
|
|
39
|
-
@router.skip(/\/fs/)
|
|
40
|
-
|
|
41
|
-
skip = catch :skip do
|
|
42
|
-
@router.decode("/fs/user/avatar", {})
|
|
43
|
-
nil
|
|
44
|
-
end
|
|
45
|
-
skip.should_not be_nil
|
|
46
|
-
end
|
|
35
|
+
end
|
|
47
36
|
|
|
48
37
|
describe "url_for" do
|
|
49
38
|
it "should convert complex params to json" do
|
|
50
39
|
@router.url_for(BlogsController, :show, a: :b, as_json: true).should == %(/blogs_controller/show?json=%7B%22a%22%3A%22b%22%7D)
|
|
51
40
|
end
|
|
52
41
|
|
|
42
|
+
it "should works with full url" do
|
|
43
|
+
@router.url_for('http://google.com').should == "http://google.com"
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "should not allow to use url_root/params/format with full url (http://)" do
|
|
47
|
+
lambda{@router.url_for('http://google.com', {a: 'b'})}.should raise_error(/can't use option/)
|
|
48
|
+
end
|
|
49
|
+
|
|
53
50
|
it "should escape params" do
|
|
54
51
|
@router.url_for(BlogsController, :show, a: 'b/c').should == "/blogs_controller/show?a=b%2Fc"
|
|
55
52
|
end
|
|
@@ -83,10 +80,16 @@ describe "Router Basic" do
|
|
|
83
80
|
@router.url_for(BlogsController, :show, options).should == "/blogs_controller/show.js"
|
|
84
81
|
options.should == {format: :js}
|
|
85
82
|
end
|
|
83
|
+
|
|
84
|
+
# it "should check for false :url_root (from error)" do
|
|
85
|
+
# config.set! :url_root, '/bag'
|
|
86
|
+
#
|
|
87
|
+
# @router.url_for("/some_url", url_root: false).should == "/some_url"
|
|
88
|
+
# end
|
|
86
89
|
end
|
|
87
90
|
|
|
88
91
|
describe "persistent params" do
|
|
89
|
-
before
|
|
92
|
+
before do
|
|
90
93
|
@router.persistent_params << :l
|
|
91
94
|
end
|
|
92
95
|
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
require '
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe "Routing Helper" do
|
|
4
|
-
|
|
3
|
+
describe "Routing Helper" do
|
|
5
4
|
before :all do
|
|
6
5
|
class ::BlogsController
|
|
7
|
-
include Rad::CoreRoutingHelper
|
|
6
|
+
include Rad::Router::CoreRoutingHelper
|
|
8
7
|
|
|
9
8
|
def show; end
|
|
10
9
|
end
|
|
@@ -14,10 +13,10 @@ describe "Routing Helper" do
|
|
|
14
13
|
remove_constants %w(BlogsController)
|
|
15
14
|
end
|
|
16
15
|
|
|
17
|
-
before
|
|
16
|
+
before do
|
|
18
17
|
@router = Rad::Router.new :class
|
|
19
18
|
|
|
20
|
-
@params = Rad::Params.new
|
|
19
|
+
@params = Rad::Conveyors::Params.new
|
|
21
20
|
@router.stub(:safe_workspace).and_return({params: @params}.to_openobject)
|
|
22
21
|
|
|
23
22
|
@controller = BlogsController.new
|
data/spec/spec_helper.rb
ADDED
data/spec/support/spec_helper.rb
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
rad.dialog().show("<%= render 'form' %>")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<%=
|
|
1
|
+
<%= render 'b' %>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
b.js
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
rad.dialog().show("<%= render 'edit', format: 'html' %>")
|
|
@@ -1,47 +1,51 @@
|
|
|
1
|
-
require '
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe "Template" do
|
|
4
|
-
Template = Rad::Template
|
|
5
|
-
|
|
6
|
-
delegate :render, to: Template
|
|
7
|
-
|
|
8
|
-
with_environment environment: :development
|
|
9
4
|
with_view_path "#{spec_dir}/views"
|
|
10
5
|
|
|
11
|
-
before :all do
|
|
12
|
-
::RenderResult = OpenObject.new
|
|
13
|
-
|
|
6
|
+
before :all do
|
|
14
7
|
class ::SomeObject
|
|
15
8
|
attr_accessor :ivariable
|
|
16
9
|
end
|
|
10
|
+
end
|
|
11
|
+
after :all do
|
|
12
|
+
remove_constants %w(SomeObject)
|
|
17
13
|
end
|
|
18
14
|
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
before do
|
|
16
|
+
rad.mode = :development, true
|
|
17
|
+
$render_result = OpenObject.new
|
|
18
|
+
end
|
|
19
|
+
after{rad.mode = :test, true}
|
|
20
|
+
|
|
21
|
+
inject template: :template
|
|
22
|
+
|
|
23
|
+
def render *a, &b
|
|
24
|
+
template.render *a, &b
|
|
21
25
|
end
|
|
22
26
|
|
|
23
27
|
describe 'special' do
|
|
24
28
|
it "read" do
|
|
25
|
-
|
|
29
|
+
template.read('/other/template').should == %{<% "ruby code" %> content}
|
|
26
30
|
end
|
|
27
31
|
|
|
28
32
|
it "exist?" do
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
template.should exist('/other/template')
|
|
34
|
+
template.should_not exist('/other/non-existing-template')
|
|
31
35
|
end
|
|
32
36
|
|
|
33
37
|
it "template prefixes" do
|
|
34
|
-
|
|
38
|
+
template.exist?('/prefixes/underscored', prefixes: ['']).should be_false
|
|
35
39
|
render('/prefixes/underscored', prefixes: ['_', '']).should == "underscored"
|
|
36
40
|
render('/prefixes/underscored.erb', prefixes: ['_', '']).should == "underscored"
|
|
37
41
|
|
|
38
|
-
|
|
42
|
+
template.exist?('/prefixes/without_prefix', prefixes: ['_']).should be_false
|
|
39
43
|
render('/prefixes/without_prefix', prefixes: ['']).should == "whthout prefix"
|
|
40
44
|
end
|
|
41
45
|
|
|
42
46
|
it "should not use prefixes for :action" do
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
template.exist?('/prefixes/underscored').should be_true
|
|
48
|
+
template.exist?('/prefixes/underscored', prefixes: [''], exact_format: true).should be_false
|
|
45
49
|
end
|
|
46
50
|
end
|
|
47
51
|
|
|
@@ -69,11 +73,11 @@ Yield: content for :content}
|
|
|
69
73
|
end
|
|
70
74
|
|
|
71
75
|
it "should not render wrong format if :action specified" do
|
|
72
|
-
|
|
73
|
-
|
|
76
|
+
template.exist?('/basic/non_existing_format', format: 'html', prefixes: [''], exact_format: true).should be_true
|
|
77
|
+
template.exist?('/basic/non_existing_format', format: :invalid, prefixes: [''], exact_format: true).should be_false
|
|
74
78
|
|
|
75
79
|
# from error
|
|
76
|
-
|
|
80
|
+
template.exist?('non_existing_format', format: :invalid, prefixes: [''], exact_format: true, current_dir: "#{spec_dir}/views/basic").should be_false
|
|
77
81
|
end
|
|
78
82
|
|
|
79
83
|
it "extension" do
|
|
@@ -82,31 +86,31 @@ Yield: content for :content}
|
|
|
82
86
|
end
|
|
83
87
|
|
|
84
88
|
it "must support custom context_class" do
|
|
85
|
-
class CustomTemplateContext < Rad::
|
|
89
|
+
class CustomTemplateContext < Rad::Template::Context
|
|
86
90
|
def custom_helper
|
|
87
91
|
'custom helper'
|
|
88
92
|
end
|
|
89
93
|
end
|
|
90
94
|
|
|
91
|
-
render('/basic/custom_context',
|
|
95
|
+
render('/basic/custom_context', context: CustomTemplateContext.new).should == "content from custom helper"
|
|
92
96
|
end
|
|
93
97
|
|
|
94
|
-
it "must support explicit context, and it should overtake context_class" do
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
end
|
|
98
|
+
# it "must support explicit context, and it should overtake context_class" do
|
|
99
|
+
# class CustomTemplateContext < Rad::Template::Context
|
|
100
|
+
# def custom_helper
|
|
101
|
+
# 'custom helper'
|
|
102
|
+
# end
|
|
103
|
+
# end
|
|
104
|
+
#
|
|
105
|
+
# render(
|
|
106
|
+
# '/basic/custom_context',
|
|
107
|
+
# context: CustomTemplateContext.new,
|
|
108
|
+
# context_class: Object
|
|
109
|
+
# ).should == "content from custom helper"
|
|
110
|
+
# end
|
|
107
111
|
|
|
108
112
|
it "no template" do
|
|
109
|
-
lambda{render('/non-existing-template')}.should raise_error(/
|
|
113
|
+
lambda{render('/non-existing-template')}.should raise_error(/no template/)
|
|
110
114
|
end
|
|
111
115
|
|
|
112
116
|
it "should render arbitrary file" do
|
|
@@ -116,19 +120,19 @@ Yield: content for :content}
|
|
|
116
120
|
|
|
117
121
|
describe 'format' do
|
|
118
122
|
it "basic" do
|
|
119
|
-
render('/format/format', format: 'html',
|
|
120
|
-
render('/format/format', format: 'js',
|
|
121
|
-
render('/format/format', format: :non_existing,
|
|
122
|
-
render('/format/format.html', format: 'js',
|
|
123
|
-
render('/format/format.html.erb', format: 'js',
|
|
123
|
+
render('/format/format', format: 'html', prefixes: [''], exact_format: true).should == "html format"
|
|
124
|
+
render('/format/format', format: 'js', prefixes: [''], exact_format: true).should == "js format"
|
|
125
|
+
render('/format/format', format: :non_existing, prefixes: [''], exact_format: true).should == "universal format"
|
|
126
|
+
render('/format/format.html', format: 'js', prefixes: [''], exact_format: true).should == "html format"
|
|
127
|
+
render('/format/format.html.erb', format: 'js', prefixes: [''], exact_format: true).should == "html format"
|
|
124
128
|
end
|
|
125
129
|
|
|
126
130
|
it "nesting different formats" do
|
|
127
|
-
render('/nesting_format/dialog', format: 'js',
|
|
131
|
+
render('/nesting_format/dialog', format: 'js', prefixes: [''], exact_format: true).should == %(rad.dialog().show("dialog, dialog form"))
|
|
128
132
|
end
|
|
129
133
|
|
|
130
134
|
it "should not force format for partials (if :action not specified)" do
|
|
131
|
-
render('/format_for_partials/dialog', format: 'js',
|
|
135
|
+
render('/format_for_partials/dialog', format: 'js', prefixes: [''], exact_format: true).should == %(rad.dialog().show("dialog form"))
|
|
132
136
|
end
|
|
133
137
|
end
|
|
134
138
|
|
|
@@ -145,14 +149,24 @@ Yield: content for :content}
|
|
|
145
149
|
end
|
|
146
150
|
|
|
147
151
|
it "nested templates should use the same format" do
|
|
148
|
-
render('/nested/format/a', format: 'js').should == "js
|
|
152
|
+
render('/nested/format/a', format: 'js').should == "b.js"
|
|
153
|
+
# render('/nested/format/a', format: 'html')
|
|
149
154
|
end
|
|
150
155
|
end
|
|
151
156
|
|
|
152
157
|
describe "layout" do
|
|
153
|
-
def render_with_layout
|
|
154
|
-
content, context =
|
|
155
|
-
|
|
158
|
+
def render_with_layout path, options, layout
|
|
159
|
+
content, context = template.basic_render(template.parse_arguments(path, options))
|
|
160
|
+
|
|
161
|
+
render layout, context: context do |*args|
|
|
162
|
+
if args.empty?
|
|
163
|
+
content
|
|
164
|
+
else
|
|
165
|
+
args.size.must_be == 1
|
|
166
|
+
variable_name = args.first.to_s
|
|
167
|
+
context.content_variables[variable_name]
|
|
168
|
+
end
|
|
169
|
+
end
|
|
156
170
|
end
|
|
157
171
|
|
|
158
172
|
it "templates and layout must share the same context" do
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<% concat "text for concatenation" %><%
|
|
1
|
+
<% concat "text for concatenation" %><% $render_result.erb_capture = capture do %>text for capturing<% end %>
|
data/spec/template/tilt_spec.rb
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
require '
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe "Tilt" do
|
|
4
|
-
with_environment environment: :development
|
|
5
4
|
with_view_path "#{spec_dir}/views"
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
inject template: :template
|
|
7
|
+
|
|
8
|
+
def render *a, &b
|
|
9
|
+
template.render *a, &b
|
|
10
|
+
end
|
|
8
11
|
|
|
9
12
|
before :all do
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class TemplateContextStub < Rad::TemplateContext
|
|
13
|
+
class TemplateContextStub < Rad::Template::Context
|
|
13
14
|
def tag name, content = nil, &block
|
|
14
15
|
if block_given?
|
|
15
16
|
content = capture(&block)
|
|
@@ -22,15 +23,12 @@ describe "Tilt" do
|
|
|
22
23
|
end
|
|
23
24
|
end
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
before do
|
|
27
|
+
$render_result = OpenObject.new
|
|
28
|
+
rad.mode = :development, true
|
|
27
29
|
end
|
|
30
|
+
after{rad.mode = :test, true}
|
|
28
31
|
|
|
29
|
-
# def render template_name, options = {}
|
|
30
|
-
# options[:context_class] ||= TemplateContextStub
|
|
31
|
-
# Rad::Template.render template_name, options
|
|
32
|
-
# end
|
|
33
|
-
#
|
|
34
32
|
it "haml should be ugly" do
|
|
35
33
|
render('/ugly.haml').should_not =~ /^\s/
|
|
36
34
|
end
|
|
@@ -42,10 +40,10 @@ describe "Tilt" do
|
|
|
42
40
|
|
|
43
41
|
it "concat & capture" do
|
|
44
42
|
render('/concat_and_capture.erb').should =~ /^text for concatenation.?$/
|
|
45
|
-
|
|
43
|
+
$render_result.erb_capture.should =~ /^text for capturing.?$/
|
|
46
44
|
|
|
47
45
|
render('/concat_and_capture.haml').should =~ /^text for concatenation.?$/
|
|
48
|
-
|
|
46
|
+
$render_result.haml_capture.should =~ /^text for capturing.?$/
|
|
49
47
|
end
|
|
50
48
|
|
|
51
49
|
it "yield" do
|
|
@@ -61,19 +59,19 @@ describe "Tilt" do
|
|
|
61
59
|
it "broken haml concat (from error)" do
|
|
62
60
|
render(
|
|
63
61
|
'/mixed_templates/broken_haml_concat_haml',
|
|
64
|
-
|
|
62
|
+
context: TemplateContextStub.new
|
|
65
63
|
).gsub("\n", "").should == "<div>some content</div>"
|
|
66
64
|
|
|
67
65
|
render(
|
|
68
66
|
'/mixed_templates/broken_haml_concat_erb',
|
|
69
|
-
|
|
67
|
+
context: TemplateContextStub.new
|
|
70
68
|
).gsub("\n", "").should == "<div>some content</div>"
|
|
71
69
|
end
|
|
72
70
|
|
|
73
71
|
it "broken erb concat (from error)" do
|
|
74
72
|
render(
|
|
75
73
|
'/mixed_templates/broken_erb_concat_erb',
|
|
76
|
-
|
|
74
|
+
context: TemplateContextStub.new
|
|
77
75
|
).gsub("\n", "").should == "haml content<div>\tsome content</div>"
|
|
78
76
|
end
|
|
79
77
|
end
|
|
@@ -92,7 +90,7 @@ describe "Tilt" do
|
|
|
92
90
|
end
|
|
93
91
|
end
|
|
94
92
|
|
|
95
|
-
render('/nested_capture_and_concat',
|
|
93
|
+
render('/nested_capture_and_concat', context: TestTC.new).gsub("\n", '').should ==
|
|
96
94
|
"<form_tag><form_field>some field</form_field></form_tag>"
|
|
97
95
|
end
|
|
98
96
|
end
|
|
File without changes
|
|
@@ -1,27 +1,25 @@
|
|
|
1
|
-
require '
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe "
|
|
4
|
-
with_environment
|
|
5
|
-
with_http
|
|
3
|
+
describe "Core" do
|
|
6
4
|
with_load_path spec_dir
|
|
5
|
+
isolate :conveyors, before: :all
|
|
7
6
|
|
|
8
7
|
before :all do
|
|
9
|
-
HttpController = Rad::HttpController
|
|
10
8
|
load 'rad/profiles/web.rb'
|
|
11
9
|
end
|
|
12
10
|
|
|
13
11
|
after :all do
|
|
14
|
-
remove_constants %w(
|
|
15
|
-
HttpController
|
|
12
|
+
remove_constants %w(
|
|
16
13
|
SmokeTestSpec
|
|
17
14
|
JsonFormatSpec
|
|
18
15
|
RequestAndSessionSpec
|
|
16
|
+
FullUrl
|
|
19
17
|
)
|
|
20
18
|
end
|
|
21
19
|
|
|
22
|
-
it "smoke test" do
|
|
20
|
+
it "smoke test" do
|
|
23
21
|
class ::SmokeTestSpec
|
|
24
|
-
inherit
|
|
22
|
+
inherit Rad::Controller::Http
|
|
25
23
|
|
|
26
24
|
def action
|
|
27
25
|
respond_to do |format|
|
|
@@ -35,12 +33,33 @@ describe "Integration" do
|
|
|
35
33
|
response.body.should == %(some content)
|
|
36
34
|
|
|
37
35
|
wcall("/smoke_test_spec/action", format: 'json')
|
|
38
|
-
response.body.should == %({"a":"b"})
|
|
36
|
+
response.body.should == %({"a":"b"})
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "full url (from error)" do
|
|
40
|
+
class ::FullUrl
|
|
41
|
+
inherit Rad::Controller::Http
|
|
42
|
+
|
|
43
|
+
def action
|
|
44
|
+
params.a.should == 'b'
|
|
45
|
+
render inline: 'ok'
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
wcall "http://localhost/full_url/action?a=b" do |c|
|
|
50
|
+
check = {
|
|
51
|
+
'PATH_INFO' => '/full_url/action',
|
|
52
|
+
'QUERY_STRING' => 'a=b'
|
|
53
|
+
}
|
|
54
|
+
workspace.env.subset(check.keys).should == check
|
|
55
|
+
c.call
|
|
56
|
+
end
|
|
57
|
+
response.body.should == %(ok)
|
|
39
58
|
end
|
|
40
59
|
|
|
41
60
|
it "json" do
|
|
42
61
|
class ::JsonFormatSpec
|
|
43
|
-
inherit
|
|
62
|
+
inherit Rad::Controller::Http
|
|
44
63
|
|
|
45
64
|
def action
|
|
46
65
|
render json: {a: 'b'}
|
|
@@ -54,7 +73,7 @@ describe "Integration" do
|
|
|
54
73
|
|
|
55
74
|
it "should have workspace, request, env, and session" do
|
|
56
75
|
class ::RequestAndSessionSpec
|
|
57
|
-
inherit
|
|
76
|
+
inherit Rad::Controller::Http
|
|
58
77
|
|
|
59
78
|
inject workspace: :workspace
|
|
60
79
|
def action
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
require '
|
|
2
|
-
require 'integration/spec_helper'
|
|
1
|
+
require 'spec_helper'
|
|
3
2
|
|
|
4
|
-
describe "UrlHelper" do
|
|
3
|
+
describe "UrlHelper" do
|
|
5
4
|
before :all do
|
|
5
|
+
rad.web
|
|
6
|
+
rad.reset :conveyors
|
|
7
|
+
|
|
6
8
|
class ControllerStub
|
|
7
9
|
inherit Rad::ControllerRoutingHelper, Rad::ControllerMicelaneousHelper
|
|
8
10
|
|
|
@@ -16,13 +18,13 @@ describe "UrlHelper" do
|
|
|
16
18
|
remove_constants :ControllerStub
|
|
17
19
|
end
|
|
18
20
|
|
|
19
|
-
before
|
|
21
|
+
before do
|
|
20
22
|
@c = ControllerStub.new
|
|
21
23
|
end
|
|
22
24
|
|
|
23
25
|
def stub_workspace
|
|
24
|
-
@response = Rad::Response.new
|
|
25
|
-
@params = Rad::Params.new
|
|
26
|
+
@response = Rad::Http::Response.new
|
|
27
|
+
@params = Rad::Conveyors::Params.new
|
|
26
28
|
|
|
27
29
|
@workspace = Object.new
|
|
28
30
|
@workspace.stub(:params).and_return(@params)
|
|
@@ -32,11 +34,11 @@ describe "UrlHelper" do
|
|
|
32
34
|
end
|
|
33
35
|
|
|
34
36
|
def within_request &block
|
|
35
|
-
@response.body = catch(:
|
|
37
|
+
@response.body = catch(:halt){block.call}
|
|
36
38
|
end
|
|
37
39
|
|
|
38
40
|
describe "redirect_to" do
|
|
39
|
-
before
|
|
41
|
+
before do
|
|
40
42
|
stub_workspace
|
|
41
43
|
end
|
|
42
44
|
|
|
@@ -44,7 +46,7 @@ describe "UrlHelper" do
|
|
|
44
46
|
@params.format = 'html'
|
|
45
47
|
|
|
46
48
|
within_request{@c.redirect_to('/some_book')}
|
|
47
|
-
@response.status.should ==
|
|
49
|
+
@response.status.should == 302
|
|
48
50
|
@response.headers['Location'].should == "/some_book"
|
|
49
51
|
@response.body.should =~ /You are being/
|
|
50
52
|
end
|
|
@@ -53,7 +55,7 @@ describe "UrlHelper" do
|
|
|
53
55
|
@params.format = 'html'
|
|
54
56
|
|
|
55
57
|
within_request{@c.redirect_to('http://localhost/some_book')}
|
|
56
|
-
@response.status.should ==
|
|
58
|
+
@response.status.should == 302
|
|
57
59
|
@response.headers['Location'].should == "http://localhost/some_book"
|
|
58
60
|
@response.body.should =~ /You are being/
|
|
59
61
|
end
|
|
@@ -69,7 +71,7 @@ describe "UrlHelper" do
|
|
|
69
71
|
end
|
|
70
72
|
|
|
71
73
|
describe "reload_page" do
|
|
72
|
-
before
|
|
74
|
+
before do
|
|
73
75
|
stub_workspace
|
|
74
76
|
end
|
|
75
77
|
|