hanami 2.0.0.beta2 → 2.0.0.beta3
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 +10 -1
- data/lib/hanami/configuration/null_configuration.rb +2 -2
- data/lib/hanami/configuration.rb +17 -17
- data/lib/hanami/routes.rb +48 -21
- data/lib/hanami/version.rb +1 -1
- data/spec/{new_integration → integration}/action/cookies_spec.rb +0 -0
- data/spec/{new_integration → integration}/action/csrf_protection_spec.rb +0 -0
- data/spec/{new_integration → integration}/action/routes_spec.rb +3 -5
- data/spec/{new_integration → integration}/action/sessions_spec.rb +0 -0
- data/spec/{new_integration → integration}/action/slice_configuration_spec.rb +0 -0
- data/spec/{new_integration → integration}/action/view_integration_spec.rb +0 -0
- data/spec/{new_integration → integration}/action/view_rendering/automatic_rendering_spec.rb +0 -0
- data/spec/{new_integration → integration}/action/view_rendering/paired_view_inference_spec.rb +0 -0
- data/spec/{new_integration → integration}/action/view_rendering_spec.rb +0 -0
- data/spec/{new_integration → integration}/code_loading/loading_from_app_spec.rb +0 -0
- data/spec/{new_integration → integration}/code_loading/loading_from_lib_spec.rb +0 -0
- data/spec/{new_integration → integration}/code_loading/loading_from_slice_spec.rb +0 -0
- data/spec/{new_integration → integration}/container/application_routes_helper_spec.rb +1 -3
- data/spec/{new_integration → integration}/container/auto_injection_spec.rb +0 -0
- data/spec/{new_integration → integration}/container/auto_registration_spec.rb +0 -0
- data/spec/{new_integration → integration}/container/autoloader_spec.rb +0 -0
- data/spec/{new_integration → integration}/container/imports_spec.rb +0 -0
- data/spec/{new_integration → integration}/container/prepare_container_spec.rb +0 -0
- data/spec/{new_integration → integration}/container/shutdown_spec.rb +0 -0
- data/spec/{new_integration → integration}/container/standard_bootable_components_spec.rb +0 -0
- data/spec/{new_integration → integration}/dotenv_loading_spec.rb +0 -0
- data/spec/{new_integration → integration}/rack_app/middleware_spec.rb +9 -15
- data/spec/{new_integration → integration}/rack_app/non_booted_rack_app_spec.rb +3 -5
- data/spec/{new_integration → integration}/rack_app/rack_app_spec.rb +28 -48
- data/spec/{new_integration → integration}/settings/access_to_constants_spec.rb +0 -0
- data/spec/{new_integration → integration}/settings/loading_from_env_spec.rb +0 -0
- data/spec/{new_integration → integration}/settings/settings_component_loading_spec.rb +0 -0
- data/spec/{new_integration → integration}/settings/using_types_spec.rb +0 -0
- data/spec/{new_integration → integration}/setup_spec.rb +20 -0
- data/spec/{new_integration → integration}/slices/external_slice_spec.rb +2 -4
- data/spec/{new_integration → integration}/slices/slice_configuration_spec.rb +0 -0
- data/spec/{new_integration → integration}/slices/slice_loading_spec.rb +0 -0
- data/spec/{new_integration → integration}/slices/slice_routing_spec.rb +5 -13
- data/spec/{new_integration → integration}/slices/slice_settings_spec.rb +0 -0
- data/spec/{new_integration → integration}/slices_spec.rb +0 -0
- data/spec/{new_integration → integration}/view/context/assets_spec.rb +0 -0
- data/spec/{new_integration → integration}/view/context/inflector_spec.rb +0 -0
- data/spec/{new_integration → integration}/view/context/request_spec.rb +0 -0
- data/spec/{new_integration → integration}/view/context/routes_spec.rb +1 -3
- data/spec/{new_integration → integration}/view/context/settings_spec.rb +0 -0
- data/spec/{new_integration → integration}/view/inflector_spec.rb +0 -0
- data/spec/{new_integration → integration}/view/part_namespace_spec.rb +0 -0
- data/spec/{new_integration → integration}/view/path_spec.rb +0 -0
- data/spec/{new_integration → integration}/view/slice_configuration_spec.rb +0 -0
- data/spec/{new_integration → integration}/view/template_spec.rb +0 -0
- data/spec/{new_integration → integration}/view/views_spec.rb +0 -0
- data/spec/unit/hanami/configuration/actions_spec.rb +4 -15
- data/spec/unit/hanami/configuration/router_spec.rb +45 -0
- data/spec/unit/hanami/configuration/views_spec.rb +4 -15
- data/spec/unit/hanami/version_spec.rb +1 -1
- metadata +97 -244
- data/lib/hanami/server.rb +0 -29
- data/spec/integration/application_middleware_stack_spec.rb +0 -84
- data/spec/integration/assets/cdn_spec.rb +0 -48
- data/spec/integration/assets/fingerprint_spec.rb +0 -42
- data/spec/integration/assets/helpers_spec.rb +0 -50
- data/spec/integration/assets/serve_spec.rb +0 -70
- data/spec/integration/assets/subresource_integrity_spec.rb +0 -54
- data/spec/integration/body_parsers_spec.rb +0 -50
- data/spec/integration/cli/assets/precompile_spec.rb +0 -147
- data/spec/integration/cli/assets_spec.rb +0 -14
- data/spec/integration/cli/console_spec.rb +0 -105
- data/spec/integration/cli/db/apply_spec.rb +0 -74
- data/spec/integration/cli/db/console_spec.rb +0 -40
- data/spec/integration/cli/db/create_spec.rb +0 -50
- data/spec/integration/cli/db/drop_spec.rb +0 -54
- data/spec/integration/cli/db/migrate_spec.rb +0 -108
- data/spec/integration/cli/db/prepare_spec.rb +0 -36
- data/spec/integration/cli/db/rollback_spec.rb +0 -96
- data/spec/integration/cli/db/version_spec.rb +0 -38
- data/spec/integration/cli/db_spec.rb +0 -21
- data/spec/integration/cli/destroy/action_spec.rb +0 -143
- data/spec/integration/cli/destroy/app_spec.rb +0 -118
- data/spec/integration/cli/destroy/mailer_spec.rb +0 -74
- data/spec/integration/cli/destroy/migration_spec.rb +0 -70
- data/spec/integration/cli/destroy/model_spec.rb +0 -113
- data/spec/integration/cli/destroy_spec.rb +0 -18
- data/spec/integration/cli/generate/action_spec.rb +0 -469
- data/spec/integration/cli/generate/app_spec.rb +0 -215
- data/spec/integration/cli/generate/mailer_spec.rb +0 -189
- data/spec/integration/cli/generate/migration_spec.rb +0 -72
- data/spec/integration/cli/generate/model_spec.rb +0 -290
- data/spec/integration/cli/generate/secret_spec.rb +0 -56
- data/spec/integration/cli/generate_spec.rb +0 -19
- data/spec/integration/cli/new/database_spec.rb +0 -235
- data/spec/integration/cli/new/hanami_head_spec.rb +0 -27
- data/spec/integration/cli/new/template_spec.rb +0 -118
- data/spec/integration/cli/new/test_spec.rb +0 -274
- data/spec/integration/cli/new_spec.rb +0 -970
- data/spec/integration/cli/plugins_spec.rb +0 -39
- data/spec/integration/cli/routes_spec.rb +0 -49
- data/spec/integration/cli/server_spec.rb +0 -626
- data/spec/integration/cli/version_spec.rb +0 -85
- data/spec/integration/early_hints_spec.rb +0 -35
- data/spec/integration/handle_exceptions_spec.rb +0 -244
- data/spec/integration/head_spec.rb +0 -89
- data/spec/integration/http_headers_spec.rb +0 -29
- data/spec/integration/mailer_spec.rb +0 -32
- data/spec/integration/middleware_spec.rb +0 -81
- data/spec/integration/mount_applications_spec.rb +0 -88
- data/spec/integration/project_initializers_spec.rb +0 -40
- data/spec/integration/rackup_spec.rb +0 -35
- data/spec/integration/rake/with_minitest_spec.rb +0 -67
- data/spec/integration/rake/with_rspec_spec.rb +0 -69
- data/spec/integration/routing_helpers_spec.rb +0 -61
- data/spec/integration/security/content_security_policy_spec.rb +0 -46
- data/spec/integration/security/csrf_protection_spec.rb +0 -42
- data/spec/integration/security/force_ssl_spec.rb +0 -29
- data/spec/integration/security/x_content_type_options_spec.rb +0 -46
- data/spec/integration/security/x_frame_options_spec.rb +0 -46
- data/spec/integration/security/x_xss_protection_spec.rb +0 -46
- data/spec/integration/send_file_spec.rb +0 -51
- data/spec/integration/sessions_spec.rb +0 -247
- data/spec/integration/static_middleware_spec.rb +0 -21
- data/spec/integration/streaming_spec.rb +0 -41
- data/spec/integration/unsafe_send_file_spec.rb +0 -52
- data/spec/support/fixtures/hanami-plugin/Gemfile +0 -8
- data/spec/support/fixtures/hanami-plugin/README.md +0 -35
- data/spec/support/fixtures/hanami-plugin/Rakefile +0 -4
- data/spec/support/fixtures/hanami-plugin/bin/console +0 -15
- data/spec/support/fixtures/hanami-plugin/bin/setup +0 -8
- data/spec/support/fixtures/hanami-plugin/hanami-plugin.gemspec +0 -28
- data/spec/support/fixtures/hanami-plugin/lib/hanami/plugin/cli.rb +0 -19
- data/spec/support/fixtures/hanami-plugin/lib/hanami/plugin/version.rb +0 -7
- data/spec/support/fixtures/hanami-plugin/lib/hanami/plugin.rb +0 -8
- data/spec/unit/hanami/routes_spec.rb +0 -25
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
RSpec.describe "hanami db", type: :integration do
|
|
4
|
-
describe "apply" do
|
|
5
|
-
it "migrates, dumps structure, deletes migrations", if: RUBY_VERSION < '2.4' do
|
|
6
|
-
with_project do
|
|
7
|
-
versions = generate_migrations
|
|
8
|
-
|
|
9
|
-
hanami "db apply"
|
|
10
|
-
|
|
11
|
-
hanami "db version"
|
|
12
|
-
expect(out).to include(versions.last.to_s)
|
|
13
|
-
|
|
14
|
-
db = Pathname.new("db")
|
|
15
|
-
schema = db.join("schema.sql").to_s
|
|
16
|
-
migrations = db.join("migrations")
|
|
17
|
-
|
|
18
|
-
expect(schema).to have_file_content <<~SQL
|
|
19
|
-
CREATE TABLE `schema_migrations` (`filename` varchar(255) NOT NULL PRIMARY KEY);
|
|
20
|
-
CREATE TABLE `users` (`id` integer NOT NULL PRIMARY KEY AUTOINCREMENT, `name` varchar(255), `age` integer);
|
|
21
|
-
INSERT INTO "schema_migrations" VALUES('#{versions.first}_create_users.rb');
|
|
22
|
-
INSERT INTO "schema_migrations" VALUES('#{versions.last}_add_age_to_users.rb');
|
|
23
|
-
SQL
|
|
24
|
-
|
|
25
|
-
expect(migrations.children).to be_empty
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
it "migrates, dumps structure, deletes migrations", if: RUBY_VERSION >= '2.4' do
|
|
30
|
-
with_project do
|
|
31
|
-
versions = generate_migrations
|
|
32
|
-
|
|
33
|
-
hanami "db apply"
|
|
34
|
-
|
|
35
|
-
hanami "db version"
|
|
36
|
-
expect(out).to include(versions.last.to_s)
|
|
37
|
-
|
|
38
|
-
db = Pathname.new('db')
|
|
39
|
-
schema = db.join('schema.sql').to_s
|
|
40
|
-
migrations = db.join('migrations')
|
|
41
|
-
|
|
42
|
-
expect(schema).to have_file_content <<-SQL
|
|
43
|
-
CREATE TABLE `schema_migrations` (`filename` varchar(255) NOT NULL PRIMARY KEY);
|
|
44
|
-
CREATE TABLE `users` (`id` integer NOT NULL PRIMARY KEY AUTOINCREMENT, `name` varchar(255), `age` integer);
|
|
45
|
-
CREATE TABLE sqlite_sequence(name,seq);
|
|
46
|
-
INSERT INTO schema_migrations VALUES('#{versions.first}_create_users.rb');
|
|
47
|
-
INSERT INTO schema_migrations VALUES('#{versions.last}_add_age_to_users.rb');
|
|
48
|
-
SQL
|
|
49
|
-
|
|
50
|
-
expect(migrations.children).to be_empty
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
it "prints help message" do
|
|
55
|
-
with_project do
|
|
56
|
-
output = <<~OUT
|
|
57
|
-
Command:
|
|
58
|
-
hanami db apply
|
|
59
|
-
|
|
60
|
-
Usage:
|
|
61
|
-
hanami db apply
|
|
62
|
-
|
|
63
|
-
Description:
|
|
64
|
-
Migrate, dump the SQL schema, and delete the migrations (experimental)
|
|
65
|
-
|
|
66
|
-
Options:
|
|
67
|
-
--help, -h # Print this help
|
|
68
|
-
OUT
|
|
69
|
-
|
|
70
|
-
run_cmd "hanami db apply --help", output
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
end
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
RSpec.describe "hanami db", type: :integration do
|
|
4
|
-
describe "console" do
|
|
5
|
-
it "starts database console" do
|
|
6
|
-
with_project do
|
|
7
|
-
generate_migrations
|
|
8
|
-
hanami "db prepare"
|
|
9
|
-
|
|
10
|
-
db_console do |input, _, _|
|
|
11
|
-
input.puts('INSERT INTO users (id, name, age) VALUES(1, "Luca", 34);')
|
|
12
|
-
input.puts("SELECT * FROM users;")
|
|
13
|
-
input.puts(".quit")
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
expect(out).to include("1|Luca|34")
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it "prints help message" do
|
|
21
|
-
with_project do
|
|
22
|
-
output = <<~OUT
|
|
23
|
-
Command:
|
|
24
|
-
hanami db console
|
|
25
|
-
|
|
26
|
-
Usage:
|
|
27
|
-
hanami db console
|
|
28
|
-
|
|
29
|
-
Description:
|
|
30
|
-
Starts a database console
|
|
31
|
-
|
|
32
|
-
Options:
|
|
33
|
-
--help, -h # Print this help
|
|
34
|
-
OUT
|
|
35
|
-
|
|
36
|
-
run_cmd "hanami db console --help", output
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
RSpec.describe "hanami db", type: :integration do
|
|
4
|
-
describe "create" do
|
|
5
|
-
it "creates database" do
|
|
6
|
-
project = "bookshelf_db_create"
|
|
7
|
-
|
|
8
|
-
with_project(project) do
|
|
9
|
-
hanami "db create"
|
|
10
|
-
|
|
11
|
-
db = Pathname.new("db").join("#{project}_development.sqlite").to_s
|
|
12
|
-
expect(db).to be_an_existing_file
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it "doesn't create in production" do
|
|
17
|
-
project = "bookshelf_db_create_production"
|
|
18
|
-
|
|
19
|
-
with_project(project) do
|
|
20
|
-
RSpec::Support::Env["HANAMI_ENV"] = "production"
|
|
21
|
-
hanami "db create"
|
|
22
|
-
|
|
23
|
-
expect(exitstatus).to eq(1)
|
|
24
|
-
|
|
25
|
-
db = Pathname.new("db").join("#{project}.sqlite").to_s
|
|
26
|
-
expect(db).to_not be_an_existing_file
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
it "prints help message" do
|
|
31
|
-
with_project do
|
|
32
|
-
output = <<~OUT
|
|
33
|
-
Command:
|
|
34
|
-
hanami db create
|
|
35
|
-
|
|
36
|
-
Usage:
|
|
37
|
-
hanami db create
|
|
38
|
-
|
|
39
|
-
Description:
|
|
40
|
-
Create the database (only for development/test)
|
|
41
|
-
|
|
42
|
-
Options:
|
|
43
|
-
--help, -h # Print this help
|
|
44
|
-
OUT
|
|
45
|
-
|
|
46
|
-
run_cmd 'hanami db create --help', output
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
RSpec.describe "hanami db", type: :integration do
|
|
4
|
-
describe "drop" do
|
|
5
|
-
it "drops database" do
|
|
6
|
-
project = "bookshelf_db_drop"
|
|
7
|
-
|
|
8
|
-
with_project(project) do
|
|
9
|
-
db = Pathname.new("db").join("#{project}_development.sqlite").to_s
|
|
10
|
-
|
|
11
|
-
hanami "db create"
|
|
12
|
-
expect(db).to be_an_existing_file
|
|
13
|
-
|
|
14
|
-
hanami "db drop"
|
|
15
|
-
expect(db).to_not be_an_existing_file
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
it "doesn't drop in production" do
|
|
20
|
-
project = "bookshelf_db_drop_production"
|
|
21
|
-
|
|
22
|
-
with_project(project) do
|
|
23
|
-
RSpec::Support::Env["HANAMI_ENV"] = "production"
|
|
24
|
-
db = Pathname.new("db").join("#{project}.sqlite").to_s
|
|
25
|
-
FileUtils.touch(db) # simulate existing database
|
|
26
|
-
|
|
27
|
-
hanami "db drop"
|
|
28
|
-
|
|
29
|
-
expect(exitstatus).to eq(1)
|
|
30
|
-
expect(db).to be_an_existing_file
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
it "prints help message" do
|
|
35
|
-
with_project do
|
|
36
|
-
output = <<~OUT
|
|
37
|
-
Command:
|
|
38
|
-
hanami db drop
|
|
39
|
-
|
|
40
|
-
Usage:
|
|
41
|
-
hanami db drop
|
|
42
|
-
|
|
43
|
-
Description:
|
|
44
|
-
Drop the database (only for development/test)
|
|
45
|
-
|
|
46
|
-
Options:
|
|
47
|
-
--help, -h # Print this help
|
|
48
|
-
OUT
|
|
49
|
-
|
|
50
|
-
run_cmd 'hanami db drop --help', output
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
RSpec.describe "hanami db", type: :integration do
|
|
4
|
-
describe "migrate" do
|
|
5
|
-
it "migrates database" do
|
|
6
|
-
project = "bookshelf_db_migrate"
|
|
7
|
-
|
|
8
|
-
with_project(project) do
|
|
9
|
-
generate_migrations
|
|
10
|
-
|
|
11
|
-
hanami "db create"
|
|
12
|
-
hanami "db migrate"
|
|
13
|
-
|
|
14
|
-
db = Pathname.new("db").join("#{project}_development.sqlite")
|
|
15
|
-
|
|
16
|
-
users = `sqlite3 #{db} ".schema users"`
|
|
17
|
-
expect(users).to include("CREATE TABLE `users` (`id` integer NOT NULL PRIMARY KEY AUTOINCREMENT, `name` varchar(255), `age` integer);")
|
|
18
|
-
|
|
19
|
-
version = `sqlite3 #{db} "SELECT filename FROM schema_migrations ORDER BY filename DESC LIMIT 1"`
|
|
20
|
-
expect(version).to include("add_age_to_users")
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it "migrates database up to a version" do
|
|
25
|
-
project = "bookshelf_db_migrate_up_to_version"
|
|
26
|
-
|
|
27
|
-
with_project(project) do
|
|
28
|
-
versions = generate_migrations
|
|
29
|
-
|
|
30
|
-
hanami "db create"
|
|
31
|
-
hanami "db migrate #{versions.first}"
|
|
32
|
-
|
|
33
|
-
db = Pathname.new("db").join("#{project}_development.sqlite")
|
|
34
|
-
|
|
35
|
-
users = `sqlite3 #{db} ".schema users"`
|
|
36
|
-
expect(users).to include("CREATE TABLE `users` (`id` integer NOT NULL PRIMARY KEY AUTOINCREMENT, `name` varchar(255));")
|
|
37
|
-
|
|
38
|
-
version = `sqlite3 #{db} "SELECT filename FROM schema_migrations ORDER BY filename DESC LIMIT 1"`
|
|
39
|
-
expect(version).to include("create_users")
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
it "migrates database down to a version" do
|
|
44
|
-
project = "bookshelf_db_migrate_down_to_version"
|
|
45
|
-
|
|
46
|
-
with_project(project) do
|
|
47
|
-
versions = generate_migrations
|
|
48
|
-
|
|
49
|
-
hanami "db create"
|
|
50
|
-
hanami "db migrate" # up to latest version
|
|
51
|
-
hanami "db migrate #{versions.first}"
|
|
52
|
-
|
|
53
|
-
db = Pathname.new("db").join("#{project}_development.sqlite")
|
|
54
|
-
|
|
55
|
-
users = `sqlite3 #{db} ".schema users"`
|
|
56
|
-
expect(users).to include("CREATE TABLE `users`(`id` integer DEFAULT (NULL) NOT NULL PRIMARY KEY AUTOINCREMENT, `name` varchar(255) DEFAULT (NULL) NULL);")
|
|
57
|
-
|
|
58
|
-
version = `sqlite3 #{db} "SELECT filename FROM schema_migrations ORDER BY filename DESC LIMIT 1"`
|
|
59
|
-
expect(version).to include("create_users")
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
it "migrates database down to 0" do
|
|
64
|
-
project = "bookshelf_db_migrate_down_to_zero"
|
|
65
|
-
|
|
66
|
-
with_project(project) do
|
|
67
|
-
generate_migrations
|
|
68
|
-
|
|
69
|
-
hanami "db create"
|
|
70
|
-
hanami "db migrate" # up to latest version
|
|
71
|
-
hanami "db migrate 0"
|
|
72
|
-
|
|
73
|
-
db = Pathname.new("db").join("#{project}_development.sqlite")
|
|
74
|
-
|
|
75
|
-
users = `sqlite3 #{db} ".schema users"`
|
|
76
|
-
expect(users).to eq("")
|
|
77
|
-
|
|
78
|
-
version = `sqlite3 #{db} "SELECT filename FROM schema_migrations ORDER BY filename DESC LIMIT 1"`
|
|
79
|
-
expect(version).to eq("")
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
it "prints help message" do
|
|
84
|
-
with_project do
|
|
85
|
-
banner = <<~OUT
|
|
86
|
-
Command:
|
|
87
|
-
hanami db drop
|
|
88
|
-
|
|
89
|
-
Usage:
|
|
90
|
-
hanami db drop
|
|
91
|
-
|
|
92
|
-
Description:
|
|
93
|
-
Drop the database (only for development/test)
|
|
94
|
-
|
|
95
|
-
Options:
|
|
96
|
-
--help, -h # Print this help
|
|
97
|
-
OUT
|
|
98
|
-
|
|
99
|
-
output = [
|
|
100
|
-
banner,
|
|
101
|
-
# %r{ hanami db migrate [\d]{14} # Migrate to a specific version}
|
|
102
|
-
]
|
|
103
|
-
|
|
104
|
-
run_cmd 'hanami db drop --help', output
|
|
105
|
-
end
|
|
106
|
-
end
|
|
107
|
-
end
|
|
108
|
-
end
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
RSpec.describe "hanami db", type: :integration do
|
|
4
|
-
describe "prepare" do
|
|
5
|
-
it "prepares database" do
|
|
6
|
-
with_project do
|
|
7
|
-
versions = generate_migrations
|
|
8
|
-
|
|
9
|
-
hanami "db prepare"
|
|
10
|
-
hanami "db version"
|
|
11
|
-
|
|
12
|
-
expect(out).to include(versions.last.to_s)
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it "prints help message" do
|
|
17
|
-
with_project do
|
|
18
|
-
output = <<~OUT
|
|
19
|
-
Command:
|
|
20
|
-
hanami db prepare
|
|
21
|
-
|
|
22
|
-
Usage:
|
|
23
|
-
hanami db prepare
|
|
24
|
-
|
|
25
|
-
Description:
|
|
26
|
-
Drop, create, and migrate the database (only for development/test)
|
|
27
|
-
|
|
28
|
-
Options:
|
|
29
|
-
--help, -h # Print this help
|
|
30
|
-
OUT
|
|
31
|
-
|
|
32
|
-
run_cmd 'hanami db prepare --help', output
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
RSpec.describe "hanami db", type: :integration do
|
|
4
|
-
describe "rollback" do
|
|
5
|
-
it "rollbacks database" do
|
|
6
|
-
project = "bookshelf_db_rollback"
|
|
7
|
-
|
|
8
|
-
with_project(project) do
|
|
9
|
-
generate_migrations
|
|
10
|
-
|
|
11
|
-
hanami "db create"
|
|
12
|
-
hanami "db migrate"
|
|
13
|
-
hanami "db rollback"
|
|
14
|
-
|
|
15
|
-
db = Pathname.new("db").join("#{project}_development.sqlite")
|
|
16
|
-
|
|
17
|
-
users = `sqlite3 #{db} ".schema users"`
|
|
18
|
-
expect(users).to include("CREATE TABLE `users`(`id` integer DEFAULT (NULL) NOT NULL PRIMARY KEY AUTOINCREMENT, `name` varchar(255) DEFAULT (NULL) NULL);")
|
|
19
|
-
|
|
20
|
-
version = `sqlite3 #{db} "SELECT filename FROM schema_migrations ORDER BY filename DESC LIMIT 1"`
|
|
21
|
-
expect(version).to_not include("add_age_to_users")
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it "rollbacks database using custom steps" do
|
|
26
|
-
project = "bookshelf_db_migrate_custom_steps"
|
|
27
|
-
|
|
28
|
-
with_project(project) do
|
|
29
|
-
generate_migrations
|
|
30
|
-
|
|
31
|
-
hanami "db create"
|
|
32
|
-
hanami "db migrate"
|
|
33
|
-
hanami "db rollback 2"
|
|
34
|
-
|
|
35
|
-
db = Pathname.new("db").join("#{project}_development.sqlite")
|
|
36
|
-
|
|
37
|
-
users = `sqlite3 #{db} ".schema users"`
|
|
38
|
-
expect(users).to_not include("CREATE TABLE `users`(`id` integer DEFAULT (NULL) NOT NULL PRIMARY KEY AUTOINCREMENT, `name` varchar(255) DEFAULT (NULL) NULL);")
|
|
39
|
-
|
|
40
|
-
version = `sqlite3 #{db} "SELECT filename FROM schema_migrations ORDER BY filename DESC LIMIT 1"`
|
|
41
|
-
expect(version).to_not include("create_users")
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
it "returns an error when steps isn't an integer" do
|
|
46
|
-
with_project do
|
|
47
|
-
generate_migrations
|
|
48
|
-
|
|
49
|
-
hanami "db create"
|
|
50
|
-
hanami "db migrate"
|
|
51
|
-
|
|
52
|
-
output = "the number of steps must be a positive integer (you entered `quindici')."
|
|
53
|
-
run_cmd "hanami db rollback quindici", output, exit_status: 1
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
it "returns an error when steps is 0" do
|
|
58
|
-
with_project do
|
|
59
|
-
generate_migrations
|
|
60
|
-
|
|
61
|
-
hanami "db create"
|
|
62
|
-
hanami "db migrate"
|
|
63
|
-
|
|
64
|
-
output = "the number of steps must be a positive integer (you entered `0')."
|
|
65
|
-
run_cmd "hanami db rollback 0", output, exit_status: 1
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
it "prints help message" do
|
|
70
|
-
with_project do
|
|
71
|
-
output = <<~OUT
|
|
72
|
-
Command:
|
|
73
|
-
hanami db rollback
|
|
74
|
-
|
|
75
|
-
Usage:
|
|
76
|
-
hanami db rollback [STEPS]
|
|
77
|
-
|
|
78
|
-
Description:
|
|
79
|
-
Rollback migrations
|
|
80
|
-
|
|
81
|
-
Arguments:
|
|
82
|
-
STEPS # Number of steps to rollback the database
|
|
83
|
-
|
|
84
|
-
Options:
|
|
85
|
-
--help, -h # Print this help
|
|
86
|
-
|
|
87
|
-
Examples:
|
|
88
|
-
hanami db rollback # Rollbacks latest migration
|
|
89
|
-
hanami db rollback 2 # Rollbacks last two migration
|
|
90
|
-
OUT
|
|
91
|
-
|
|
92
|
-
run_cmd 'hanami db rollback --help', output
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
end
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
RSpec.describe "hanami db", type: :integration do
|
|
4
|
-
describe "version" do
|
|
5
|
-
it "prints database version" do
|
|
6
|
-
with_project do
|
|
7
|
-
versions = generate_migrations
|
|
8
|
-
|
|
9
|
-
hanami "db create"
|
|
10
|
-
hanami "db migrate"
|
|
11
|
-
hanami "db version"
|
|
12
|
-
|
|
13
|
-
expect(out).to include(versions.last.to_s)
|
|
14
|
-
expect(out).to_not include("SELECT * FROM")
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
it "prints help message" do
|
|
19
|
-
with_project do
|
|
20
|
-
output = <<~OUT
|
|
21
|
-
Command:
|
|
22
|
-
hanami db version
|
|
23
|
-
|
|
24
|
-
Usage:
|
|
25
|
-
hanami db version
|
|
26
|
-
|
|
27
|
-
Description:
|
|
28
|
-
Print the current migrated version
|
|
29
|
-
|
|
30
|
-
Options:
|
|
31
|
-
--help, -h # Print this help
|
|
32
|
-
OUT
|
|
33
|
-
|
|
34
|
-
run_cmd 'hanami db version --help', output
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
RSpec.describe "hanami db", type: :integration do
|
|
4
|
-
it "prints subcommands" do
|
|
5
|
-
with_project do
|
|
6
|
-
output = <<~OUT
|
|
7
|
-
Commands:
|
|
8
|
-
hanami db apply # Migrate, dump the SQL schema, and delete the migrations (experimental)
|
|
9
|
-
hanami db console # Starts a database console
|
|
10
|
-
hanami db create # Create the database (only for development/test)
|
|
11
|
-
hanami db drop # Drop the database (only for development/test)
|
|
12
|
-
hanami db migrate [VERSION] # Migrate the database
|
|
13
|
-
hanami db prepare # Drop, create, and migrate the database (only for development/test)
|
|
14
|
-
hanami db rollback [STEPS] # Rollback migrations
|
|
15
|
-
hanami db version # Print the current migrated version
|
|
16
|
-
OUT
|
|
17
|
-
|
|
18
|
-
run_cmd "hanami db", output, exit_status: 1
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
RSpec.describe "hanami destroy", type: :integration do
|
|
4
|
-
describe "action" do
|
|
5
|
-
it "destroys action" do
|
|
6
|
-
with_project do
|
|
7
|
-
generate "action web books#index"
|
|
8
|
-
output = [
|
|
9
|
-
"subtract apps/web/config/routes.rb",
|
|
10
|
-
"remove spec/web/views/books/index_spec.rb",
|
|
11
|
-
"remove apps/web/templates/books/index.html.erb",
|
|
12
|
-
"remove apps/web/views/books/index.rb",
|
|
13
|
-
"remove apps/web/controllers/books/index.rb",
|
|
14
|
-
"remove spec/web/controllers/books/index_spec.rb"
|
|
15
|
-
]
|
|
16
|
-
|
|
17
|
-
run_cmd "hanami destroy action web books#index", output
|
|
18
|
-
|
|
19
|
-
expect("spec/web/controllers/books/index_spec.rb").to_not be_an_existing_file
|
|
20
|
-
expect("apps/web/controllers/books/index.rb").to_not be_an_existing_file
|
|
21
|
-
expect("apps/web/views/books/index.rb").to_not be_an_existing_file
|
|
22
|
-
expect("apps/web/templates/books/index.html.erb").to_not be_an_existing_file
|
|
23
|
-
expect("spec/web/views/books/index_spec.rb").to_not be_an_existing_file
|
|
24
|
-
|
|
25
|
-
expect("apps/web/config/routes.rb").to_not have_file_content(%r{get '/books', to: 'books#index'})
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
it "destroys namespaced action" do
|
|
30
|
-
with_project do
|
|
31
|
-
generate "action web api/books#index"
|
|
32
|
-
output = [
|
|
33
|
-
"subtract apps/web/config/routes.rb",
|
|
34
|
-
"remove spec/web/views/api/books/index_spec.rb",
|
|
35
|
-
"remove apps/web/templates/api/books/index.html.erb",
|
|
36
|
-
"remove apps/web/views/api/books/index.rb",
|
|
37
|
-
"remove apps/web/controllers/api/books/index.rb",
|
|
38
|
-
"remove spec/web/controllers/api/books/index_spec.rb"
|
|
39
|
-
]
|
|
40
|
-
|
|
41
|
-
run_cmd "hanami destroy action web api/books#index", output
|
|
42
|
-
|
|
43
|
-
expect("spec/web/controllers/api/books/index_spec.rb").to_not be_an_existing_file
|
|
44
|
-
expect("apps/web/controllers/api/books/index.rb").to_not be_an_existing_file
|
|
45
|
-
expect("apps/web/views/api/books/index.rb").to_not be_an_existing_file
|
|
46
|
-
expect("apps/web/templates/api/books/index.html.erb").to_not be_an_existing_file
|
|
47
|
-
expect("spec/web/views/api/books/index_spec.rb").to_not be_an_existing_file
|
|
48
|
-
|
|
49
|
-
expect("apps/web/config/routes.rb").to_not have_file_content(%r{get '/api/books', to: 'api/books#index'})
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
it "destroys action without view" do
|
|
54
|
-
with_project do
|
|
55
|
-
generate "action web home#ping --skip-view --url=/ping"
|
|
56
|
-
output = [
|
|
57
|
-
"subtract apps/web/config/routes.rb",
|
|
58
|
-
"remove apps/web/controllers/home/ping.rb",
|
|
59
|
-
"remove spec/web/controllers/home/ping_spec.rb"
|
|
60
|
-
]
|
|
61
|
-
|
|
62
|
-
run_cmd "hanami destroy action web home#ping", output
|
|
63
|
-
|
|
64
|
-
expect("spec/web/controllers/home/ping_spec.rb").to_not be_an_existing_file
|
|
65
|
-
expect("apps/web/controllers/home/ping.rb").to_not be_an_existing_file
|
|
66
|
-
expect("apps/web/views/home/ping.rb").to_not be_an_existing_file
|
|
67
|
-
expect("apps/web/templates/home/ping.html.erb").to_not be_an_existing_file
|
|
68
|
-
expect("spec/web/views/home/ping_spec.rb").to_not be_an_existing_file
|
|
69
|
-
|
|
70
|
-
expect("apps/web/config/routes.rb").to_not have_file_content(%r{get '/ping', to: 'home#ping'})
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
it "fails with missing arguments" do
|
|
75
|
-
with_project do
|
|
76
|
-
output = <<~OUT
|
|
77
|
-
ERROR: "hanami destroy action" was called with no arguments
|
|
78
|
-
Usage: "hanami destroy action APP ACTION"
|
|
79
|
-
OUT
|
|
80
|
-
|
|
81
|
-
run_cmd "hanami destroy action", output, exit_status: 1
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
it "fails with missing app" do
|
|
86
|
-
with_project("bookshelf_generate_action_without_app") do
|
|
87
|
-
output = <<~OUT
|
|
88
|
-
ERROR: "hanami destroy action" was called with arguments ["home#index"]
|
|
89
|
-
Usage: "hanami destroy action APP ACTION"
|
|
90
|
-
OUT
|
|
91
|
-
|
|
92
|
-
run_cmd "hanami destroy action home#index", output, exit_status: 1
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
it "fails with unknown app" do
|
|
97
|
-
with_project("bookshelf_generate_action_with_unknown_app") do
|
|
98
|
-
output = "`foo' is not a valid APP. Please specify one of: `web'"
|
|
99
|
-
|
|
100
|
-
run_cmd "hanami destroy action foo home#index", output, exit_status: 1
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
it "fails with unknown action" do
|
|
105
|
-
with_project("bookshelf_generate_action_with_unknown_action") do
|
|
106
|
-
output = <<~OUT
|
|
107
|
-
cannot find `home#index' in `web' app.
|
|
108
|
-
please run `hanami routes' to know the existing actions.
|
|
109
|
-
OUT
|
|
110
|
-
|
|
111
|
-
run_cmd "hanami destroy action web home#index", output, exit_status: 1
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
it "prints help message" do
|
|
116
|
-
with_project do
|
|
117
|
-
output = <<~OUT
|
|
118
|
-
Command:
|
|
119
|
-
hanami destroy action
|
|
120
|
-
|
|
121
|
-
Usage:
|
|
122
|
-
hanami destroy action APP ACTION
|
|
123
|
-
|
|
124
|
-
Description:
|
|
125
|
-
Destroy an action from app
|
|
126
|
-
|
|
127
|
-
Arguments:
|
|
128
|
-
APP # REQUIRED The app name (eg. `web`)
|
|
129
|
-
ACTION # REQUIRED The action name (eg. `home#index`)
|
|
130
|
-
|
|
131
|
-
Options:
|
|
132
|
-
--help, -h # Print this help
|
|
133
|
-
|
|
134
|
-
Examples:
|
|
135
|
-
hanami destroy action web home#index # Basic usage
|
|
136
|
-
hanami destroy action admin users#index # Destroy from `admin` app
|
|
137
|
-
OUT
|
|
138
|
-
|
|
139
|
-
run_cmd 'hanami destroy action --help', output
|
|
140
|
-
end
|
|
141
|
-
end
|
|
142
|
-
end # action
|
|
143
|
-
end
|