my_api_client 1.3.1 → 2.0.0
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/.dockerignore +8 -0
- data/.envrc.skeleton +0 -1
- data/.github/dependabot.yml +82 -7
- data/.github/workflows/ci.yml +334 -0
- data/.github/workflows/dependabot-auto-merge.yml +96 -0
- data/.github/workflows/release.yml +33 -0
- data/.github/workflows/rubocop_challenge.yml +33 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +1 -1
- data/.ruby-version +1 -1
- data/AGENTS.md +128 -0
- data/CHANGELOG.md +54 -2
- data/CLAUDE.md +6 -0
- data/Dockerfile +22 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +67 -59
- data/README.md +398 -62
- data/docker-compose.yml +29 -0
- data/docs/runbooks/dependabot_pr_auto_merge.md +113 -0
- data/gemfiles/rails_7.2.gemfile +1 -1
- data/gemfiles/{rails_7.1.gemfile → rails_8.0.gemfile} +2 -2
- data/gemfiles/{rails_6.1.gemfile → rails_8.1.gemfile} +2 -2
- data/lib/my_api_client/default_error_handlers.rb +1 -1
- data/lib/my_api_client/errors/client_error.rb +5 -1
- data/lib/my_api_client/integrations/bugsnag.rb +1 -1
- data/lib/my_api_client/version.rb +1 -1
- data/lib/my_api_client.rb +1 -1
- data/my_api/.ruby-version +1 -1
- data/my_api/AGENTS.md +35 -0
- data/my_api/Dockerfile +25 -0
- data/my_api/Gemfile +5 -16
- data/my_api/Gemfile.lock +263 -228
- data/my_api/README.md +36 -25
- data/my_api/Rakefile +3 -2
- data/my_api/app/controllers/application_controller.rb +1 -2
- data/my_api/app/controllers/error_controller.rb +2 -2
- data/my_api/app/controllers/header_controller.rb +6 -3
- data/my_api/app/controllers/pagination_controller.rb +5 -15
- data/my_api/app/controllers/rest_controller.rb +12 -16
- data/my_api/app/controllers/status_controller.rb +3 -4
- data/my_api/config/application.rb +12 -67
- data/{rails_app/rails_6.1 → my_api}/config/boot.rb +1 -1
- data/{rails_app/rails_7.1 → my_api}/config/environment.rb +0 -2
- data/my_api/config/environments/development.rb +6 -6
- data/my_api/config/environments/production.rb +5 -8
- data/my_api/config/environments/test.rb +5 -6
- data/my_api/config/routes.rb +2 -10
- data/my_api/config.ru +2 -4
- data/my_api/public/index.html +10 -90
- data/{rails_app/rails_7.0 → my_api}/spec/rails_helper.rb +3 -4
- data/my_api/spec/requests/error_controller_spec.rb +18 -0
- data/my_api/spec/requests/pagination_controller_spec.rb +22 -0
- data/my_api/spec/requests/rest_controller_spec.rb +22 -0
- data/my_api/spec/requests/status_controller_spec.rb +20 -0
- data/my_api/spec/spec_helper.rb +15 -23
- data/my_api_client.gemspec +2 -2
- data/rails_app/AGENTS.md +13 -0
- data/rails_app/rails_7.2/Dockerfile +1 -1
- data/rails_app/rails_7.2/Gemfile +2 -0
- data/rails_app/rails_7.2/Gemfile.lock +143 -122
- data/rails_app/{rails_7.1 → rails_8.0}/.dockerignore +16 -2
- data/rails_app/{rails_6.1 → rails_8.0}/.gitattributes +2 -1
- data/rails_app/rails_8.0/.github/workflows/ci.yml +39 -0
- data/rails_app/{rails_6.1 → rails_8.0}/.gitignore +11 -7
- data/rails_app/rails_8.0/.rubocop.yml +8 -0
- data/rails_app/rails_8.0/.ruby-version +1 -0
- data/rails_app/{rails_7.1 → rails_8.0}/Dockerfile +28 -18
- data/rails_app/rails_8.0/Gemfile +15 -0
- data/rails_app/rails_8.0/Gemfile.lock +286 -0
- data/rails_app/{rails_6.1 → rails_8.0}/Rakefile +1 -3
- data/rails_app/{rails_7.1 → rails_8.0}/app/controllers/application_controller.rb +0 -2
- data/rails_app/rails_8.0/app/jobs/application_job.rb +7 -0
- data/rails_app/rails_8.0/app/mailers/application_mailer.rb +4 -0
- data/rails_app/{rails_7.0 → rails_8.0}/app/models/application_record.rb +0 -2
- data/rails_app/rails_8.0/app/views/layouts/mailer.html.erb +13 -0
- data/rails_app/rails_8.0/app/views/layouts/mailer.text.erb +1 -0
- data/rails_app/rails_8.0/bin/brakeman +7 -0
- data/rails_app/rails_8.0/bin/dev +2 -0
- data/rails_app/rails_8.0/bin/docker-entrypoint +14 -0
- data/rails_app/rails_8.0/bin/rails +4 -0
- data/rails_app/rails_8.0/bin/rake +4 -0
- data/rails_app/rails_8.0/bin/rubocop +8 -0
- data/rails_app/{rails_7.1 → rails_8.0}/bin/setup +11 -12
- data/rails_app/rails_8.0/bin/thrust +5 -0
- data/rails_app/{rails_7.1 → rails_8.0}/config/application.rb +14 -16
- data/rails_app/rails_8.0/config/boot.rb +3 -0
- data/rails_app/rails_8.0/config/cable.yml +10 -0
- data/rails_app/rails_8.0/config/credentials.yml.enc +1 -0
- data/rails_app/{rails_7.1 → rails_8.0}/config/database.yml +18 -2
- data/rails_app/{rails_6.1 → rails_8.0}/config/environment.rb +1 -3
- data/rails_app/rails_8.0/config/environments/development.rb +70 -0
- data/rails_app/rails_8.0/config/environments/production.rb +86 -0
- data/rails_app/{rails_7.1 → rails_8.0}/config/environments/test.rb +16 -19
- data/rails_app/{rails_7.1 → rails_8.0}/config/initializers/cors.rb +0 -1
- data/rails_app/{rails_7.1 → rails_8.0}/config/initializers/filter_parameter_logging.rb +2 -4
- data/rails_app/{rails_7.0 → rails_8.0}/config/initializers/inflections.rb +0 -1
- data/rails_app/rails_8.0/config/puma.rb +41 -0
- data/rails_app/{rails_7.1 → rails_8.0}/config/routes.rb +1 -3
- data/rails_app/rails_8.0/config/storage.yml +34 -0
- data/rails_app/{rails_7.1 → rails_8.0}/config.ru +1 -3
- data/rails_app/{rails_7.1 → rails_8.0}/db/seeds.rb +0 -1
- data/rails_app/{rails_7.1 → rails_8.0}/spec/rails_helper.rb +1 -1
- data/rails_app/rails_8.1/.dockerignore +45 -0
- data/rails_app/rails_8.1/.gitattributes +9 -0
- data/rails_app/rails_8.1/.github/workflows/ci.yml +52 -0
- data/rails_app/rails_8.1/.gitignore +33 -0
- data/rails_app/rails_8.1/.rspec +1 -0
- data/rails_app/rails_8.1/.rubocop.yml +8 -0
- data/rails_app/rails_8.1/.ruby-version +1 -0
- data/rails_app/rails_8.1/Dockerfile +68 -0
- data/rails_app/rails_8.1/Gemfile +15 -0
- data/rails_app/rails_8.1/Gemfile.lock +289 -0
- data/rails_app/{rails_7.0 → rails_8.1}/Rakefile +1 -3
- data/rails_app/{rails_6.1 → rails_8.1}/app/controllers/application_controller.rb +0 -2
- data/rails_app/rails_8.1/app/jobs/application_job.rb +7 -0
- data/rails_app/rails_8.1/app/mailers/application_mailer.rb +4 -0
- data/rails_app/{rails_7.1 → rails_8.1}/app/models/application_record.rb +0 -2
- data/rails_app/rails_8.1/app/views/layouts/mailer.html.erb +13 -0
- data/rails_app/rails_8.1/app/views/layouts/mailer.text.erb +1 -0
- data/rails_app/rails_8.1/bin/brakeman +7 -0
- data/rails_app/rails_8.1/bin/bundler-audit +6 -0
- data/rails_app/rails_8.1/bin/ci +6 -0
- data/rails_app/rails_8.1/bin/dev +2 -0
- data/rails_app/{rails_7.1 → rails_8.1}/bin/docker-entrypoint +1 -1
- data/rails_app/rails_8.1/bin/rails +4 -0
- data/rails_app/rails_8.1/bin/rake +4 -0
- data/rails_app/rails_8.1/bin/rubocop +8 -0
- data/rails_app/{rails_7.0 → rails_8.1}/bin/setup +13 -13
- data/rails_app/rails_8.1/bin/thrust +5 -0
- data/rails_app/{rails_6.1 → rails_8.1}/config/application.rb +19 -17
- data/rails_app/rails_8.1/config/boot.rb +3 -0
- data/rails_app/rails_8.1/config/bundler-audit.yml +5 -0
- data/rails_app/rails_8.1/config/cable.yml +10 -0
- data/rails_app/rails_8.1/config/ci.rb +19 -0
- data/rails_app/rails_8.1/config/credentials.yml.enc +1 -0
- data/rails_app/rails_8.1/config/database.yml +40 -0
- data/rails_app/{rails_7.0 → rails_8.1}/config/environment.rb +1 -3
- data/rails_app/rails_8.1/config/environments/development.rb +73 -0
- data/rails_app/rails_8.1/config/environments/production.rb +86 -0
- data/rails_app/rails_8.1/config/environments/test.rb +53 -0
- data/rails_app/{rails_7.0 → rails_8.1}/config/initializers/cors.rb +1 -2
- data/rails_app/rails_8.1/config/initializers/filter_parameter_logging.rb +8 -0
- data/rails_app/{rails_7.1 → rails_8.1}/config/initializers/inflections.rb +0 -1
- data/rails_app/rails_8.1/config/locales/en.yml +31 -0
- data/rails_app/rails_8.1/config/puma.rb +42 -0
- data/rails_app/rails_8.1/config/routes.rb +10 -0
- data/rails_app/rails_8.1/config/storage.yml +27 -0
- data/rails_app/{rails_7.0 → rails_8.1}/config.ru +1 -3
- data/rails_app/rails_8.1/db/seeds.rb +9 -0
- data/rails_app/{rails_6.1 → rails_8.1}/spec/rails_helper.rb +1 -2
- metadata +139 -136
- data/.circleci/config.yml +0 -344
- data/README.jp.md +0 -785
- data/gemfiles/rails_7.0.gemfile +0 -15
- data/my_api/.envrc.skeleton +0 -3
- data/my_api/.jetskeep +0 -1
- data/my_api/Procfile +0 -7
- data/my_api/app/helpers/application_helper.rb +0 -5
- data/my_api/app/jobs/application_job.rb +0 -7
- data/my_api/app/models/application_item.rb +0 -5
- data/my_api/config/dynamodb.yml +0 -22
- data/my_api/spec/controllers/error_controller_spec.rb +0 -43
- data/my_api/spec/controllers/header_controller_spec.rb +0 -33
- data/my_api/spec/controllers/pagination_controller_spec.rb +0 -73
- data/my_api/spec/controllers/rest_controller_spec.rb +0 -99
- data/my_api/spec/controllers/status_controller_spec.rb +0 -47
- data/my_api/spec/fixtures/payloads/posts-index.json +0 -51
- data/my_api/spec/fixtures/payloads/posts-show.json +0 -53
- data/rails_app/rails_6.1/.rspec +0 -3
- data/rails_app/rails_6.1/Gemfile +0 -17
- data/rails_app/rails_6.1/Gemfile.lock +0 -195
- data/rails_app/rails_6.1/app/models/application_record.rb +0 -5
- data/rails_app/rails_6.1/bin/bundle +0 -122
- data/rails_app/rails_6.1/bin/rails +0 -6
- data/rails_app/rails_6.1/bin/rake +0 -6
- data/rails_app/rails_6.1/bin/setup +0 -35
- data/rails_app/rails_6.1/config/credentials.yml.enc +0 -1
- data/rails_app/rails_6.1/config/database.yml +0 -25
- data/rails_app/rails_6.1/config/environments/development.rb +0 -59
- data/rails_app/rails_6.1/config/environments/production.rb +0 -97
- data/rails_app/rails_6.1/config/environments/test.rb +0 -51
- data/rails_app/rails_6.1/config/initializers/application_controller_renderer.rb +0 -9
- data/rails_app/rails_6.1/config/initializers/backtrace_silencers.rb +0 -10
- data/rails_app/rails_6.1/config/initializers/cors.rb +0 -17
- data/rails_app/rails_6.1/config/initializers/filter_parameter_logging.rb +0 -8
- data/rails_app/rails_6.1/config/initializers/inflections.rb +0 -17
- data/rails_app/rails_6.1/config/initializers/mime_types.rb +0 -5
- data/rails_app/rails_6.1/config/initializers/wrap_parameters.rb +0 -16
- data/rails_app/rails_6.1/config/locales/en.yml +0 -33
- data/rails_app/rails_6.1/config/routes.rb +0 -5
- data/rails_app/rails_6.1/config.ru +0 -8
- data/rails_app/rails_6.1/db/seeds.rb +0 -8
- data/rails_app/rails_7.0/Gemfile +0 -13
- data/rails_app/rails_7.0/Gemfile.lock +0 -212
- data/rails_app/rails_7.0/app/controllers/application_controller.rb +0 -4
- data/rails_app/rails_7.0/bin/bundle +0 -122
- data/rails_app/rails_7.0/bin/rails +0 -6
- data/rails_app/rails_7.0/bin/rake +0 -6
- data/rails_app/rails_7.0/config/application.rb +0 -41
- data/rails_app/rails_7.0/config/boot.rb +0 -5
- data/rails_app/rails_7.0/config/credentials.yml.enc +0 -1
- data/rails_app/rails_7.0/config/database.yml +0 -25
- data/rails_app/rails_7.0/config/environments/development.rb +0 -58
- data/rails_app/rails_7.0/config/environments/production.rb +0 -70
- data/rails_app/rails_7.0/config/environments/test.rb +0 -52
- data/rails_app/rails_7.0/config/initializers/filter_parameter_logging.rb +0 -8
- data/rails_app/rails_7.0/config/locales/en.yml +0 -33
- data/rails_app/rails_7.0/config/routes.rb +0 -8
- data/rails_app/rails_7.0/db/seeds.rb +0 -8
- data/rails_app/rails_7.1/Gemfile +0 -16
- data/rails_app/rails_7.1/Gemfile.lock +0 -241
- data/rails_app/rails_7.1/README.md +0 -24
- data/rails_app/rails_7.1/Rakefile +0 -8
- data/rails_app/rails_7.1/bin/bundle +0 -122
- data/rails_app/rails_7.1/bin/rails +0 -6
- data/rails_app/rails_7.1/bin/rake +0 -6
- data/rails_app/rails_7.1/config/boot.rb +0 -5
- data/rails_app/rails_7.1/config/credentials.yml.enc +0 -1
- data/rails_app/rails_7.1/config/environments/development.rb +0 -58
- data/rails_app/rails_7.1/config/environments/production.rb +0 -74
- data/rails_app/rails_7.1/config/puma.rb +0 -46
- data/rails_app/rails_7.1/public/robots.txt +0 -2
- data/rails_app/rails_7.1/spec/spec_helper.rb +0 -13
- data/rails_app/rails_7.1/vendor/.keep +0 -0
- data/rails_app/rails_7.2/.github/dependabot.yml +0 -12
- /data/rails_app/{rails_7.1 → rails_8.0}/.rspec +0 -0
- /data/rails_app/{rails_6.1 → rails_8.0}/README.md +0 -0
- /data/rails_app/{rails_6.1 → rails_8.0}/app/controllers/concerns/.keep +0 -0
- /data/rails_app/{rails_6.1/app/javascript → rails_8.0/app/models/concerns}/.keep +0 -0
- /data/rails_app/{rails_7.1 → rails_8.0}/config/locales/en.yml +0 -0
- /data/rails_app/{rails_6.1/app/models/concerns → rails_8.0/lib/tasks}/.keep +0 -0
- /data/rails_app/{rails_6.1/lib/tasks → rails_8.0/log}/.keep +0 -0
- /data/rails_app/{rails_6.1 → rails_8.0}/public/robots.txt +0 -0
- /data/rails_app/{rails_6.1/tmp → rails_8.0/script}/.keep +0 -0
- /data/rails_app/{rails_6.1 → rails_8.0}/spec/spec_helper.rb +0 -0
- /data/rails_app/{rails_6.1/tmp/pids → rails_8.0/storage}/.keep +0 -0
- /data/rails_app/{rails_6.1 → rails_8.0}/vendor/.keep +0 -0
- /data/rails_app/{rails_7.0 → rails_8.1}/README.md +0 -0
- /data/rails_app/{rails_7.1 → rails_8.1}/app/controllers/concerns/.keep +0 -0
- /data/rails_app/{rails_7.1 → rails_8.1}/app/models/concerns/.keep +0 -0
- /data/rails_app/{rails_7.1 → rails_8.1}/lib/tasks/.keep +0 -0
- /data/rails_app/{rails_7.1/storage → rails_8.1/log}/.keep +0 -0
- /data/rails_app/{rails_7.0 → rails_8.1}/public/robots.txt +0 -0
- /data/rails_app/{rails_7.1/tmp → rails_8.1/script}/.keep +0 -0
- /data/rails_app/{rails_7.0 → rails_8.1}/spec/spec_helper.rb +0 -0
- /data/rails_app/{rails_7.1/tmp/pids → rails_8.1/storage}/.keep +0 -0
- /data/rails_app/{rails_7.1/tmp/storage → rails_8.1/vendor}/.keep +0 -0
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
#
|
|
3
|
+
# Header endpoint used to test response header-based error handling.
|
|
4
4
|
class HeaderController < ApplicationController
|
|
5
|
-
# GET header
|
|
5
|
+
# GET /header
|
|
6
6
|
def index
|
|
7
|
-
params.each do |header_name, header_value|
|
|
7
|
+
params.to_unsafe_h.each do |header_name, header_value|
|
|
8
|
+
next unless header_name.start_with?('X-')
|
|
9
|
+
|
|
8
10
|
response.set_header(header_name, header_value)
|
|
9
11
|
end
|
|
12
|
+
|
|
10
13
|
render status: :ok, json: {}
|
|
11
14
|
end
|
|
12
15
|
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
#
|
|
3
|
+
# Pagination endpoint that serves three linked pages for paging tests.
|
|
4
4
|
class PaginationController < ApplicationController
|
|
5
|
-
# GET pagination
|
|
5
|
+
# GET /pagination
|
|
6
6
|
def index
|
|
7
7
|
case params[:page]&.to_s
|
|
8
8
|
when '1', nil
|
|
@@ -20,9 +20,7 @@ class PaginationController < ApplicationController
|
|
|
20
20
|
|
|
21
21
|
def first_page
|
|
22
22
|
{
|
|
23
|
-
links: {
|
|
24
|
-
next: page_link(2),
|
|
25
|
-
},
|
|
23
|
+
links: { next: page_link(2) },
|
|
26
24
|
page: 1,
|
|
27
25
|
}
|
|
28
26
|
end
|
|
@@ -39,20 +37,12 @@ class PaginationController < ApplicationController
|
|
|
39
37
|
|
|
40
38
|
def third_page
|
|
41
39
|
{
|
|
42
|
-
links: {
|
|
43
|
-
previous: page_link(2),
|
|
44
|
-
},
|
|
40
|
+
links: { previous: page_link(2) },
|
|
45
41
|
page: 3,
|
|
46
42
|
}
|
|
47
43
|
end
|
|
48
44
|
|
|
49
|
-
# NOTE: `#pagination_url` returns `http://xxxxx.execute-api.ap-northeast-1.amazonaws.com/pagination`
|
|
50
|
-
# but it should be `https://xxxxx.execute-api.ap-northeast-1.amazonaws.com/dev/pagination`.
|
|
51
|
-
# So this is workaround.
|
|
52
45
|
def page_link(page)
|
|
53
|
-
|
|
54
|
-
uri = File.join(ENV.fetch('JETS_HOST', nil), ENV.fetch('JETS_STAGE', nil), pagination_path)
|
|
55
|
-
uri.sub!('http://', 'https://')
|
|
56
|
-
URI.join(uri, query_strings)
|
|
46
|
+
"#{request.base_url}#{pagination_path(page: page)}"
|
|
57
47
|
end
|
|
58
48
|
end
|
|
@@ -1,33 +1,31 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
#
|
|
3
|
+
# REST endpoints for integration test fixtures.
|
|
4
4
|
class RestController < ApplicationController
|
|
5
|
-
# GET rest
|
|
5
|
+
# GET /rest
|
|
6
6
|
def index
|
|
7
7
|
result = params[:order] == 'desc' ? posts.reverse : posts
|
|
8
8
|
render status: :ok, json: result
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
# GET rest/:id
|
|
11
|
+
# GET /rest/:id
|
|
12
12
|
def show
|
|
13
13
|
render status: :ok, json: find_post(id:)
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
# POST rest
|
|
16
|
+
# POST /rest
|
|
17
17
|
def create
|
|
18
|
-
render status: :created,
|
|
19
|
-
json: create_post(title: params[:title])
|
|
18
|
+
render status: :created, json: create_post(title: params[:title])
|
|
20
19
|
end
|
|
21
20
|
|
|
22
|
-
#
|
|
21
|
+
# PUT/PATCH /rest/:id
|
|
23
22
|
def update
|
|
24
|
-
render status: :ok,
|
|
25
|
-
json: update_post(id:, title: params[:title])
|
|
23
|
+
render status: :ok, json: update_post(id:, title: params[:title])
|
|
26
24
|
end
|
|
27
25
|
|
|
28
|
-
# DELETE rest/:id
|
|
29
|
-
def
|
|
30
|
-
render status: :
|
|
26
|
+
# DELETE /rest/:id
|
|
27
|
+
def destroy
|
|
28
|
+
render status: :ok, json: nil
|
|
31
29
|
end
|
|
32
30
|
|
|
33
31
|
private
|
|
@@ -45,7 +43,7 @@ class RestController < ApplicationController
|
|
|
45
43
|
end
|
|
46
44
|
|
|
47
45
|
def find_post(id:)
|
|
48
|
-
posts.find { |
|
|
46
|
+
posts.find { |post| post[:id] == id }
|
|
49
47
|
end
|
|
50
48
|
|
|
51
49
|
def create_post(title:)
|
|
@@ -53,8 +51,6 @@ class RestController < ApplicationController
|
|
|
53
51
|
end
|
|
54
52
|
|
|
55
53
|
def update_post(id:, title:)
|
|
56
|
-
find_post(id:).tap
|
|
57
|
-
post[:title] = title
|
|
58
|
-
end
|
|
54
|
+
find_post(id:).tap { |post| post[:title] = title }
|
|
59
55
|
end
|
|
60
56
|
end
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
#
|
|
3
|
+
# Status endpoint that echoes requested HTTP status code.
|
|
4
4
|
class StatusController < ApplicationController
|
|
5
|
-
# GET status/:status
|
|
5
|
+
# GET /status/:status
|
|
6
6
|
def show
|
|
7
7
|
status = params[:status].to_i
|
|
8
|
-
render status:,
|
|
9
|
-
json: { message: "You requested status code: #{status}" }
|
|
8
|
+
render status:, json: { message: "You requested status code: #{status}" }
|
|
10
9
|
end
|
|
11
10
|
end
|
|
@@ -1,73 +1,18 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
config.project_name = 'my_api'
|
|
5
|
-
config.mode = 'api'
|
|
3
|
+
require_relative 'boot'
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
require 'rails'
|
|
6
|
+
require 'active_model/railtie'
|
|
7
|
+
require 'active_job/railtie'
|
|
8
|
+
require 'action_controller/railtie'
|
|
11
9
|
|
|
12
|
-
|
|
13
|
-
# config.autoload_paths = []
|
|
10
|
+
Bundler.require(*Rails.groups)
|
|
14
11
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
# config.function.role = "arn:aws:iam::#{Jets.aws.account}:role/service-role/pre-created"
|
|
22
|
-
# config.function.memory_size = 1536
|
|
23
|
-
|
|
24
|
-
# Default is 'EDGE'
|
|
25
|
-
# https://docs.aws.amazon.com/apigateway/api-reference/link-relation/restapi-create/#endpointConfiguration
|
|
26
|
-
# config.api.endpoint_type = 'PRIVATE'
|
|
27
|
-
|
|
28
|
-
# config.function.environment = {
|
|
29
|
-
# global_app_key1: "global_app_value1",
|
|
30
|
-
# global_app_key2: "global_app_value2",
|
|
31
|
-
# }
|
|
32
|
-
# More examples:
|
|
33
|
-
# config.function.dead_letter_config = { target_arn: "arn" }
|
|
34
|
-
# config.function.vpc_config = {
|
|
35
|
-
# security_group_ids: %w[sg-1 sg-2],
|
|
36
|
-
# subnet_ids: %w[subnet-1 subnet-2],
|
|
37
|
-
# }
|
|
38
|
-
# The config.function settings to the CloudFormation Lambda Function properties.
|
|
39
|
-
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html
|
|
40
|
-
# Underscored format can be used for keys to make it look more ruby-ish.
|
|
41
|
-
|
|
42
|
-
# Assets settings
|
|
43
|
-
# The config.assets.folders are folders within the public folder that will be set
|
|
44
|
-
# to public-read on s3 and served directly. IE: public/assets public/images public/packs
|
|
45
|
-
# config.assets.folders = %w[assets images packs]
|
|
46
|
-
# config.assets.max_age = 3600 # when to expire assets
|
|
47
|
-
#
|
|
48
|
-
# # IE: "public, max-age=3600" # override max_age for more fine-grain control.
|
|
49
|
-
# config.assets.cache_control = nil
|
|
50
|
-
#
|
|
51
|
-
# IE: https://cloudfront.com/my/base/path, defaults to the s3 bucket url
|
|
52
|
-
# IE: https://s3-us-west-2.amazonaws.com/demo-dev-s3bucket-1inlzkvujq8zb
|
|
53
|
-
# config.assets.base_url = nil
|
|
54
|
-
#
|
|
55
|
-
|
|
56
|
-
# config.api.endpoint_type = 'PRIVATE' # Default is 'EDGE' https://amzn.to/2r0Iu2L
|
|
57
|
-
# config.api.authorization_type = "AWS_IAM" # default is 'NONE' https://amzn.to/2qZ7zLh
|
|
58
|
-
|
|
59
|
-
# More info: http://rubyonjets.com/docs/routing/custom-domain/
|
|
60
|
-
# config.domain.hosted_zone_name = "example.com"
|
|
61
|
-
# us-west-2 REGIONAL endpoint - takes 2 minutes
|
|
62
|
-
# config.domain.cert_arn = "arn:aws:acm:us-west-2:112233445566:certificate/8d8919ce-a710-4050-976b-b33da991e123"
|
|
63
|
-
# us-east-1 EDGE endpoint - takes 10-15 minutes
|
|
64
|
-
# config.domain.cert_arn = "arn:aws:acm:us-east-1:112233445566:certificate/d68472ba-04f8-45ba-b9db-14f839d57123"
|
|
65
|
-
# config.domain.endpoint_type = "EDGE"
|
|
66
|
-
|
|
67
|
-
# By default logger needs to log to $stderr for CloudWatch to receive Lambda messages, but for
|
|
68
|
-
# local testing environment you may want to log these messages to 'test.log' file to keep your
|
|
69
|
-
# testing suite output readable.
|
|
70
|
-
# config.logger = Jets::Logger.new($strerr)
|
|
71
|
-
|
|
72
|
-
config.controllers.default_protect_from_forgery = false
|
|
12
|
+
module MyApi
|
|
13
|
+
# Rails API application used for integration testing endpoints.
|
|
14
|
+
class Application < Rails::Application
|
|
15
|
+
config.load_defaults 8.1
|
|
16
|
+
config.api_only = true
|
|
17
|
+
end
|
|
73
18
|
end
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
Rails.application.configure do
|
|
4
|
+
config.enable_reloading = true
|
|
5
|
+
config.eager_load = false
|
|
6
|
+
config.consider_all_requests_local = true
|
|
7
|
+
config.log_level = :debug
|
|
8
|
+
config.hosts.clear
|
|
9
9
|
end
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
|
9
|
-
# Docs: http://rubyonjets.com/docs/email-sending/
|
|
10
|
-
# config.action_mailer.raise_delivery_errors = false
|
|
3
|
+
Rails.application.configure do
|
|
4
|
+
config.enable_reloading = false
|
|
5
|
+
config.eager_load = true
|
|
6
|
+
config.consider_all_requests_local = false
|
|
7
|
+
config.log_level = ENV.fetch('RAILS_LOG_LEVEL', 'info')
|
|
11
8
|
end
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
config.action_mailer.delivery_method = :test
|
|
3
|
+
Rails.application.configure do
|
|
4
|
+
config.enable_reloading = false
|
|
5
|
+
config.eager_load = ENV['CI'].present?
|
|
6
|
+
config.consider_all_requests_local = true
|
|
7
|
+
config.log_level = :warn
|
|
9
8
|
end
|
data/my_api/config/routes.rb
CHANGED
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
resources 'rest', only: %i[index show create update delete]
|
|
3
|
+
Rails.application.routes.draw do
|
|
4
|
+
resources :rest, only: %i[index show create update destroy]
|
|
7
5
|
|
|
8
6
|
get 'status/:status', to: 'status#show'
|
|
9
7
|
get 'header', to: 'header#index'
|
|
10
8
|
get 'error/:code', to: 'error#show'
|
|
11
9
|
get 'pagination', to: 'pagination#index'
|
|
12
|
-
|
|
13
|
-
# The jets/public#show controller can serve static utf8 content out of the public folder.
|
|
14
|
-
# Note, as part of the deploy process Jets uploads files in the public folder to s3
|
|
15
|
-
# and serves them out of s3 directly. S3 is well suited to serve static assets.
|
|
16
|
-
# More info here: https://rubyonjets.com/docs/extras/assets-serving/
|
|
17
|
-
any '*catchall', to: 'jets/public#show'
|
|
18
10
|
end
|
data/my_api/config.ru
CHANGED
data/my_api/public/index.html
CHANGED
|
@@ -1,91 +1,11 @@
|
|
|
1
|
-
<!
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
img {
|
|
13
|
-
max-width: 320px;
|
|
14
|
-
}
|
|
15
|
-
.container {
|
|
16
|
-
max-width: 648px;
|
|
17
|
-
}
|
|
18
|
-
@media (min-width: 768px) {
|
|
19
|
-
img {
|
|
20
|
-
max-width: none;
|
|
21
|
-
}
|
|
22
|
-
.container {
|
|
23
|
-
max-width: none;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.header {
|
|
28
|
-
padding: 20px;
|
|
29
|
-
/*background-color: #b81513;*/
|
|
30
|
-
/*color: white;*/
|
|
31
|
-
}
|
|
32
|
-
.title {
|
|
33
|
-
font-size: 1.5em;
|
|
34
|
-
}
|
|
35
|
-
@media (max-width: 500px) {
|
|
36
|
-
.title {
|
|
37
|
-
font-size: 1.3em;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
.intro {
|
|
41
|
-
text-align: left;
|
|
42
|
-
font-size: large;
|
|
43
|
-
margin: 0 auto;
|
|
44
|
-
padding: 0 20px;
|
|
45
|
-
max-width: 640px;
|
|
46
|
-
}
|
|
47
|
-
pre, code {
|
|
48
|
-
padding: 0;
|
|
49
|
-
margin: 0;
|
|
50
|
-
}
|
|
51
|
-
pre {
|
|
52
|
-
margin-left: 20px;
|
|
53
|
-
width: 99%;
|
|
54
|
-
overflow: auto;
|
|
55
|
-
}
|
|
56
|
-
@media (max-width: 500px) {
|
|
57
|
-
pre {
|
|
58
|
-
margin-left: -30px;
|
|
59
|
-
font-size: 0.8em;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
</style>
|
|
63
|
-
</head>
|
|
64
|
-
|
|
65
|
-
<body>
|
|
66
|
-
<div class="container">
|
|
67
|
-
<header class="header">
|
|
68
|
-
<img src="https://s3.amazonaws.com/jets-public/jets/images/jets.png" class="logo" alt="logo" />
|
|
69
|
-
<h1 class="title">Welcome and congrats!<br /> Jets is running.</h1>
|
|
70
|
-
</header>
|
|
71
|
-
<div class="intro">
|
|
72
|
-
<p>
|
|
73
|
-
To get started:
|
|
74
|
-
</p>
|
|
75
|
-
<div class="code"><pre><code>
|
|
76
|
-
$ jets generate scaffold post title:string
|
|
77
|
-
$ jets db:create db:migrate
|
|
78
|
-
$ jets server
|
|
79
|
-
$ open http://localhost:8888/posts
|
|
80
|
-
$ jets help
|
|
81
|
-
</code></pre></div>
|
|
82
|
-
<p>More on info: <a href="http://rubyonjets.com">rubyonjets.com</a></p>
|
|
83
|
-
<p>Also check out the <a href="http://rubyonjets.com/reference">Jets CLI reference</a>.</p>
|
|
84
|
-
</div>
|
|
85
|
-
<p class="version">
|
|
86
|
-
<strong>Jets version:</strong> 4.0<br />
|
|
87
|
-
<strong>Ruby version:</strong> 3.2
|
|
88
|
-
</p>
|
|
89
|
-
</div>
|
|
90
|
-
</body>
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
+
<title>My API</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<h1>My API is running</h1>
|
|
10
|
+
</body>
|
|
91
11
|
</html>
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'spec_helper'
|
|
4
3
|
ENV['RAILS_ENV'] ||= 'test'
|
|
5
|
-
|
|
4
|
+
require_relative '../config/environment'
|
|
6
5
|
abort('The Rails environment is running in production mode!') if Rails.env.production?
|
|
6
|
+
|
|
7
7
|
require 'rspec/rails'
|
|
8
|
-
require 'my_api_client/rspec'
|
|
9
8
|
|
|
10
9
|
RSpec.configure do |config|
|
|
11
|
-
|
|
10
|
+
config.use_transactional_fixtures = false
|
|
12
11
|
config.infer_spec_type_from_file_location!
|
|
13
12
|
config.filter_rails_from_backtrace!
|
|
14
13
|
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rails_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe ErrorController do
|
|
6
|
+
# GET /error/:code
|
|
7
|
+
it 'returns bad request with error payload' do
|
|
8
|
+
get '/error/10'
|
|
9
|
+
|
|
10
|
+
expect(response).to have_http_status(:bad_request)
|
|
11
|
+
expect(JSON.parse(response.body)).to eq(
|
|
12
|
+
'error' => {
|
|
13
|
+
'code' => 10,
|
|
14
|
+
'message' => 'You requested error code: 10',
|
|
15
|
+
}
|
|
16
|
+
)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rails_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe PaginationController do
|
|
6
|
+
# GET /pagination
|
|
7
|
+
it 'returns first page with next link' do
|
|
8
|
+
get '/pagination', params: { page: 1 }
|
|
9
|
+
|
|
10
|
+
expect(response).to have_http_status(:ok)
|
|
11
|
+
json = JSON.parse(response.body)
|
|
12
|
+
expect(json.fetch('page')).to eq(1)
|
|
13
|
+
expect(json.dig('links', 'next')).to end_with('/pagination?page=2')
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# GET /pagination
|
|
17
|
+
it 'returns not found for unsupported pages' do
|
|
18
|
+
get '/pagination', params: { page: 4 }
|
|
19
|
+
|
|
20
|
+
expect(response).to have_http_status(:not_found)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rails_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe RestController do
|
|
6
|
+
# GET /rest
|
|
7
|
+
it 'returns posts in ascending order by default' do
|
|
8
|
+
get '/rest'
|
|
9
|
+
|
|
10
|
+
expect(response).to have_http_status(:ok)
|
|
11
|
+
json = JSON.parse(response.body)
|
|
12
|
+
expect(json.map { |post| post['id'] }).to eq([1, 2, 3])
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# DELETE /rest/:id
|
|
16
|
+
it 'returns null payload for delete endpoint' do
|
|
17
|
+
delete '/rest/1'
|
|
18
|
+
|
|
19
|
+
expect(response).to have_http_status(:ok)
|
|
20
|
+
expect(JSON.parse(response.body)).to be_nil
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rails_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe StatusController do
|
|
6
|
+
# GET /status/:status
|
|
7
|
+
it 'echoes requested status and message' do
|
|
8
|
+
get '/status/200'
|
|
9
|
+
|
|
10
|
+
expect(response).to have_http_status(:ok)
|
|
11
|
+
expect(JSON.parse(response.body)).to eq('message' => 'You requested status code: 200')
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# GET /status/:status
|
|
15
|
+
it 'returns requested non-200 status code' do
|
|
16
|
+
get '/status/404'
|
|
17
|
+
|
|
18
|
+
expect(response).to have_http_status(:not_found)
|
|
19
|
+
end
|
|
20
|
+
end
|
data/my_api/spec/spec_helper.rb
CHANGED
|
@@ -1,31 +1,23 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
ENV['JETS_STAGE'] ||= 'test'
|
|
6
|
-
# Ensures aws api never called. Fixture home folder does not contain ~/.aws/credentails
|
|
7
|
-
ENV['HOME'] = 'spec/fixtures/home'
|
|
3
|
+
require 'simplecov'
|
|
4
|
+
require 'simplecov_json_formatter'
|
|
8
5
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
SimpleCov.command_name(ENV.fetch('SIMPLECOV_COMMAND_NAME', 'my_api_rspec'))
|
|
7
|
+
SimpleCov.formatters = [
|
|
8
|
+
SimpleCov::Formatter::HTMLFormatter,
|
|
9
|
+
SimpleCov::Formatter::JSONFormatter,
|
|
10
|
+
]
|
|
11
|
+
SimpleCov.start
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
require 'jets/spec_helpers'
|
|
17
|
-
|
|
18
|
-
# Rspec helper module
|
|
19
|
-
module Helpers
|
|
20
|
-
def payload(name)
|
|
21
|
-
JSON.parse(File.read("spec/fixtures/payloads/#{name}.json"))
|
|
13
|
+
RSpec.configure do |config|
|
|
14
|
+
config.expect_with :rspec do |expectations|
|
|
15
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
|
22
16
|
end
|
|
23
|
-
end
|
|
24
17
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
end
|
|
18
|
+
config.mock_with :rspec do |mocks|
|
|
19
|
+
mocks.verify_partial_doubles = true
|
|
20
|
+
end
|
|
28
21
|
|
|
29
|
-
|
|
30
|
-
config.helpers.host = 'https://example.com'
|
|
22
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
|
31
23
|
end
|
data/my_api_client.gemspec
CHANGED
|
@@ -22,9 +22,9 @@ Gem::Specification.new do |spec|
|
|
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
23
23
|
spec.require_paths = ['lib']
|
|
24
24
|
|
|
25
|
-
spec.required_ruby_version = '>= 3.
|
|
25
|
+
spec.required_ruby_version = '>= 3.2.0'
|
|
26
26
|
|
|
27
|
-
spec.add_dependency 'activesupport', '>=
|
|
27
|
+
spec.add_dependency 'activesupport', '>= 7.2.0'
|
|
28
28
|
spec.add_dependency 'faraday', '>= 0.17.1'
|
|
29
29
|
spec.add_dependency 'jsonpath'
|
|
30
30
|
spec.add_dependency 'sawyer', '>= 0.8.2'
|
data/rails_app/AGENTS.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# AGENTS.md (rails_app)
|
|
2
|
+
|
|
3
|
+
## Rails Verification App Policy
|
|
4
|
+
- For a new Rails major/minor verification environment, generate it with `rails new` first instead of copying from another version directory.
|
|
5
|
+
- Keep the generated app close to Rails defaults, then apply only the minimum project-specific changes needed for CI verification.
|
|
6
|
+
- Minimum project-specific changes:
|
|
7
|
+
- Add `gem 'my_api_client', path: '../..'` to the app Gemfile.
|
|
8
|
+
- Add `gem 'rspec-rails'` and required `spec/` helpers so `verify_generator` can run RSpec.
|
|
9
|
+
- For Ruby 4.0+ compatibility in generator verification, add `gem 'benchmark'` and `gem 'cgi'` to the app Gemfile when required by Rails/runtime.
|
|
10
|
+
- Remove nested `.git` created by `rails new` under `rails_app/rails_*`.
|
|
11
|
+
- Development baseline rule in this repository also applies here:
|
|
12
|
+
- Use the oldest supported Ruby/Rails major-minor.
|
|
13
|
+
- Patch versions can be the latest available within that baseline.
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
# docker run -d -p 80:80 -p 443:443 --name my-app -e RAILS_MASTER_KEY=<value from config/master.key> my-app
|
|
6
6
|
|
|
7
7
|
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version
|
|
8
|
-
ARG RUBY_VERSION=3.
|
|
8
|
+
ARG RUBY_VERSION=3.2.9
|
|
9
9
|
FROM docker.io/library/ruby:$RUBY_VERSION-slim AS base
|
|
10
10
|
|
|
11
11
|
# Rails app lives here
|