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.
Files changed (248) hide show
  1. checksums.yaml +4 -4
  2. data/.dockerignore +8 -0
  3. data/.envrc.skeleton +0 -1
  4. data/.github/dependabot.yml +82 -7
  5. data/.github/workflows/ci.yml +334 -0
  6. data/.github/workflows/dependabot-auto-merge.yml +96 -0
  7. data/.github/workflows/release.yml +33 -0
  8. data/.github/workflows/rubocop_challenge.yml +33 -0
  9. data/.gitignore +1 -0
  10. data/.rubocop.yml +1 -1
  11. data/.ruby-version +1 -1
  12. data/AGENTS.md +128 -0
  13. data/CHANGELOG.md +54 -2
  14. data/CLAUDE.md +6 -0
  15. data/Dockerfile +22 -0
  16. data/Gemfile +1 -1
  17. data/Gemfile.lock +67 -59
  18. data/README.md +398 -62
  19. data/docker-compose.yml +29 -0
  20. data/docs/runbooks/dependabot_pr_auto_merge.md +113 -0
  21. data/gemfiles/rails_7.2.gemfile +1 -1
  22. data/gemfiles/{rails_7.1.gemfile → rails_8.0.gemfile} +2 -2
  23. data/gemfiles/{rails_6.1.gemfile → rails_8.1.gemfile} +2 -2
  24. data/lib/my_api_client/default_error_handlers.rb +1 -1
  25. data/lib/my_api_client/errors/client_error.rb +5 -1
  26. data/lib/my_api_client/integrations/bugsnag.rb +1 -1
  27. data/lib/my_api_client/version.rb +1 -1
  28. data/lib/my_api_client.rb +1 -1
  29. data/my_api/.ruby-version +1 -1
  30. data/my_api/AGENTS.md +35 -0
  31. data/my_api/Dockerfile +25 -0
  32. data/my_api/Gemfile +5 -16
  33. data/my_api/Gemfile.lock +263 -228
  34. data/my_api/README.md +36 -25
  35. data/my_api/Rakefile +3 -2
  36. data/my_api/app/controllers/application_controller.rb +1 -2
  37. data/my_api/app/controllers/error_controller.rb +2 -2
  38. data/my_api/app/controllers/header_controller.rb +6 -3
  39. data/my_api/app/controllers/pagination_controller.rb +5 -15
  40. data/my_api/app/controllers/rest_controller.rb +12 -16
  41. data/my_api/app/controllers/status_controller.rb +3 -4
  42. data/my_api/config/application.rb +12 -67
  43. data/{rails_app/rails_6.1 → my_api}/config/boot.rb +1 -1
  44. data/{rails_app/rails_7.1 → my_api}/config/environment.rb +0 -2
  45. data/my_api/config/environments/development.rb +6 -6
  46. data/my_api/config/environments/production.rb +5 -8
  47. data/my_api/config/environments/test.rb +5 -6
  48. data/my_api/config/routes.rb +2 -10
  49. data/my_api/config.ru +2 -4
  50. data/my_api/public/index.html +10 -90
  51. data/{rails_app/rails_7.0 → my_api}/spec/rails_helper.rb +3 -4
  52. data/my_api/spec/requests/error_controller_spec.rb +18 -0
  53. data/my_api/spec/requests/pagination_controller_spec.rb +22 -0
  54. data/my_api/spec/requests/rest_controller_spec.rb +22 -0
  55. data/my_api/spec/requests/status_controller_spec.rb +20 -0
  56. data/my_api/spec/spec_helper.rb +15 -23
  57. data/my_api_client.gemspec +2 -2
  58. data/rails_app/AGENTS.md +13 -0
  59. data/rails_app/rails_7.2/Dockerfile +1 -1
  60. data/rails_app/rails_7.2/Gemfile +2 -0
  61. data/rails_app/rails_7.2/Gemfile.lock +143 -122
  62. data/rails_app/{rails_7.1 → rails_8.0}/.dockerignore +16 -2
  63. data/rails_app/{rails_6.1 → rails_8.0}/.gitattributes +2 -1
  64. data/rails_app/rails_8.0/.github/workflows/ci.yml +39 -0
  65. data/rails_app/{rails_6.1 → rails_8.0}/.gitignore +11 -7
  66. data/rails_app/rails_8.0/.rubocop.yml +8 -0
  67. data/rails_app/rails_8.0/.ruby-version +1 -0
  68. data/rails_app/{rails_7.1 → rails_8.0}/Dockerfile +28 -18
  69. data/rails_app/rails_8.0/Gemfile +15 -0
  70. data/rails_app/rails_8.0/Gemfile.lock +286 -0
  71. data/rails_app/{rails_6.1 → rails_8.0}/Rakefile +1 -3
  72. data/rails_app/{rails_7.1 → rails_8.0}/app/controllers/application_controller.rb +0 -2
  73. data/rails_app/rails_8.0/app/jobs/application_job.rb +7 -0
  74. data/rails_app/rails_8.0/app/mailers/application_mailer.rb +4 -0
  75. data/rails_app/{rails_7.0 → rails_8.0}/app/models/application_record.rb +0 -2
  76. data/rails_app/rails_8.0/app/views/layouts/mailer.html.erb +13 -0
  77. data/rails_app/rails_8.0/app/views/layouts/mailer.text.erb +1 -0
  78. data/rails_app/rails_8.0/bin/brakeman +7 -0
  79. data/rails_app/rails_8.0/bin/dev +2 -0
  80. data/rails_app/rails_8.0/bin/docker-entrypoint +14 -0
  81. data/rails_app/rails_8.0/bin/rails +4 -0
  82. data/rails_app/rails_8.0/bin/rake +4 -0
  83. data/rails_app/rails_8.0/bin/rubocop +8 -0
  84. data/rails_app/{rails_7.1 → rails_8.0}/bin/setup +11 -12
  85. data/rails_app/rails_8.0/bin/thrust +5 -0
  86. data/rails_app/{rails_7.1 → rails_8.0}/config/application.rb +14 -16
  87. data/rails_app/rails_8.0/config/boot.rb +3 -0
  88. data/rails_app/rails_8.0/config/cable.yml +10 -0
  89. data/rails_app/rails_8.0/config/credentials.yml.enc +1 -0
  90. data/rails_app/{rails_7.1 → rails_8.0}/config/database.yml +18 -2
  91. data/rails_app/{rails_6.1 → rails_8.0}/config/environment.rb +1 -3
  92. data/rails_app/rails_8.0/config/environments/development.rb +70 -0
  93. data/rails_app/rails_8.0/config/environments/production.rb +86 -0
  94. data/rails_app/{rails_7.1 → rails_8.0}/config/environments/test.rb +16 -19
  95. data/rails_app/{rails_7.1 → rails_8.0}/config/initializers/cors.rb +0 -1
  96. data/rails_app/{rails_7.1 → rails_8.0}/config/initializers/filter_parameter_logging.rb +2 -4
  97. data/rails_app/{rails_7.0 → rails_8.0}/config/initializers/inflections.rb +0 -1
  98. data/rails_app/rails_8.0/config/puma.rb +41 -0
  99. data/rails_app/{rails_7.1 → rails_8.0}/config/routes.rb +1 -3
  100. data/rails_app/rails_8.0/config/storage.yml +34 -0
  101. data/rails_app/{rails_7.1 → rails_8.0}/config.ru +1 -3
  102. data/rails_app/{rails_7.1 → rails_8.0}/db/seeds.rb +0 -1
  103. data/rails_app/{rails_7.1 → rails_8.0}/spec/rails_helper.rb +1 -1
  104. data/rails_app/rails_8.1/.dockerignore +45 -0
  105. data/rails_app/rails_8.1/.gitattributes +9 -0
  106. data/rails_app/rails_8.1/.github/workflows/ci.yml +52 -0
  107. data/rails_app/rails_8.1/.gitignore +33 -0
  108. data/rails_app/rails_8.1/.rspec +1 -0
  109. data/rails_app/rails_8.1/.rubocop.yml +8 -0
  110. data/rails_app/rails_8.1/.ruby-version +1 -0
  111. data/rails_app/rails_8.1/Dockerfile +68 -0
  112. data/rails_app/rails_8.1/Gemfile +15 -0
  113. data/rails_app/rails_8.1/Gemfile.lock +289 -0
  114. data/rails_app/{rails_7.0 → rails_8.1}/Rakefile +1 -3
  115. data/rails_app/{rails_6.1 → rails_8.1}/app/controllers/application_controller.rb +0 -2
  116. data/rails_app/rails_8.1/app/jobs/application_job.rb +7 -0
  117. data/rails_app/rails_8.1/app/mailers/application_mailer.rb +4 -0
  118. data/rails_app/{rails_7.1 → rails_8.1}/app/models/application_record.rb +0 -2
  119. data/rails_app/rails_8.1/app/views/layouts/mailer.html.erb +13 -0
  120. data/rails_app/rails_8.1/app/views/layouts/mailer.text.erb +1 -0
  121. data/rails_app/rails_8.1/bin/brakeman +7 -0
  122. data/rails_app/rails_8.1/bin/bundler-audit +6 -0
  123. data/rails_app/rails_8.1/bin/ci +6 -0
  124. data/rails_app/rails_8.1/bin/dev +2 -0
  125. data/rails_app/{rails_7.1 → rails_8.1}/bin/docker-entrypoint +1 -1
  126. data/rails_app/rails_8.1/bin/rails +4 -0
  127. data/rails_app/rails_8.1/bin/rake +4 -0
  128. data/rails_app/rails_8.1/bin/rubocop +8 -0
  129. data/rails_app/{rails_7.0 → rails_8.1}/bin/setup +13 -13
  130. data/rails_app/rails_8.1/bin/thrust +5 -0
  131. data/rails_app/{rails_6.1 → rails_8.1}/config/application.rb +19 -17
  132. data/rails_app/rails_8.1/config/boot.rb +3 -0
  133. data/rails_app/rails_8.1/config/bundler-audit.yml +5 -0
  134. data/rails_app/rails_8.1/config/cable.yml +10 -0
  135. data/rails_app/rails_8.1/config/ci.rb +19 -0
  136. data/rails_app/rails_8.1/config/credentials.yml.enc +1 -0
  137. data/rails_app/rails_8.1/config/database.yml +40 -0
  138. data/rails_app/{rails_7.0 → rails_8.1}/config/environment.rb +1 -3
  139. data/rails_app/rails_8.1/config/environments/development.rb +73 -0
  140. data/rails_app/rails_8.1/config/environments/production.rb +86 -0
  141. data/rails_app/rails_8.1/config/environments/test.rb +53 -0
  142. data/rails_app/{rails_7.0 → rails_8.1}/config/initializers/cors.rb +1 -2
  143. data/rails_app/rails_8.1/config/initializers/filter_parameter_logging.rb +8 -0
  144. data/rails_app/{rails_7.1 → rails_8.1}/config/initializers/inflections.rb +0 -1
  145. data/rails_app/rails_8.1/config/locales/en.yml +31 -0
  146. data/rails_app/rails_8.1/config/puma.rb +42 -0
  147. data/rails_app/rails_8.1/config/routes.rb +10 -0
  148. data/rails_app/rails_8.1/config/storage.yml +27 -0
  149. data/rails_app/{rails_7.0 → rails_8.1}/config.ru +1 -3
  150. data/rails_app/rails_8.1/db/seeds.rb +9 -0
  151. data/rails_app/{rails_6.1 → rails_8.1}/spec/rails_helper.rb +1 -2
  152. metadata +139 -136
  153. data/.circleci/config.yml +0 -344
  154. data/README.jp.md +0 -785
  155. data/gemfiles/rails_7.0.gemfile +0 -15
  156. data/my_api/.envrc.skeleton +0 -3
  157. data/my_api/.jetskeep +0 -1
  158. data/my_api/Procfile +0 -7
  159. data/my_api/app/helpers/application_helper.rb +0 -5
  160. data/my_api/app/jobs/application_job.rb +0 -7
  161. data/my_api/app/models/application_item.rb +0 -5
  162. data/my_api/config/dynamodb.yml +0 -22
  163. data/my_api/spec/controllers/error_controller_spec.rb +0 -43
  164. data/my_api/spec/controllers/header_controller_spec.rb +0 -33
  165. data/my_api/spec/controllers/pagination_controller_spec.rb +0 -73
  166. data/my_api/spec/controllers/rest_controller_spec.rb +0 -99
  167. data/my_api/spec/controllers/status_controller_spec.rb +0 -47
  168. data/my_api/spec/fixtures/payloads/posts-index.json +0 -51
  169. data/my_api/spec/fixtures/payloads/posts-show.json +0 -53
  170. data/rails_app/rails_6.1/.rspec +0 -3
  171. data/rails_app/rails_6.1/Gemfile +0 -17
  172. data/rails_app/rails_6.1/Gemfile.lock +0 -195
  173. data/rails_app/rails_6.1/app/models/application_record.rb +0 -5
  174. data/rails_app/rails_6.1/bin/bundle +0 -122
  175. data/rails_app/rails_6.1/bin/rails +0 -6
  176. data/rails_app/rails_6.1/bin/rake +0 -6
  177. data/rails_app/rails_6.1/bin/setup +0 -35
  178. data/rails_app/rails_6.1/config/credentials.yml.enc +0 -1
  179. data/rails_app/rails_6.1/config/database.yml +0 -25
  180. data/rails_app/rails_6.1/config/environments/development.rb +0 -59
  181. data/rails_app/rails_6.1/config/environments/production.rb +0 -97
  182. data/rails_app/rails_6.1/config/environments/test.rb +0 -51
  183. data/rails_app/rails_6.1/config/initializers/application_controller_renderer.rb +0 -9
  184. data/rails_app/rails_6.1/config/initializers/backtrace_silencers.rb +0 -10
  185. data/rails_app/rails_6.1/config/initializers/cors.rb +0 -17
  186. data/rails_app/rails_6.1/config/initializers/filter_parameter_logging.rb +0 -8
  187. data/rails_app/rails_6.1/config/initializers/inflections.rb +0 -17
  188. data/rails_app/rails_6.1/config/initializers/mime_types.rb +0 -5
  189. data/rails_app/rails_6.1/config/initializers/wrap_parameters.rb +0 -16
  190. data/rails_app/rails_6.1/config/locales/en.yml +0 -33
  191. data/rails_app/rails_6.1/config/routes.rb +0 -5
  192. data/rails_app/rails_6.1/config.ru +0 -8
  193. data/rails_app/rails_6.1/db/seeds.rb +0 -8
  194. data/rails_app/rails_7.0/Gemfile +0 -13
  195. data/rails_app/rails_7.0/Gemfile.lock +0 -212
  196. data/rails_app/rails_7.0/app/controllers/application_controller.rb +0 -4
  197. data/rails_app/rails_7.0/bin/bundle +0 -122
  198. data/rails_app/rails_7.0/bin/rails +0 -6
  199. data/rails_app/rails_7.0/bin/rake +0 -6
  200. data/rails_app/rails_7.0/config/application.rb +0 -41
  201. data/rails_app/rails_7.0/config/boot.rb +0 -5
  202. data/rails_app/rails_7.0/config/credentials.yml.enc +0 -1
  203. data/rails_app/rails_7.0/config/database.yml +0 -25
  204. data/rails_app/rails_7.0/config/environments/development.rb +0 -58
  205. data/rails_app/rails_7.0/config/environments/production.rb +0 -70
  206. data/rails_app/rails_7.0/config/environments/test.rb +0 -52
  207. data/rails_app/rails_7.0/config/initializers/filter_parameter_logging.rb +0 -8
  208. data/rails_app/rails_7.0/config/locales/en.yml +0 -33
  209. data/rails_app/rails_7.0/config/routes.rb +0 -8
  210. data/rails_app/rails_7.0/db/seeds.rb +0 -8
  211. data/rails_app/rails_7.1/Gemfile +0 -16
  212. data/rails_app/rails_7.1/Gemfile.lock +0 -241
  213. data/rails_app/rails_7.1/README.md +0 -24
  214. data/rails_app/rails_7.1/Rakefile +0 -8
  215. data/rails_app/rails_7.1/bin/bundle +0 -122
  216. data/rails_app/rails_7.1/bin/rails +0 -6
  217. data/rails_app/rails_7.1/bin/rake +0 -6
  218. data/rails_app/rails_7.1/config/boot.rb +0 -5
  219. data/rails_app/rails_7.1/config/credentials.yml.enc +0 -1
  220. data/rails_app/rails_7.1/config/environments/development.rb +0 -58
  221. data/rails_app/rails_7.1/config/environments/production.rb +0 -74
  222. data/rails_app/rails_7.1/config/puma.rb +0 -46
  223. data/rails_app/rails_7.1/public/robots.txt +0 -2
  224. data/rails_app/rails_7.1/spec/spec_helper.rb +0 -13
  225. data/rails_app/rails_7.1/vendor/.keep +0 -0
  226. data/rails_app/rails_7.2/.github/dependabot.yml +0 -12
  227. /data/rails_app/{rails_7.1 → rails_8.0}/.rspec +0 -0
  228. /data/rails_app/{rails_6.1 → rails_8.0}/README.md +0 -0
  229. /data/rails_app/{rails_6.1 → rails_8.0}/app/controllers/concerns/.keep +0 -0
  230. /data/rails_app/{rails_6.1/app/javascript → rails_8.0/app/models/concerns}/.keep +0 -0
  231. /data/rails_app/{rails_7.1 → rails_8.0}/config/locales/en.yml +0 -0
  232. /data/rails_app/{rails_6.1/app/models/concerns → rails_8.0/lib/tasks}/.keep +0 -0
  233. /data/rails_app/{rails_6.1/lib/tasks → rails_8.0/log}/.keep +0 -0
  234. /data/rails_app/{rails_6.1 → rails_8.0}/public/robots.txt +0 -0
  235. /data/rails_app/{rails_6.1/tmp → rails_8.0/script}/.keep +0 -0
  236. /data/rails_app/{rails_6.1 → rails_8.0}/spec/spec_helper.rb +0 -0
  237. /data/rails_app/{rails_6.1/tmp/pids → rails_8.0/storage}/.keep +0 -0
  238. /data/rails_app/{rails_6.1 → rails_8.0}/vendor/.keep +0 -0
  239. /data/rails_app/{rails_7.0 → rails_8.1}/README.md +0 -0
  240. /data/rails_app/{rails_7.1 → rails_8.1}/app/controllers/concerns/.keep +0 -0
  241. /data/rails_app/{rails_7.1 → rails_8.1}/app/models/concerns/.keep +0 -0
  242. /data/rails_app/{rails_7.1 → rails_8.1}/lib/tasks/.keep +0 -0
  243. /data/rails_app/{rails_7.1/storage → rails_8.1/log}/.keep +0 -0
  244. /data/rails_app/{rails_7.0 → rails_8.1}/public/robots.txt +0 -0
  245. /data/rails_app/{rails_7.1/tmp → rails_8.1/script}/.keep +0 -0
  246. /data/rails_app/{rails_7.0 → rails_8.1}/spec/spec_helper.rb +0 -0
  247. /data/rails_app/{rails_7.1/tmp/pids → rails_8.1/storage}/.keep +0 -0
  248. /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
- # The header API
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
- # A Pagination API
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
- query_strings = "?#{{ page: }.to_query}"
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
- # A REST API
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
- # POST/PUT/PATCH rest/:id
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 delete
30
- render status: :no_content
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 { |p| p[:id] == id }
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 do |post|
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
- # THe status API
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
- Jets.application.configure do
4
- config.project_name = 'my_api'
5
- config.mode = 'api'
3
+ require_relative 'boot'
6
4
 
7
- config.prewarm.enable = true # default is true
8
- # config.prewarm.rate = '30 minutes' # default is '30 minutes'
9
- # config.prewarm.concurrency = 2 # default is 2
10
- # config.prewarm.public_ratio = 3 # default is 3
5
+ require 'rails'
6
+ require 'active_model/railtie'
7
+ require 'active_job/railtie'
8
+ require 'action_controller/railtie'
11
9
 
12
- # config.env_extra = 2 # can also set this with JETS_ENV_EXTRA
13
- # config.autoload_paths = []
10
+ Bundler.require(*Rails.groups)
14
11
 
15
- # config.asset_base_url = 'https://cloudfront.domain.com/assets' # example
16
-
17
- # config.cors = true # for '*'' # defaults to false
18
- # config.cors = '*.mydomain.com' # for specific domain
19
-
20
- # config.function.timeout = 30 # defaults to 30
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
@@ -2,4 +2,4 @@
2
2
 
3
3
  ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
4
4
 
5
- require 'bundler/setup' # Set up gems listed in the Gemfile.
5
+ require 'bundler/setup'
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Load the Rails application.
4
3
  require_relative 'application'
5
4
 
6
- # Initialize the Rails application.
7
5
  Rails.application.initialize!
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- Jets.application.configure do
4
- # Example:
5
- # config.function.memory_size = 1536
6
-
7
- # config.action_mailer.raise_delivery_errors = false
8
- # Docs: http://rubyonjets.com/docs/email-sending/
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
- Jets.application.configure do
4
- # Example:
5
- # config.function.memory_size = 2048
6
-
7
- # Ignore bad email addresses and do not raise email delivery errors.
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
- Jets.application.configure do
4
- # Tell Action Mailer not to deliver emails to the real world.
5
- # The :test delivery method accumulates sent emails in the
6
- # ActionMailer::Base.deliveries array.
7
- # Docs: http://rubyonjets.com/docs/email-sending/
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
@@ -1,18 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- Jets.application.routes.draw do
4
- root 'jets/public#show'
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
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # This file is used by Rack-based servers to start the application.
3
+ require_relative 'config/environment'
4
4
 
5
- require 'jets'
6
- Jets.boot
7
- run Jets.application
5
+ run Rails.application
@@ -1,91 +1,11 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Ruby on Jets</title>
5
- <meta charset="utf-8">
6
- <meta name="viewport" content="width=device-width">
7
- <style type="text/css" media="screen" charset="utf-8">
8
- body {
9
- text-align: center;
10
- margin: 0;
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
- require File.expand_path('../config/environment', __dir__)
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
- # config.use_active_record = false # [Workaround] See: https://github.com/rspec/rspec-rails/issues/2417
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
@@ -1,31 +1,23 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- ENV['JETS_TEST'] = '1'
4
- ENV['JETS_ENV'] ||= 'test'
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
- require 'byebug'
10
- require 'fileutils'
11
- require 'jets'
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
- abort('The Jets environment is running in production mode!') if Jets.env == 'production'
14
- Jets.boot
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
- RSpec.configure do |c|
26
- c.include Helpers
27
- end
18
+ config.mock_with :rspec do |mocks|
19
+ mocks.verify_partial_doubles = true
20
+ end
28
21
 
29
- Jets.application.configure do
30
- config.helpers.host = 'https://example.com'
22
+ config.shared_context_metadata_behavior = :apply_to_host_groups
31
23
  end
@@ -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.1.0'
25
+ spec.required_ruby_version = '>= 3.2.0'
26
26
 
27
- spec.add_dependency 'activesupport', '>= 6.1.0'
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'
@@ -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.1.6
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
@@ -3,6 +3,8 @@
3
3
  source 'https://rubygems.org'
4
4
 
5
5
  gem 'my_api_client', path: '../..'
6
+ gem 'benchmark'
7
+ gem 'cgi'
6
8
  gem 'puma', '>= 5.0'
7
9
  gem 'rails', '~> 7.2.1'
8
10
  gem 'sqlite3', '>= 1.4'