hanami 2.3.2 → 3.0.0.rc1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +55 -19
- data/LICENSE +20 -0
- data/README.md +18 -35
- data/hanami.gemspec +36 -37
- data/lib/hanami/config/db.rb +2 -0
- data/lib/hanami/config/i18n.rb +138 -0
- data/lib/hanami/config/logger.rb +15 -7
- data/lib/hanami/config/null_config.rb +1 -1
- data/lib/hanami/config/views.rb +17 -0
- data/lib/hanami/config.rb +66 -22
- data/lib/hanami/errors.rb +6 -0
- data/lib/hanami/extensions/action/slice_configured_action.rb +1 -1
- data/lib/hanami/extensions/action.rb +2 -2
- data/lib/hanami/extensions/mailer/slice_configured_mailer.rb +120 -0
- data/lib/hanami/extensions/mailer.rb +28 -0
- data/lib/hanami/extensions/operation/slice_configured_db_operation.rb +2 -0
- data/lib/hanami/extensions/view/context.rb +26 -4
- data/lib/hanami/extensions/view/part.rb +2 -0
- data/lib/hanami/extensions/view/slice_configured_context.rb +7 -0
- data/lib/hanami/extensions/view/slice_configured_part.rb +2 -0
- data/lib/hanami/extensions/view/slice_configured_view.rb +8 -8
- data/lib/hanami/extensions/view/standard_helpers.rb +4 -0
- data/lib/hanami/extensions.rb +6 -1
- data/lib/hanami/helpers/assets_helper.rb +0 -4
- data/lib/hanami/helpers/form_helper.rb +1 -1
- data/lib/hanami/helpers/i18n_helper.rb +176 -0
- data/lib/hanami/logger/rack_formatter.rb +73 -0
- data/lib/hanami/logger/sql_formatter.rb +80 -0
- data/lib/hanami/logger/sql_logger.rb +48 -0
- data/lib/hanami/middleware/render_errors.rb +2 -2
- data/lib/hanami/providers/db.rb +7 -2
- data/lib/hanami/providers/db_logging.rb +4 -7
- data/lib/hanami/providers/i18n/backend.rb +369 -0
- data/lib/hanami/providers/i18n/locale/en.yml +57 -0
- data/lib/hanami/providers/i18n.rb +114 -0
- data/lib/hanami/providers/mailers.rb +101 -0
- data/lib/hanami/routes.rb +1 -0
- data/lib/hanami/settings/composite_store.rb +53 -0
- data/lib/hanami/settings.rb +4 -4
- data/lib/hanami/slice/router.rb +15 -10
- data/lib/hanami/slice.rb +71 -11
- data/lib/hanami/slice_registrar.rb +2 -2
- data/lib/hanami/universal_logger.rb +250 -0
- data/lib/hanami/version.rb +1 -1
- data/lib/hanami/web/rack_logger.rb +2 -80
- data/lib/hanami/web/welcome.html.erb +443 -58
- data/lib/hanami.rb +4 -2
- metadata +28 -276
- data/CODE_OF_CONDUCT.md +0 -74
- data/FEATURES.md +0 -269
- data/LICENSE.md +0 -22
- data/spec/integration/action/cookies_spec.rb +0 -58
- data/spec/integration/action/csrf_protection_spec.rb +0 -54
- data/spec/integration/action/format_config_spec.rb +0 -129
- data/spec/integration/action/routes_spec.rb +0 -71
- data/spec/integration/action/sessions_spec.rb +0 -50
- data/spec/integration/action/slice_configuration_spec.rb +0 -284
- data/spec/integration/action/view_rendering/automatic_rendering_spec.rb +0 -247
- data/spec/integration/action/view_rendering/paired_view_inference_spec.rb +0 -115
- data/spec/integration/action/view_rendering/view_context_spec.rb +0 -221
- data/spec/integration/action/view_rendering_spec.rb +0 -89
- data/spec/integration/assets/assets_spec.rb +0 -155
- data/spec/integration/assets/cross_slice_assets_helpers_spec.rb +0 -129
- data/spec/integration/assets/serve_static_assets_spec.rb +0 -152
- data/spec/integration/code_loading/loading_from_app_spec.rb +0 -152
- data/spec/integration/code_loading/loading_from_lib_spec.rb +0 -242
- data/spec/integration/code_loading/loading_from_slice_spec.rb +0 -165
- data/spec/integration/container/application_routes_helper_spec.rb +0 -48
- data/spec/integration/container/auto_injection_spec.rb +0 -53
- data/spec/integration/container/auto_registration_spec.rb +0 -86
- data/spec/integration/container/autoloader_spec.rb +0 -82
- data/spec/integration/container/imports_spec.rb +0 -253
- data/spec/integration/container/prepare_container_spec.rb +0 -125
- data/spec/integration/container/provider_environment_spec.rb +0 -52
- data/spec/integration/container/provider_lifecycle_spec.rb +0 -61
- data/spec/integration/container/shutdown_spec.rb +0 -91
- data/spec/integration/container/standard_providers/rack_provider_spec.rb +0 -44
- data/spec/integration/container/standard_providers_spec.rb +0 -124
- data/spec/integration/db/auto_registration_spec.rb +0 -39
- data/spec/integration/db/commands_spec.rb +0 -80
- data/spec/integration/db/db_inflector_spec.rb +0 -57
- data/spec/integration/db/db_slices_spec.rb +0 -398
- data/spec/integration/db/db_spec.rb +0 -245
- data/spec/integration/db/gateways_spec.rb +0 -361
- data/spec/integration/db/logging_spec.rb +0 -301
- data/spec/integration/db/mappers_spec.rb +0 -84
- data/spec/integration/db/provider_config_spec.rb +0 -88
- data/spec/integration/db/provider_spec.rb +0 -35
- data/spec/integration/db/relations_spec.rb +0 -60
- data/spec/integration/db/repo_spec.rb +0 -300
- data/spec/integration/db/slices_importing_from_parent.rb +0 -130
- data/spec/integration/dotenv_loading_spec.rb +0 -138
- data/spec/integration/logging/exception_logging_spec.rb +0 -120
- data/spec/integration/logging/notifications_spec.rb +0 -68
- data/spec/integration/logging/request_logging_spec.rb +0 -202
- data/spec/integration/operations/extension_spec.rb +0 -122
- data/spec/integration/rack_app/body_parser_spec.rb +0 -108
- data/spec/integration/rack_app/method_override_spec.rb +0 -97
- data/spec/integration/rack_app/middleware_spec.rb +0 -720
- data/spec/integration/rack_app/non_booted_rack_app_spec.rb +0 -104
- data/spec/integration/rack_app/rack_app_spec.rb +0 -442
- data/spec/integration/rake_tasks_spec.rb +0 -107
- data/spec/integration/router/resource_routes_spec.rb +0 -281
- data/spec/integration/settings/access_in_slice_class_body_spec.rb +0 -83
- data/spec/integration/settings/access_to_constants_spec.rb +0 -46
- data/spec/integration/settings/loading_from_env_spec.rb +0 -188
- data/spec/integration/settings/settings_component_loading_spec.rb +0 -113
- data/spec/integration/settings/slice_registration_spec.rb +0 -145
- data/spec/integration/settings/using_types_spec.rb +0 -80
- data/spec/integration/setup_spec.rb +0 -165
- data/spec/integration/slices/external_slice_spec.rb +0 -91
- data/spec/integration/slices/slice_configuration_spec.rb +0 -42
- data/spec/integration/slices/slice_loading_spec.rb +0 -171
- data/spec/integration/slices/slice_registrations_spec.rb +0 -80
- data/spec/integration/slices/slice_routing_spec.rb +0 -219
- data/spec/integration/slices_spec.rb +0 -471
- data/spec/integration/view/config/default_context_spec.rb +0 -149
- data/spec/integration/view/config/inflector_spec.rb +0 -57
- data/spec/integration/view/config/part_class_spec.rb +0 -147
- data/spec/integration/view/config/part_namespace_spec.rb +0 -103
- data/spec/integration/view/config/paths_spec.rb +0 -119
- data/spec/integration/view/config/scope_class_spec.rb +0 -147
- data/spec/integration/view/config/scope_namespace_spec.rb +0 -103
- data/spec/integration/view/config/template_spec.rb +0 -38
- data/spec/integration/view/context/assets_spec.rb +0 -79
- data/spec/integration/view/context/inflector_spec.rb +0 -40
- data/spec/integration/view/context/request_spec.rb +0 -57
- data/spec/integration/view/context/routes_spec.rb +0 -84
- data/spec/integration/view/helpers/form_helper_spec.rb +0 -174
- data/spec/integration/view/helpers/part_helpers_spec.rb +0 -124
- data/spec/integration/view/helpers/scope_helpers_spec.rb +0 -84
- data/spec/integration/view/helpers/user_defined_helpers/part_helpers_spec.rb +0 -162
- data/spec/integration/view/helpers/user_defined_helpers/scope_helpers_spec.rb +0 -119
- data/spec/integration/view/parts/default_rendering_spec.rb +0 -138
- data/spec/integration/view/slice_configuration_spec.rb +0 -289
- data/spec/integration/view/views_spec.rb +0 -103
- data/spec/integration/web/content_security_policy_nonce_spec.rb +0 -251
- data/spec/integration/web/render_detailed_errors_spec.rb +0 -107
- data/spec/integration/web/render_errors_spec.rb +0 -242
- data/spec/integration/web/welcome_view_spec.rb +0 -84
- data/spec/spec_helper.rb +0 -28
- data/spec/support/app_integration.rb +0 -157
- data/spec/support/coverage.rb +0 -1
- data/spec/support/matchers.rb +0 -32
- data/spec/support/rspec.rb +0 -27
- data/spec/unit/hanami/config/actions/content_security_policy_spec.rb +0 -96
- data/spec/unit/hanami/config/actions/cookies_spec.rb +0 -46
- data/spec/unit/hanami/config/actions/csrf_protection_spec.rb +0 -58
- data/spec/unit/hanami/config/actions/default_values_spec.rb +0 -43
- data/spec/unit/hanami/config/actions/sessions_spec.rb +0 -48
- data/spec/unit/hanami/config/actions_spec.rb +0 -52
- data/spec/unit/hanami/config/base_url_spec.rb +0 -25
- data/spec/unit/hanami/config/console_spec.rb +0 -22
- data/spec/unit/hanami/config/db_spec.rb +0 -38
- data/spec/unit/hanami/config/inflector_spec.rb +0 -35
- data/spec/unit/hanami/config/logger_spec.rb +0 -195
- data/spec/unit/hanami/config/render_detailed_errors_spec.rb +0 -25
- data/spec/unit/hanami/config/render_errors_spec.rb +0 -25
- data/spec/unit/hanami/config/router_spec.rb +0 -44
- data/spec/unit/hanami/config/slices_spec.rb +0 -34
- data/spec/unit/hanami/config/views_spec.rb +0 -80
- data/spec/unit/hanami/env_spec.rb +0 -37
- data/spec/unit/hanami/extensions/view/context_spec.rb +0 -59
- data/spec/unit/hanami/helpers/assets_helper/asset_url_spec.rb +0 -120
- data/spec/unit/hanami/helpers/assets_helper/audio_tag_spec.rb +0 -132
- data/spec/unit/hanami/helpers/assets_helper/favicon_tag_spec.rb +0 -87
- data/spec/unit/hanami/helpers/assets_helper/image_tag_spec.rb +0 -92
- data/spec/unit/hanami/helpers/assets_helper/javascript_tag_spec.rb +0 -143
- data/spec/unit/hanami/helpers/assets_helper/stylesheet_tag_spec.rb +0 -126
- data/spec/unit/hanami/helpers/assets_helper/video_tag_spec.rb +0 -136
- data/spec/unit/hanami/helpers/form_helper_spec.rb +0 -2857
- data/spec/unit/hanami/port_spec.rb +0 -117
- data/spec/unit/hanami/providers/db/config/default_config_spec.rb +0 -100
- data/spec/unit/hanami/providers/db/config/gateway_spec.rb +0 -73
- data/spec/unit/hanami/providers/db/config_spec.rb +0 -143
- data/spec/unit/hanami/router/errors/not_allowed_error_spec.rb +0 -27
- data/spec/unit/hanami/router/errors/not_found_error_spec.rb +0 -22
- data/spec/unit/hanami/settings/env_store_spec.rb +0 -52
- data/spec/unit/hanami/settings_spec.rb +0 -111
- data/spec/unit/hanami/slice_configurable_spec.rb +0 -141
- data/spec/unit/hanami/slice_name_spec.rb +0 -47
- data/spec/unit/hanami/slice_spec.rb +0 -99
- data/spec/unit/hanami/web/rack_logger_spec.rb +0 -99
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "rack/test"
|
|
4
|
-
require "stringio"
|
|
5
|
-
|
|
6
|
-
RSpec.describe "Hanami web app", :app_integration do
|
|
7
|
-
include Rack::Test::Methods
|
|
8
|
-
|
|
9
|
-
let(:app) { Hanami.app }
|
|
10
|
-
|
|
11
|
-
around do |example|
|
|
12
|
-
with_tmp_directory(Dir.mktmpdir, &example)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
specify "Default body parser" do
|
|
16
|
-
write "config/app.rb", <<~RUBY
|
|
17
|
-
require "hanami"
|
|
18
|
-
|
|
19
|
-
module TestApp
|
|
20
|
-
class App < Hanami::App
|
|
21
|
-
config.actions.format :json
|
|
22
|
-
config.logger.stream = StringIO.new
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
RUBY
|
|
26
|
-
|
|
27
|
-
write "config/routes.rb", <<~RUBY
|
|
28
|
-
module TestApp
|
|
29
|
-
class Routes < Hanami::Routes
|
|
30
|
-
post "/users", to: "users.create"
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
RUBY
|
|
34
|
-
|
|
35
|
-
write "app/actions/users/create.rb", <<~RUBY
|
|
36
|
-
module TestApp
|
|
37
|
-
module Actions
|
|
38
|
-
module Users
|
|
39
|
-
class Create < Hanami::Action
|
|
40
|
-
def handle(req, res)
|
|
41
|
-
res.body = req.params[:users].join("-")
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
RUBY
|
|
48
|
-
|
|
49
|
-
require "hanami/boot"
|
|
50
|
-
|
|
51
|
-
post(
|
|
52
|
-
"/users",
|
|
53
|
-
JSON.dump("users" => %w[jane john jade joe]),
|
|
54
|
-
"CONTENT_TYPE" => "application/json"
|
|
55
|
-
)
|
|
56
|
-
|
|
57
|
-
expect(last_response).to be_successful
|
|
58
|
-
expect(last_response.body).to eql("jane-john-jade-joe")
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
specify "Configuring custom mime-types and body parser" do
|
|
62
|
-
write "config/app.rb", <<~RUBY
|
|
63
|
-
require "hanami"
|
|
64
|
-
|
|
65
|
-
module TestApp
|
|
66
|
-
class App < Hanami::App
|
|
67
|
-
config.actions.formats.register :json, "application/json+scim"
|
|
68
|
-
config.actions.formats.accept :json
|
|
69
|
-
config.middleware.use :body_parser, [json: "application/json+scim"]
|
|
70
|
-
config.logger.stream = StringIO.new
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
RUBY
|
|
74
|
-
|
|
75
|
-
write "config/routes.rb", <<~RUBY
|
|
76
|
-
module TestApp
|
|
77
|
-
class Routes < Hanami::Routes
|
|
78
|
-
post "/users", to: "users.create"
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
RUBY
|
|
82
|
-
|
|
83
|
-
write "app/actions/users/create.rb", <<~RUBY
|
|
84
|
-
module TestApp
|
|
85
|
-
module Actions
|
|
86
|
-
module Users
|
|
87
|
-
class Create < Hanami::Action
|
|
88
|
-
def handle(req, res)
|
|
89
|
-
res.body = req.params[:users].join("-")
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
RUBY
|
|
96
|
-
|
|
97
|
-
require "hanami/boot"
|
|
98
|
-
|
|
99
|
-
post(
|
|
100
|
-
"/users",
|
|
101
|
-
JSON.dump("users" => %w[jane john jade joe]),
|
|
102
|
-
"CONTENT_TYPE" => "application/json+scim"
|
|
103
|
-
)
|
|
104
|
-
|
|
105
|
-
expect(last_response).to be_successful
|
|
106
|
-
expect(last_response.body).to eql("jane-john-jade-joe")
|
|
107
|
-
end
|
|
108
|
-
end
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "rack/test"
|
|
4
|
-
require "stringio"
|
|
5
|
-
|
|
6
|
-
RSpec.describe "Hanami web app: Method Override", :app_integration do
|
|
7
|
-
include Rack::Test::Methods
|
|
8
|
-
|
|
9
|
-
let(:app) { Hanami.app }
|
|
10
|
-
|
|
11
|
-
around do |example|
|
|
12
|
-
with_tmp_directory(Dir.mktmpdir, &example)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
context "enabled by default" do
|
|
16
|
-
before do
|
|
17
|
-
write "config/app.rb", <<~RUBY
|
|
18
|
-
require "hanami"
|
|
19
|
-
|
|
20
|
-
module TestApp
|
|
21
|
-
class App < Hanami::App
|
|
22
|
-
config.logger.stream = StringIO.new
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
RUBY
|
|
26
|
-
|
|
27
|
-
generate_app_code
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
it "overrides the original HTTP method" do
|
|
31
|
-
post(
|
|
32
|
-
"/users/:id",
|
|
33
|
-
{"_method" => "PUT"},
|
|
34
|
-
"CONTENT_TYPE" => "multipart/form-data"
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
expect(last_response).to be_successful
|
|
38
|
-
expect(last_response.body).to eq("PUT")
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
context "when disabled" do
|
|
43
|
-
before do
|
|
44
|
-
write "config/app.rb", <<~RUBY
|
|
45
|
-
require "hanami"
|
|
46
|
-
|
|
47
|
-
module TestApp
|
|
48
|
-
class App < Hanami::App
|
|
49
|
-
config.logger.stream = StringIO.new
|
|
50
|
-
config.actions.method_override = false
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
RUBY
|
|
54
|
-
|
|
55
|
-
generate_app_code
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
it "overrides the original HTTP method" do
|
|
59
|
-
post(
|
|
60
|
-
"/users/:id",
|
|
61
|
-
{"_method" => "PUT"},
|
|
62
|
-
"CONTENT_TYPE" => "multipart/form-data"
|
|
63
|
-
)
|
|
64
|
-
|
|
65
|
-
expect(last_response).to_not be_successful
|
|
66
|
-
expect(last_response.status).to be(404)
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
private
|
|
71
|
-
|
|
72
|
-
def generate_app_code
|
|
73
|
-
write "config/routes.rb", <<~RUBY
|
|
74
|
-
module TestApp
|
|
75
|
-
class Routes < Hanami::Routes
|
|
76
|
-
put "/users/:id", to: "users.update"
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
RUBY
|
|
80
|
-
|
|
81
|
-
write "app/actions/users/update.rb", <<~RUBY
|
|
82
|
-
module TestApp
|
|
83
|
-
module Actions
|
|
84
|
-
module Users
|
|
85
|
-
class Update < Hanami::Action
|
|
86
|
-
def handle(req, res)
|
|
87
|
-
res.body = req.env.fetch("REQUEST_METHOD")
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
RUBY
|
|
94
|
-
|
|
95
|
-
require "hanami/boot"
|
|
96
|
-
end
|
|
97
|
-
end
|