hanami 2.2.1 → 2.3.0.beta2
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 +49 -1
- data/README.md +20 -35
- data/hanami.gemspec +9 -8
- data/lib/hanami/app.rb +2 -0
- data/lib/hanami/config/actions/content_security_policy.rb +23 -0
- data/lib/hanami/config/actions.rb +21 -0
- data/lib/hanami/config/console.rb +79 -0
- data/lib/hanami/config/logger.rb +1 -1
- data/lib/hanami/config.rb +14 -1
- data/lib/hanami/constants.rb +3 -0
- data/lib/hanami/extensions/db/repo.rb +11 -6
- data/lib/hanami/extensions/view/context.rb +10 -10
- data/lib/hanami/extensions/view/slice_configured_context.rb +0 -7
- data/lib/hanami/helpers/assets_helper.rb +92 -25
- data/lib/hanami/middleware/content_security_policy_nonce.rb +53 -0
- data/lib/hanami/routes.rb +3 -3
- data/lib/hanami/slice.rb +34 -6
- data/lib/hanami/slice_registrar.rb +1 -1
- data/lib/hanami/version.rb +1 -1
- data/lib/hanami.rb +10 -2
- data/spec/integration/action/format_config_spec.rb +6 -3
- data/spec/integration/action/slice_configuration_spec.rb +36 -36
- data/spec/integration/assets/cross_slice_assets_helpers_spec.rb +0 -1
- data/spec/integration/assets/serve_static_assets_spec.rb +1 -1
- data/spec/integration/container/autoloader_spec.rb +2 -0
- data/spec/integration/db/db_spec.rb +1 -1
- data/spec/integration/db/logging_spec.rb +63 -0
- data/spec/integration/db/repo_spec.rb +87 -2
- data/spec/integration/logging/exception_logging_spec.rb +6 -1
- data/spec/integration/rack_app/body_parser_spec.rb +2 -1
- data/spec/integration/rack_app/middleware_spec.rb +4 -11
- data/spec/integration/rack_app/rack_app_spec.rb +2 -2
- data/spec/integration/view/helpers/form_helper_spec.rb +1 -1
- data/spec/integration/web/content_security_policy_nonce_spec.rb +251 -0
- data/spec/support/app_integration.rb +2 -1
- data/spec/unit/hanami/config/actions/content_security_policy_spec.rb +7 -0
- data/spec/unit/hanami/config/actions_spec.rb +2 -2
- data/spec/unit/hanami/config/console_spec.rb +22 -0
- data/spec/unit/hanami/env_spec.rb +10 -13
- data/spec/unit/hanami/slice_spec.rb +18 -0
- data/spec/unit/hanami/web/rack_logger_spec.rb +11 -4
- metadata +34 -29
- data/spec/integration/view/context/settings_spec.rb +0 -46
- data/spec/support/shared_examples/cli/generate/app.rb +0 -494
- data/spec/support/shared_examples/cli/generate/migration.rb +0 -32
- data/spec/support/shared_examples/cli/generate/model.rb +0 -81
- data/spec/support/shared_examples/cli/new.rb +0 -97
- data/spec/unit/hanami/version_spec.rb +0 -7
|
@@ -3,30 +3,27 @@
|
|
|
3
3
|
RSpec.describe Hanami, ".env" do
|
|
4
4
|
subject { described_class.env(e: env) }
|
|
5
5
|
|
|
6
|
-
context "HANAMI_ENV in ENV" do
|
|
7
|
-
let(:env) { {"HANAMI_ENV" => "test"} }
|
|
6
|
+
context "HANAMI_ENV, APP_ENV and RACK_ENV in ENV" do
|
|
7
|
+
let(:env) { { "HANAMI_ENV" => "test", "APP_ENV" => "development", "RACK_ENV" => "production" } }
|
|
8
8
|
|
|
9
9
|
it "is the value of HANAMI_ENV" do
|
|
10
10
|
is_expected.to eq(:test)
|
|
11
11
|
end
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
context "RACK_ENV in ENV" do
|
|
15
|
-
let(:env) { {"
|
|
14
|
+
context "APP_ENV and RACK_ENV in ENV" do
|
|
15
|
+
let(:env) { {"APP_ENV" => "development", "RACK_ENV" => "production" } }
|
|
16
16
|
|
|
17
|
-
it "is the value of
|
|
18
|
-
is_expected.to eq(:
|
|
17
|
+
it "is the value of APP_ENV" do
|
|
18
|
+
is_expected.to eq(:development)
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
context "
|
|
23
|
-
let(:env)
|
|
24
|
-
{"HANAMI_ENV" => "test",
|
|
25
|
-
"RACK_ENV" => "production"}
|
|
26
|
-
end
|
|
22
|
+
context "RACK_ENV in ENV" do
|
|
23
|
+
let(:env) { { "RACK_ENV" => "production" } }
|
|
27
24
|
|
|
28
|
-
it "is the value of
|
|
29
|
-
is_expected.to eq(:
|
|
25
|
+
it "is the value of RACK_ENV" do
|
|
26
|
+
is_expected.to eq(:production)
|
|
30
27
|
end
|
|
31
28
|
end
|
|
32
29
|
|
|
@@ -65,6 +65,24 @@ RSpec.describe Hanami::Slice, :app_integration do
|
|
|
65
65
|
expect { Class.new(described_class).prepare }
|
|
66
66
|
.to raise_error Hanami::SliceLoadError, /Slice must have a class name/
|
|
67
67
|
end
|
|
68
|
+
|
|
69
|
+
it "does not allow special characters in slice names" do
|
|
70
|
+
expect { Hanami.app.register_slice(:'test_$lice') }
|
|
71
|
+
.to raise_error(ArgumentError, /must be lowercase alphanumeric text and underscores only/)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it "does not allow uppercase characters in slice names" do
|
|
75
|
+
expect { Hanami.app.register_slice(:TEST_slice) }
|
|
76
|
+
.to raise_error(ArgumentError, /must be lowercase alphanumeric text and underscores only/)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it "allows lowercase alphanumeric text and underscores only" do
|
|
80
|
+
expect { Hanami.app.register_slice(:test_slice) }.not_to raise_error
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it "allows single character slice names" do
|
|
84
|
+
expect { Hanami.app.register_slice(:t) }.not_to raise_error
|
|
85
|
+
end
|
|
68
86
|
end
|
|
69
87
|
|
|
70
88
|
describe ".source_path" do
|
|
@@ -53,10 +53,17 @@ RSpec.describe Hanami::Web::RackLogger do
|
|
|
53
53
|
stream.rewind
|
|
54
54
|
actual = stream.read
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
{
|
|
59
|
-
|
|
56
|
+
if RUBY_VERSION < "3.4"
|
|
57
|
+
expect(actual).to eql(<<~LOG)
|
|
58
|
+
[#{app_name}] [INFO] [#{time}] #{verb} #{status} #{elapsed}µs #{ip} #{path} #{content_length}
|
|
59
|
+
{"user"=>{"password"=>"[FILTERED]"}}
|
|
60
|
+
LOG
|
|
61
|
+
else
|
|
62
|
+
expect(actual).to eql(<<~LOG)
|
|
63
|
+
[#{app_name}] [INFO] [#{time}] #{verb} #{status} #{elapsed}µs #{ip} #{path} #{content_length}
|
|
64
|
+
{"user" => {"password" => "[FILTERED]"}}
|
|
65
|
+
LOG
|
|
66
|
+
end
|
|
60
67
|
end
|
|
61
68
|
|
|
62
69
|
context "ip" do
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hanami
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.3.0.beta2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
-
|
|
8
|
-
autorequire:
|
|
7
|
+
- Hanakai team
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: bundler
|
|
@@ -168,28 +167,28 @@ dependencies:
|
|
|
168
167
|
requirements:
|
|
169
168
|
- - "~>"
|
|
170
169
|
- !ruby/object:Gem::Version
|
|
171
|
-
version: 2.
|
|
170
|
+
version: 2.3.0.beta2
|
|
172
171
|
type: :runtime
|
|
173
172
|
prerelease: false
|
|
174
173
|
version_requirements: !ruby/object:Gem::Requirement
|
|
175
174
|
requirements:
|
|
176
175
|
- - "~>"
|
|
177
176
|
- !ruby/object:Gem::Version
|
|
178
|
-
version: 2.
|
|
177
|
+
version: 2.3.0.beta2
|
|
179
178
|
- !ruby/object:Gem::Dependency
|
|
180
179
|
name: hanami-utils
|
|
181
180
|
requirement: !ruby/object:Gem::Requirement
|
|
182
181
|
requirements:
|
|
183
182
|
- - "~>"
|
|
184
183
|
- !ruby/object:Gem::Version
|
|
185
|
-
version:
|
|
184
|
+
version: 2.3.0.beta2
|
|
186
185
|
type: :runtime
|
|
187
186
|
prerelease: false
|
|
188
187
|
version_requirements: !ruby/object:Gem::Requirement
|
|
189
188
|
requirements:
|
|
190
189
|
- - "~>"
|
|
191
190
|
- !ruby/object:Gem::Version
|
|
192
|
-
version:
|
|
191
|
+
version: 2.3.0.beta2
|
|
193
192
|
- !ruby/object:Gem::Dependency
|
|
194
193
|
name: json
|
|
195
194
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -218,6 +217,20 @@ dependencies:
|
|
|
218
217
|
- - "~>"
|
|
219
218
|
- !ruby/object:Gem::Version
|
|
220
219
|
version: '2.6'
|
|
220
|
+
- !ruby/object:Gem::Dependency
|
|
221
|
+
name: rack-session
|
|
222
|
+
requirement: !ruby/object:Gem::Requirement
|
|
223
|
+
requirements:
|
|
224
|
+
- - ">="
|
|
225
|
+
- !ruby/object:Gem::Version
|
|
226
|
+
version: '0'
|
|
227
|
+
type: :runtime
|
|
228
|
+
prerelease: false
|
|
229
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
230
|
+
requirements:
|
|
231
|
+
- - ">="
|
|
232
|
+
- !ruby/object:Gem::Version
|
|
233
|
+
version: '0'
|
|
221
234
|
- !ruby/object:Gem::Dependency
|
|
222
235
|
name: rspec
|
|
223
236
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -238,14 +251,14 @@ dependencies:
|
|
|
238
251
|
requirements:
|
|
239
252
|
- - "~>"
|
|
240
253
|
- !ruby/object:Gem::Version
|
|
241
|
-
version: '
|
|
254
|
+
version: '2.0'
|
|
242
255
|
type: :development
|
|
243
256
|
prerelease: false
|
|
244
257
|
version_requirements: !ruby/object:Gem::Requirement
|
|
245
258
|
requirements:
|
|
246
259
|
- - "~>"
|
|
247
260
|
- !ruby/object:Gem::Version
|
|
248
|
-
version: '
|
|
261
|
+
version: '2.0'
|
|
249
262
|
- !ruby/object:Gem::Dependency
|
|
250
263
|
name: rake
|
|
251
264
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -260,9 +273,9 @@ dependencies:
|
|
|
260
273
|
- - "~>"
|
|
261
274
|
- !ruby/object:Gem::Version
|
|
262
275
|
version: '13.0'
|
|
263
|
-
description:
|
|
276
|
+
description: A flexible framework for maintainable Ruby apps
|
|
264
277
|
email:
|
|
265
|
-
-
|
|
278
|
+
- info@hanakai.org
|
|
266
279
|
executables: []
|
|
267
280
|
extensions: []
|
|
268
281
|
extra_rdoc_files: []
|
|
@@ -282,6 +295,7 @@ files:
|
|
|
282
295
|
- lib/hanami/config/actions/cookies.rb
|
|
283
296
|
- lib/hanami/config/actions/sessions.rb
|
|
284
297
|
- lib/hanami/config/assets.rb
|
|
298
|
+
- lib/hanami/config/console.rb
|
|
285
299
|
- lib/hanami/config/db.rb
|
|
286
300
|
- lib/hanami/config/logger.rb
|
|
287
301
|
- lib/hanami/config/null_config.rb
|
|
@@ -310,6 +324,7 @@ files:
|
|
|
310
324
|
- lib/hanami/helpers/form_helper/form_builder.rb
|
|
311
325
|
- lib/hanami/helpers/form_helper/values.rb
|
|
312
326
|
- lib/hanami/middleware/assets.rb
|
|
327
|
+
- lib/hanami/middleware/content_security_policy_nonce.rb
|
|
313
328
|
- lib/hanami/middleware/public_errors_app.rb
|
|
314
329
|
- lib/hanami/middleware/render_errors.rb
|
|
315
330
|
- lib/hanami/port.rb
|
|
@@ -423,7 +438,6 @@ files:
|
|
|
423
438
|
- spec/integration/view/context/inflector_spec.rb
|
|
424
439
|
- spec/integration/view/context/request_spec.rb
|
|
425
440
|
- spec/integration/view/context/routes_spec.rb
|
|
426
|
-
- spec/integration/view/context/settings_spec.rb
|
|
427
441
|
- spec/integration/view/helpers/form_helper_spec.rb
|
|
428
442
|
- spec/integration/view/helpers/part_helpers_spec.rb
|
|
429
443
|
- spec/integration/view/helpers/scope_helpers_spec.rb
|
|
@@ -432,6 +446,7 @@ files:
|
|
|
432
446
|
- spec/integration/view/parts/default_rendering_spec.rb
|
|
433
447
|
- spec/integration/view/slice_configuration_spec.rb
|
|
434
448
|
- spec/integration/view/views_spec.rb
|
|
449
|
+
- spec/integration/web/content_security_policy_nonce_spec.rb
|
|
435
450
|
- spec/integration/web/render_detailed_errors_spec.rb
|
|
436
451
|
- spec/integration/web/render_errors_spec.rb
|
|
437
452
|
- spec/integration/web/welcome_view_spec.rb
|
|
@@ -440,10 +455,6 @@ files:
|
|
|
440
455
|
- spec/support/coverage.rb
|
|
441
456
|
- spec/support/matchers.rb
|
|
442
457
|
- spec/support/rspec.rb
|
|
443
|
-
- spec/support/shared_examples/cli/generate/app.rb
|
|
444
|
-
- spec/support/shared_examples/cli/generate/migration.rb
|
|
445
|
-
- spec/support/shared_examples/cli/generate/model.rb
|
|
446
|
-
- spec/support/shared_examples/cli/new.rb
|
|
447
458
|
- spec/unit/hanami/config/actions/content_security_policy_spec.rb
|
|
448
459
|
- spec/unit/hanami/config/actions/cookies_spec.rb
|
|
449
460
|
- spec/unit/hanami/config/actions/csrf_protection_spec.rb
|
|
@@ -451,6 +462,7 @@ files:
|
|
|
451
462
|
- spec/unit/hanami/config/actions/sessions_spec.rb
|
|
452
463
|
- spec/unit/hanami/config/actions_spec.rb
|
|
453
464
|
- spec/unit/hanami/config/base_url_spec.rb
|
|
465
|
+
- spec/unit/hanami/config/console_spec.rb
|
|
454
466
|
- spec/unit/hanami/config/db_spec.rb
|
|
455
467
|
- spec/unit/hanami/config/inflector_spec.rb
|
|
456
468
|
- spec/unit/hanami/config/logger_spec.rb
|
|
@@ -480,7 +492,6 @@ files:
|
|
|
480
492
|
- spec/unit/hanami/slice_configurable_spec.rb
|
|
481
493
|
- spec/unit/hanami/slice_name_spec.rb
|
|
482
494
|
- spec/unit/hanami/slice_spec.rb
|
|
483
|
-
- spec/unit/hanami/version_spec.rb
|
|
484
495
|
- spec/unit/hanami/web/rack_logger_spec.rb
|
|
485
496
|
homepage: http://hanamirb.org
|
|
486
497
|
licenses:
|
|
@@ -488,7 +499,6 @@ licenses:
|
|
|
488
499
|
metadata:
|
|
489
500
|
rubygems_mfa_required: 'true'
|
|
490
501
|
allowed_push_host: https://rubygems.org
|
|
491
|
-
post_install_message:
|
|
492
502
|
rdoc_options: []
|
|
493
503
|
require_paths:
|
|
494
504
|
- lib
|
|
@@ -496,17 +506,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
496
506
|
requirements:
|
|
497
507
|
- - ">="
|
|
498
508
|
- !ruby/object:Gem::Version
|
|
499
|
-
version: '3.
|
|
509
|
+
version: '3.2'
|
|
500
510
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
501
511
|
requirements:
|
|
502
512
|
- - ">="
|
|
503
513
|
- !ruby/object:Gem::Version
|
|
504
514
|
version: '0'
|
|
505
515
|
requirements: []
|
|
506
|
-
rubygems_version: 3.
|
|
507
|
-
signing_key:
|
|
516
|
+
rubygems_version: 3.6.9
|
|
508
517
|
specification_version: 4
|
|
509
|
-
summary:
|
|
518
|
+
summary: A flexible framework for maintainable Ruby apps
|
|
510
519
|
test_files:
|
|
511
520
|
- spec/integration/action/cookies_spec.rb
|
|
512
521
|
- spec/integration/action/csrf_protection_spec.rb
|
|
@@ -584,7 +593,6 @@ test_files:
|
|
|
584
593
|
- spec/integration/view/context/inflector_spec.rb
|
|
585
594
|
- spec/integration/view/context/request_spec.rb
|
|
586
595
|
- spec/integration/view/context/routes_spec.rb
|
|
587
|
-
- spec/integration/view/context/settings_spec.rb
|
|
588
596
|
- spec/integration/view/helpers/form_helper_spec.rb
|
|
589
597
|
- spec/integration/view/helpers/part_helpers_spec.rb
|
|
590
598
|
- spec/integration/view/helpers/scope_helpers_spec.rb
|
|
@@ -593,6 +601,7 @@ test_files:
|
|
|
593
601
|
- spec/integration/view/parts/default_rendering_spec.rb
|
|
594
602
|
- spec/integration/view/slice_configuration_spec.rb
|
|
595
603
|
- spec/integration/view/views_spec.rb
|
|
604
|
+
- spec/integration/web/content_security_policy_nonce_spec.rb
|
|
596
605
|
- spec/integration/web/render_detailed_errors_spec.rb
|
|
597
606
|
- spec/integration/web/render_errors_spec.rb
|
|
598
607
|
- spec/integration/web/welcome_view_spec.rb
|
|
@@ -601,10 +610,6 @@ test_files:
|
|
|
601
610
|
- spec/support/coverage.rb
|
|
602
611
|
- spec/support/matchers.rb
|
|
603
612
|
- spec/support/rspec.rb
|
|
604
|
-
- spec/support/shared_examples/cli/generate/app.rb
|
|
605
|
-
- spec/support/shared_examples/cli/generate/migration.rb
|
|
606
|
-
- spec/support/shared_examples/cli/generate/model.rb
|
|
607
|
-
- spec/support/shared_examples/cli/new.rb
|
|
608
613
|
- spec/unit/hanami/config/actions/content_security_policy_spec.rb
|
|
609
614
|
- spec/unit/hanami/config/actions/cookies_spec.rb
|
|
610
615
|
- spec/unit/hanami/config/actions/csrf_protection_spec.rb
|
|
@@ -612,6 +617,7 @@ test_files:
|
|
|
612
617
|
- spec/unit/hanami/config/actions/sessions_spec.rb
|
|
613
618
|
- spec/unit/hanami/config/actions_spec.rb
|
|
614
619
|
- spec/unit/hanami/config/base_url_spec.rb
|
|
620
|
+
- spec/unit/hanami/config/console_spec.rb
|
|
615
621
|
- spec/unit/hanami/config/db_spec.rb
|
|
616
622
|
- spec/unit/hanami/config/inflector_spec.rb
|
|
617
623
|
- spec/unit/hanami/config/logger_spec.rb
|
|
@@ -641,5 +647,4 @@ test_files:
|
|
|
641
647
|
- spec/unit/hanami/slice_configurable_spec.rb
|
|
642
648
|
- spec/unit/hanami/slice_name_spec.rb
|
|
643
649
|
- spec/unit/hanami/slice_spec.rb
|
|
644
|
-
- spec/unit/hanami/version_spec.rb
|
|
645
650
|
- spec/unit/hanami/web/rack_logger_spec.rb
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "hanami"
|
|
4
|
-
require "hanami/settings"
|
|
5
|
-
|
|
6
|
-
RSpec.describe "App view / Context / Settings", :app_integration do
|
|
7
|
-
before do
|
|
8
|
-
module TestApp
|
|
9
|
-
class App < Hanami::App
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
class Settings < Hanami::Settings
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
Hanami.prepare
|
|
17
|
-
|
|
18
|
-
module TestApp
|
|
19
|
-
module Views
|
|
20
|
-
class Context < Hanami::View::Context
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
let(:context_class) { TestApp::Views::Context }
|
|
27
|
-
subject(:context) { context_class.new }
|
|
28
|
-
|
|
29
|
-
describe "#settings" do
|
|
30
|
-
it "is the app settings by default" do
|
|
31
|
-
expect(context.settings).to be TestApp::App["settings"]
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
context "injected settings" do
|
|
35
|
-
subject(:context) {
|
|
36
|
-
context_class.new(settings: settings)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
let(:settings) { double(:settings) }
|
|
40
|
-
|
|
41
|
-
it "is the injected settings" do
|
|
42
|
-
expect(context.settings).to be settings
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|