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
data/gemfiles/rails_7.0.gemfile
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# This file was generated by Appraisal
|
|
4
|
-
|
|
5
|
-
source 'https://rubygems.org'
|
|
6
|
-
|
|
7
|
-
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
|
8
|
-
|
|
9
|
-
gem 'activesupport', '~> 7.0.0'
|
|
10
|
-
|
|
11
|
-
group :integrations, optional: true do
|
|
12
|
-
gem 'bugsnag', '>= 6.11.0'
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
gemspec
|
data/my_api/.envrc.skeleton
DELETED
data/my_api/.jetskeep
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
pack
|
data/my_api/Procfile
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
local: dynamodb-local # port 8000
|
|
2
|
-
admin: env AWS_ACCESS_KEY_ID=$DYNAMODB_ADMIN_AWS_ACCESS_KEY_ID PORT=8001 dynamodb-admin # port 8001
|
|
3
|
-
# web: jets server # port 8888
|
|
4
|
-
|
|
5
|
-
# Using Procfile to just start local dynamodb services for now.
|
|
6
|
-
# To start jets server for now use:
|
|
7
|
-
# jets server
|
data/my_api/config/dynamodb.yml
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# Jets::Config.project_namespace is special value results in using the project namespace. Example :
|
|
2
|
-
# table_namespace: <%= Jets.config.project_namespace %>
|
|
3
|
-
# This is the default value.
|
|
4
|
-
|
|
5
|
-
development:
|
|
6
|
-
table_namespace: <%= Jets.config.table_namespace %>
|
|
7
|
-
# More examples:
|
|
8
|
-
# table_namespace: demo-dev
|
|
9
|
-
|
|
10
|
-
endpoint: http://localhost:8000 # comment out if want to test with real dynamodb
|
|
11
|
-
# on AWS. You can also set the DYNAMODB_ENDPOINT environment variable.
|
|
12
|
-
# You can also are actually deploying a development environment is to
|
|
13
|
-
# change bin/server and export DYNAMODB_ENDPOINT=http://localhost:8000 at the top
|
|
14
|
-
# there.
|
|
15
|
-
|
|
16
|
-
test:
|
|
17
|
-
# table_namespace: proj # do not include the env
|
|
18
|
-
endpoint: http://localhost:8000
|
|
19
|
-
table_namespace: <%= Jets.config.table_namespace %>
|
|
20
|
-
|
|
21
|
-
production:
|
|
22
|
-
table_namespace: <%= Jets.config.table_namespace %>
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
describe ErrorController do
|
|
4
|
-
describe '#show' do
|
|
5
|
-
context 'when request error code 10' do
|
|
6
|
-
let(:code) { 10 }
|
|
7
|
-
|
|
8
|
-
let(:expected_response) do
|
|
9
|
-
{
|
|
10
|
-
error: {
|
|
11
|
-
code:,
|
|
12
|
-
message: 'You requested error code: 10',
|
|
13
|
-
},
|
|
14
|
-
}.to_json
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it 'returns 400 Bad request with error code 10' do
|
|
18
|
-
get('/error/:code', code:)
|
|
19
|
-
expect(response.status).to eq 400
|
|
20
|
-
expect(response.body).to eq expected_response
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
context 'when request error code 20' do
|
|
25
|
-
let(:code) { 20 }
|
|
26
|
-
|
|
27
|
-
let(:expected_response) do
|
|
28
|
-
{
|
|
29
|
-
error: {
|
|
30
|
-
code:,
|
|
31
|
-
message: 'You requested error code: 20',
|
|
32
|
-
},
|
|
33
|
-
}.to_json
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
it 'returns 400 Bad request with error code 20' do
|
|
37
|
-
get('/error/:code', code:)
|
|
38
|
-
expect(response.status).to eq 400
|
|
39
|
-
expect(response.body).to eq expected_response
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
describe HeaderController do
|
|
4
|
-
describe '#index' do
|
|
5
|
-
context 'when request header with a header' do
|
|
6
|
-
let(:headers) { { 'x-header': 'value' } }
|
|
7
|
-
|
|
8
|
-
it 'returns 200 OK request with header' do
|
|
9
|
-
get '/header', query: headers
|
|
10
|
-
expect(response.status).to eq 200
|
|
11
|
-
expect(response.body).to eq '{}'
|
|
12
|
-
expect(response.headers['x-header']).to eq 'value'
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
context 'when request header with multiple headers' do
|
|
17
|
-
let(:headers) do
|
|
18
|
-
{
|
|
19
|
-
'x-header': 'value1',
|
|
20
|
-
'x-second-header': 'value2',
|
|
21
|
-
}
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it 'returns 200 OK request with header' do
|
|
25
|
-
get '/header', query: headers
|
|
26
|
-
expect(response.status).to eq 200
|
|
27
|
-
expect(response.body).to eq '{}'
|
|
28
|
-
expect(response.headers['x-header']).to eq 'value1'
|
|
29
|
-
expect(response.headers['x-second-header']).to eq 'value2'
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
describe PaginationController do
|
|
4
|
-
describe '#index' do
|
|
5
|
-
let(:first_page) do
|
|
6
|
-
{
|
|
7
|
-
links: {
|
|
8
|
-
next: 'https://example.com/test/pagination?page=2',
|
|
9
|
-
},
|
|
10
|
-
page: 1,
|
|
11
|
-
}.to_json
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
let(:second_page) do
|
|
15
|
-
{
|
|
16
|
-
links: {
|
|
17
|
-
next: 'https://example.com/test/pagination?page=3',
|
|
18
|
-
previous: 'https://example.com/test/pagination?page=1',
|
|
19
|
-
},
|
|
20
|
-
page: 2,
|
|
21
|
-
}.to_json
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
let(:third_page) do
|
|
25
|
-
{
|
|
26
|
-
links: {
|
|
27
|
-
previous: 'https://example.com/test/pagination?page=2',
|
|
28
|
-
},
|
|
29
|
-
page: 3,
|
|
30
|
-
}.to_json
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
context 'without page' do
|
|
34
|
-
it 'returns a 1st page contents including 2nd page link' do
|
|
35
|
-
get '/pagination'
|
|
36
|
-
expect(response.status).to eq 200
|
|
37
|
-
expect(response.body).to eq first_page
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
context 'with page = 1' do
|
|
42
|
-
it 'returns a 1st page contents including 2nd page link' do
|
|
43
|
-
get '/pagination', page: 1
|
|
44
|
-
expect(response.status).to eq 200
|
|
45
|
-
expect(response.body).to eq first_page
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
context 'with page = 2' do
|
|
50
|
-
it 'returns a 2nd page contents including 3rd page link' do
|
|
51
|
-
get '/pagination', page: 2
|
|
52
|
-
expect(response.status).to eq 200
|
|
53
|
-
expect(response.body).to eq second_page
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
context 'with page = 3' do
|
|
58
|
-
it 'returns a 3rd page contents not including next page link' do
|
|
59
|
-
get '/pagination', page: 3
|
|
60
|
-
expect(response.status).to eq 200
|
|
61
|
-
expect(response.body).to eq third_page
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
context 'with page = 4' do
|
|
66
|
-
it 'returns 404 NOT FOUND' do
|
|
67
|
-
get '/pagination', page: 4
|
|
68
|
-
expect(response.status).to eq 404
|
|
69
|
-
expect(response.body).to be_blank
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
end
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
describe RestController do
|
|
4
|
-
describe '#index' do
|
|
5
|
-
context 'with order = asc' do
|
|
6
|
-
let(:array_of_posts) do
|
|
7
|
-
[
|
|
8
|
-
{ id: 1, title: 'Title 1' },
|
|
9
|
-
{ id: 2, title: 'Title 2' },
|
|
10
|
-
{ id: 3, title: 'Title 3' },
|
|
11
|
-
].to_json
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
it 'returns an array of posts ordered by id' do
|
|
15
|
-
get '/rest', order: 'asc'
|
|
16
|
-
expect(response.status).to eq 200
|
|
17
|
-
expect(response.body).to eq array_of_posts
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
context 'with order = desc' do
|
|
22
|
-
let(:array_of_posts) do
|
|
23
|
-
[
|
|
24
|
-
{ id: 3, title: 'Title 3' },
|
|
25
|
-
{ id: 2, title: 'Title 2' },
|
|
26
|
-
{ id: 1, title: 'Title 1' },
|
|
27
|
-
].to_json
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
it 'returns an array of posts reverse ordered by id' do
|
|
31
|
-
get '/rest', order: 'desc'
|
|
32
|
-
expect(response.status).to eq 200
|
|
33
|
-
expect(response.body).to eq array_of_posts
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
describe '#show' do
|
|
39
|
-
let(:post) do
|
|
40
|
-
{ id: 1, title: 'Title 1' }.to_json
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
it 'returns a post' do
|
|
44
|
-
get '/rest/:id', id: 1
|
|
45
|
-
expect(response.status).to eq 200
|
|
46
|
-
expect(response.body).to eq post
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
describe '#create' do
|
|
51
|
-
let(:new_post) do
|
|
52
|
-
{ id: 4, title: 'New title' }.to_json
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
it 'returns a created post' do
|
|
56
|
-
post '/rest', title: 'New title'
|
|
57
|
-
expect(response.status).to eq 201
|
|
58
|
-
expect(response.body).to eq new_post
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
describe '#update' do
|
|
63
|
-
let(:the_post) do
|
|
64
|
-
{ id: 1, title: 'Modified title' }.to_json
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
context 'with POST method' do
|
|
68
|
-
it 'returns a updated post' do
|
|
69
|
-
post '/rest/:id', id: 1, title: 'Modified title'
|
|
70
|
-
expect(response.status).to eq 200
|
|
71
|
-
expect(response.body).to eq the_post
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
context 'with PUT method' do
|
|
76
|
-
it 'returns a updated post' do
|
|
77
|
-
put '/rest/:id', id: 1, title: 'Modified title'
|
|
78
|
-
expect(response.status).to eq 200
|
|
79
|
-
expect(response.body).to eq the_post
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
context 'with PATCH method' do
|
|
84
|
-
it 'returns a updated post' do
|
|
85
|
-
patch '/rest/:id', id: 1, title: 'Modified title'
|
|
86
|
-
expect(response.status).to eq 200
|
|
87
|
-
expect(response.body).to eq the_post
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
describe '#delete' do
|
|
93
|
-
it 'returns no body' do
|
|
94
|
-
delete '/rest/:id', id: 123
|
|
95
|
-
expect(response.status).to eq 204
|
|
96
|
-
expect(response.body).to be_empty
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
end
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
describe StatusController do
|
|
4
|
-
describe '#show' do
|
|
5
|
-
context 'when request status code 200' do
|
|
6
|
-
let(:status) { 200 }
|
|
7
|
-
|
|
8
|
-
let(:expected_response) do
|
|
9
|
-
{ message: 'You requested status code: 200' }.to_json
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
it 'returns 200 OK' do
|
|
13
|
-
get('/status/:status', status:)
|
|
14
|
-
expect(response.status).to eq status
|
|
15
|
-
expect(response.body).to eq expected_response
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
context 'when request status code 400' do
|
|
20
|
-
let(:status) { 400 }
|
|
21
|
-
|
|
22
|
-
let(:expected_response) do
|
|
23
|
-
{ message: 'You requested status code: 400' }.to_json
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
it 'returns 400 Bad request' do
|
|
27
|
-
get('/status/:status', status:)
|
|
28
|
-
expect(response.status).to eq status
|
|
29
|
-
expect(response.body).to eq expected_response
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
context 'when request status code 500' do
|
|
34
|
-
let(:status) { 500 }
|
|
35
|
-
|
|
36
|
-
let(:expected_response) do
|
|
37
|
-
{ message: 'You requested status code: 500' }.to_json
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
it 'returns 500 Internal server error' do
|
|
41
|
-
get('/status/:status', status:)
|
|
42
|
-
expect(response.status).to eq status
|
|
43
|
-
expect(response.body).to eq expected_response
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"resource": "/posts",
|
|
3
|
-
"path": "/posts",
|
|
4
|
-
"httpMethod": "GET",
|
|
5
|
-
"headers": {
|
|
6
|
-
"Accept": "*/*",
|
|
7
|
-
"CloudFront-Forwarded-Proto": "https",
|
|
8
|
-
"CloudFront-Is-Desktop-Viewer": "true",
|
|
9
|
-
"CloudFront-Is-Mobile-Viewer": "false",
|
|
10
|
-
"CloudFront-Is-SmartTV-Viewer": "false",
|
|
11
|
-
"CloudFront-Is-Tablet-Viewer": "false",
|
|
12
|
-
"CloudFront-Viewer-Country": "US",
|
|
13
|
-
"Host": "qg45s7uvg2.execute-api.us-east-1.amazonaws.com",
|
|
14
|
-
"User-Agent": "curl/7.54.0",
|
|
15
|
-
"Via": "1.1 3d3d633d266d05d90a4eea7a6a59b514.cloudfront.net (CloudFront)",
|
|
16
|
-
"X-Amz-Cf-Id": "4mAgowukJJbA7lgTWITzgOPmdiDsXPCwy6vonS8VKPXCdEsmldVgdg==",
|
|
17
|
-
"X-Amzn-Trace-Id": "Root=1-59fb8ea5-38c5ad176dac130f3eb9ce97",
|
|
18
|
-
"X-Forwarded-For": "69.42.1.180, 54.239.203.118",
|
|
19
|
-
"X-Forwarded-Port": "443",
|
|
20
|
-
"X-Forwarded-Proto": "https"
|
|
21
|
-
},
|
|
22
|
-
"queryStringParameters": null,
|
|
23
|
-
"pathParameters": null,
|
|
24
|
-
"stageVariables": null,
|
|
25
|
-
"requestContext": {
|
|
26
|
-
"path": "/prod/posts",
|
|
27
|
-
"accountId": "123456789012",
|
|
28
|
-
"resourceId": "ery965",
|
|
29
|
-
"stage": "prod",
|
|
30
|
-
"requestId": "292fbcc8-c015-11e7-94fa-cd109b693f3c",
|
|
31
|
-
"identity": {
|
|
32
|
-
"cognitoIdentityPoolId": null,
|
|
33
|
-
"accountId": null,
|
|
34
|
-
"cognitoIdentityId": null,
|
|
35
|
-
"caller": null,
|
|
36
|
-
"apiKey": "",
|
|
37
|
-
"sourceIp": "69.42.1.180",
|
|
38
|
-
"accessKey": null,
|
|
39
|
-
"cognitoAuthenticationType": null,
|
|
40
|
-
"cognitoAuthenticationProvider": null,
|
|
41
|
-
"userArn": null,
|
|
42
|
-
"userAgent": "curl/7.54.0",
|
|
43
|
-
"user": null
|
|
44
|
-
},
|
|
45
|
-
"resourcePath": "/posts",
|
|
46
|
-
"httpMethod": "GET",
|
|
47
|
-
"apiId": "qg45s7uvg2"
|
|
48
|
-
},
|
|
49
|
-
"body": null,
|
|
50
|
-
"isBase64Encoded": false
|
|
51
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"resource": "/posts/{id}",
|
|
3
|
-
"path": "/posts/tung",
|
|
4
|
-
"httpMethod": "GET",
|
|
5
|
-
"headers": {
|
|
6
|
-
"Accept": "*/*",
|
|
7
|
-
"CloudFront-Forwarded-Proto": "https",
|
|
8
|
-
"CloudFront-Is-Desktop-Viewer": "true",
|
|
9
|
-
"CloudFront-Is-Mobile-Viewer": "false",
|
|
10
|
-
"CloudFront-Is-SmartTV-Viewer": "false",
|
|
11
|
-
"CloudFront-Is-Tablet-Viewer": "false",
|
|
12
|
-
"CloudFront-Viewer-Country": "US",
|
|
13
|
-
"Host": "qg45s7uvg2.execute-api.us-east-1.amazonaws.com",
|
|
14
|
-
"User-Agent": "curl/7.54.0",
|
|
15
|
-
"Via": "1.1 dc553909528b8b63475c922dc07d8ba6.cloudfront.net (CloudFront)",
|
|
16
|
-
"X-Amz-Cf-Id": "s9NB2f_Z1scd6ksA4fcXA2r4QhpSKQ6QcTLQHGfxDPfI-X7sXM3YLg==",
|
|
17
|
-
"X-Amzn-Trace-Id": "Root=1-59fb8ecb-586ab81d73e36910793d767c",
|
|
18
|
-
"X-Forwarded-For": "69.42.1.180, 54.239.203.97",
|
|
19
|
-
"X-Forwarded-Port": "443",
|
|
20
|
-
"X-Forwarded-Proto": "https"
|
|
21
|
-
},
|
|
22
|
-
"queryStringParameters": null,
|
|
23
|
-
"pathParameters": {
|
|
24
|
-
"id": "tung"
|
|
25
|
-
},
|
|
26
|
-
"stageVariables": null,
|
|
27
|
-
"requestContext": {
|
|
28
|
-
"path": "/prod/posts/tung",
|
|
29
|
-
"accountId": "123456789012",
|
|
30
|
-
"resourceId": "wf2gvu",
|
|
31
|
-
"stage": "prod",
|
|
32
|
-
"requestId": "3feafb4e-c015-11e7-85c9-194f38f4c414",
|
|
33
|
-
"identity": {
|
|
34
|
-
"cognitoIdentityPoolId": null,
|
|
35
|
-
"accountId": null,
|
|
36
|
-
"cognitoIdentityId": null,
|
|
37
|
-
"caller": null,
|
|
38
|
-
"apiKey": "",
|
|
39
|
-
"sourceIp": "69.42.1.180",
|
|
40
|
-
"accessKey": null,
|
|
41
|
-
"cognitoAuthenticationType": null,
|
|
42
|
-
"cognitoAuthenticationProvider": null,
|
|
43
|
-
"userArn": null,
|
|
44
|
-
"userAgent": "curl/7.54.0",
|
|
45
|
-
"user": null
|
|
46
|
-
},
|
|
47
|
-
"resourcePath": "/posts/{id}",
|
|
48
|
-
"httpMethod": "GET",
|
|
49
|
-
"apiId": "qg45s7uvg2"
|
|
50
|
-
},
|
|
51
|
-
"body": null,
|
|
52
|
-
"isBase64Encoded": false
|
|
53
|
-
}
|
data/rails_app/rails_6.1/.rspec
DELETED
data/rails_app/rails_6.1/Gemfile
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
source 'https://rubygems.org'
|
|
4
|
-
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
|
5
|
-
|
|
6
|
-
gem 'my_api_client', path: '../..'
|
|
7
|
-
gem 'rails', '~> 6.1.0'
|
|
8
|
-
gem 'sqlite3', '~> 1.4'
|
|
9
|
-
|
|
10
|
-
group :development, :test do
|
|
11
|
-
gem 'byebug', platforms: %i[mri mingw x64_mingw]
|
|
12
|
-
gem 'rspec-rails'
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
group :development do
|
|
16
|
-
gem 'listen', '~> 3.3'
|
|
17
|
-
end
|