disco_app 0.12.7.pre.puma.pre.3 → 0.18.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (354) hide show
  1. checksums.yaml +5 -5
  2. data/Rakefile +1 -5
  3. data/app/assets/components/disco_app/forms/model-form.es6.jsx +2 -7
  4. data/app/assets/images/disco_app/.keep +0 -0
  5. data/app/assets/images/disco_app/logo.png +0 -0
  6. data/app/assets/javascripts/disco_app/components/custom/shop_row.js.jsx +2 -1
  7. data/app/assets/javascripts/disco_app/components/ui-kit/forms/base_form.es6.jsx +16 -44
  8. data/app/assets/javascripts/disco_app/components/ui-kit/forms/input-checkbox.es6.jsx +10 -5
  9. data/app/clients/disco_app/api_client.rb +25 -19
  10. data/app/clients/disco_app/graphql_client.rb +85 -0
  11. data/app/controllers/disco_app/admin/app_settings_controller.rb +2 -0
  12. data/app/controllers/disco_app/admin/application_controller.rb +3 -1
  13. data/app/controllers/disco_app/admin/concerns/app_settings_controller.rb +2 -1
  14. data/app/controllers/disco_app/admin/concerns/authenticated_controller.rb +5 -3
  15. data/app/controllers/disco_app/admin/concerns/plans_controller.rb +3 -2
  16. data/app/controllers/disco_app/admin/concerns/shops_controller.rb +1 -0
  17. data/app/controllers/disco_app/admin/concerns/sources_controller.rb +52 -0
  18. data/app/controllers/disco_app/admin/concerns/subscriptions_controller.rb +3 -2
  19. data/app/controllers/disco_app/admin/plans_controller.rb +2 -0
  20. data/app/controllers/disco_app/admin/resources/shops_controller.rb +2 -0
  21. data/app/controllers/disco_app/admin/shops_controller.rb +2 -0
  22. data/app/controllers/disco_app/admin/sources_controller.rb +5 -0
  23. data/app/controllers/disco_app/admin/subscriptions_controller.rb +2 -0
  24. data/app/controllers/disco_app/charges_controller.rb +12 -8
  25. data/app/controllers/disco_app/concerns/app_proxy_controller.rb +6 -6
  26. data/app/controllers/disco_app/concerns/authenticated_controller.rb +31 -23
  27. data/app/controllers/disco_app/concerns/carrier_request_controller.rb +22 -11
  28. data/app/controllers/disco_app/concerns/user_authenticated_controller.rb +18 -0
  29. data/app/controllers/disco_app/concerns/webhooks_controller.rb +49 -0
  30. data/app/controllers/disco_app/flow/actions_controller.rb +9 -0
  31. data/app/controllers/disco_app/flow/concerns/actions_controller.rb +23 -0
  32. data/app/controllers/disco_app/flow/concerns/trigger_usage_controller.rb +29 -0
  33. data/app/controllers/disco_app/flow/concerns/verifies_flow_payload.rb +39 -0
  34. data/app/controllers/disco_app/flow/trigger_usage_controller.rb +9 -0
  35. data/app/controllers/disco_app/frame_controller.rb +0 -1
  36. data/app/controllers/disco_app/install_controller.rb +3 -6
  37. data/app/controllers/disco_app/subscriptions_controller.rb +12 -4
  38. data/app/controllers/disco_app/user_sessions_controller.rb +58 -0
  39. data/app/controllers/disco_app/webhooks_controller.rb +2 -43
  40. data/app/controllers/sessions_controller.rb +5 -6
  41. data/app/helpers/disco_app/application_helper.rb +7 -7
  42. data/app/jobs/application_job.rb +2 -0
  43. data/app/jobs/disco_app/app_installed_job.rb +2 -0
  44. data/app/jobs/disco_app/app_uninstalled_job.rb +2 -0
  45. data/app/jobs/disco_app/concerns/app_installed_job.rb +3 -4
  46. data/app/jobs/disco_app/concerns/app_uninstalled_job.rb +2 -1
  47. data/app/jobs/disco_app/concerns/customers_data_request_job.rb +13 -0
  48. data/app/jobs/disco_app/concerns/customers_redact_job.rb +13 -0
  49. data/app/jobs/disco_app/concerns/render_asset_group_job.rb +2 -1
  50. data/app/jobs/disco_app/concerns/shop_redact_job.rb +13 -0
  51. data/app/jobs/disco_app/concerns/shop_update_job.rb +10 -3
  52. data/app/jobs/disco_app/concerns/subscription_changed_job.rb +2 -1
  53. data/app/jobs/disco_app/concerns/synchronise_carrier_service_job.rb +9 -8
  54. data/app/jobs/disco_app/concerns/synchronise_resources_job.rb +3 -6
  55. data/app/jobs/disco_app/concerns/synchronise_users_job.rb +18 -0
  56. data/app/jobs/disco_app/concerns/synchronise_webhooks_job.rb +48 -18
  57. data/app/jobs/disco_app/customers_data_request_job.rb +5 -0
  58. data/app/jobs/disco_app/customers_redact_job.rb +5 -0
  59. data/app/jobs/disco_app/flow/process_action_job.rb +11 -0
  60. data/app/jobs/disco_app/flow/process_trigger_job.rb +11 -0
  61. data/app/jobs/disco_app/render_asset_group_job.rb +2 -0
  62. data/app/jobs/disco_app/send_subscription_job.rb +1 -1
  63. data/app/jobs/disco_app/shop_job.rb +12 -5
  64. data/app/jobs/disco_app/shop_redact_job.rb +5 -0
  65. data/app/jobs/disco_app/shop_update_job.rb +2 -0
  66. data/app/jobs/disco_app/subscription_changed_job.rb +2 -0
  67. data/app/jobs/disco_app/synchronise_carrier_service_job.rb +2 -0
  68. data/app/jobs/disco_app/synchronise_resources_job.rb +2 -0
  69. data/app/jobs/disco_app/synchronise_users_job.rb +5 -0
  70. data/app/jobs/disco_app/synchronise_webhooks_job.rb +2 -0
  71. data/app/models/application_record.rb +5 -0
  72. data/app/models/disco_app/app_settings.rb +3 -1
  73. data/app/models/disco_app/application_charge.rb +8 -2
  74. data/app/models/disco_app/concerns/app_settings.rb +2 -0
  75. data/app/models/disco_app/concerns/can_be_liquified.rb +34 -18
  76. data/app/models/disco_app/concerns/has_metafields.rb +100 -44
  77. data/app/models/disco_app/concerns/plan.rb +15 -7
  78. data/app/models/disco_app/concerns/plan_code.rb +5 -3
  79. data/app/models/disco_app/concerns/renders_assets.rb +15 -21
  80. data/app/models/disco_app/concerns/shop.rb +39 -16
  81. data/app/models/disco_app/concerns/source.rb +13 -0
  82. data/app/models/disco_app/concerns/subscription.rb +14 -7
  83. data/app/models/disco_app/concerns/synchronises.rb +16 -16
  84. data/app/models/disco_app/concerns/taggable.rb +8 -3
  85. data/app/models/disco_app/concerns/user.rb +21 -0
  86. data/app/models/disco_app/flow/action.rb +9 -0
  87. data/app/models/disco_app/flow/concerns/action.rb +27 -0
  88. data/app/models/disco_app/flow/concerns/trigger.rb +28 -0
  89. data/app/models/disco_app/flow/concerns/trigger_usage.rb +17 -0
  90. data/app/models/disco_app/flow/trigger.rb +9 -0
  91. data/app/models/disco_app/flow/trigger_usage.rb +9 -0
  92. data/app/models/disco_app/plan.rb +3 -1
  93. data/app/models/disco_app/plan_code.rb +3 -1
  94. data/app/models/disco_app/recurring_application_charge.rb +9 -2
  95. data/app/models/disco_app/session_storage.rb +5 -2
  96. data/app/models/disco_app/shop.rb +3 -1
  97. data/app/models/disco_app/source.rb +5 -0
  98. data/app/models/disco_app/subscription.rb +3 -1
  99. data/app/models/disco_app/user.rb +5 -0
  100. data/app/resources/disco_app/admin/resources/concerns/shop_resource.rb +16 -19
  101. data/app/resources/disco_app/admin/resources/shop_resource.rb +1 -0
  102. data/app/services/disco_app/carrier_request_service.rb +3 -3
  103. data/app/services/disco_app/charges_service.rb +28 -38
  104. data/app/services/disco_app/flow/create_action.rb +35 -0
  105. data/app/services/disco_app/flow/create_trigger.rb +34 -0
  106. data/app/services/disco_app/flow/process_action.rb +50 -0
  107. data/app/services/disco_app/flow/process_trigger.rb +72 -0
  108. data/app/services/disco_app/flow/update_trigger_usage.rb +42 -0
  109. data/app/services/disco_app/partner_app_service.rb +151 -0
  110. data/app/services/disco_app/proxy_service.rb +2 -2
  111. data/app/services/disco_app/request_validation_service.rb +2 -2
  112. data/app/services/disco_app/subscription_service.rb +62 -28
  113. data/app/services/disco_app/synchronise_resources_service.rb +54 -0
  114. data/app/services/disco_app/webhook_service.rb +9 -11
  115. data/app/views/disco_app/admin/sources/_form.html.erb +34 -0
  116. data/app/views/disco_app/admin/sources/edit.html.erb +7 -0
  117. data/app/views/disco_app/admin/sources/index.html.erb +32 -0
  118. data/app/views/disco_app/admin/sources/new.html.erb +7 -0
  119. data/app/views/disco_app/user_sessions/new.html.erb +12 -0
  120. data/app/views/layouts/admin/_nav_items.erb +7 -0
  121. data/app/views/layouts/admin.html.erb +1 -2
  122. data/app/views/layouts/application.html.erb +1 -2
  123. data/app/views/layouts/embedded_app.html.erb +2 -4
  124. data/app/views/layouts/embedded_app_modal.html.erb +2 -3
  125. data/app/views/shopify_app/sessions/new.html.erb +2 -4
  126. data/config/routes.rb +15 -3
  127. data/db/migrate/20150525000000_create_shops_if_not_existent.rb +81 -81
  128. data/db/migrate/20170315062548_create_disco_app_sources.rb +12 -0
  129. data/db/migrate/20170315062629_add_sources_to_shop_subscriptions.rb +16 -0
  130. data/db/migrate/20170327214540_create_disco_app_users.rb +14 -0
  131. data/db/migrate/20170606160751_fix_disco_app_users_index.rb +8 -0
  132. data/db/migrate/20181229100327_create_flow_actions_and_triggers.rb +32 -0
  133. data/db/migrate/20200405000000_create_flow_trigger_usages.rb +16 -0
  134. data/lib/disco_app/configuration.rb +12 -5
  135. data/lib/disco_app/constants.rb +4 -2
  136. data/lib/disco_app/engine.rb +1 -1
  137. data/lib/disco_app/session.rb +1 -0
  138. data/lib/disco_app/support/file_fixtures.rb +2 -1
  139. data/lib/disco_app/version.rb +3 -1
  140. data/lib/generators/disco_app/install/USAGE +5 -0
  141. data/lib/generators/disco_app/install/install_generator.rb +297 -0
  142. data/lib/generators/disco_app/{templates → install/templates}/assets/javascripts/application.js +0 -0
  143. data/lib/generators/disco_app/{templates → install/templates}/assets/javascripts/components.js +0 -0
  144. data/lib/generators/disco_app/{templates → install/templates}/assets/stylesheets/application.scss +0 -0
  145. data/lib/generators/disco_app/install/templates/config/appsignal.yml +12 -0
  146. data/lib/generators/disco_app/install/templates/config/cable.yml.tt +11 -0
  147. data/lib/generators/disco_app/{templates → install/templates}/config/database.yml.tt +7 -3
  148. data/lib/generators/disco_app/install/templates/config/environments/staging.rb +108 -0
  149. data/lib/generators/disco_app/{templates → install/templates}/config/puma.rb +0 -0
  150. data/lib/generators/disco_app/{templates → install/templates}/controllers/home_controller.rb +1 -0
  151. data/lib/generators/disco_app/{templates → install/templates}/initializers/disco_app.rb +5 -0
  152. data/lib/generators/disco_app/install/templates/initializers/session_store.rb +2 -0
  153. data/lib/generators/disco_app/install/templates/initializers/shopify_app.rb +11 -0
  154. data/lib/generators/disco_app/{templates → install/templates}/initializers/shopify_session_repository.rb +2 -1
  155. data/lib/generators/disco_app/install/templates/initializers/timber.rb +4 -0
  156. data/lib/generators/disco_app/install/templates/root/.editorconfig +9 -0
  157. data/lib/generators/disco_app/install/templates/root/.env +27 -0
  158. data/lib/generators/disco_app/install/templates/root/.env.local +29 -0
  159. data/lib/generators/disco_app/install/templates/root/.github/PULL_REQUEST_TEMPLATE.md +18 -0
  160. data/lib/generators/disco_app/install/templates/root/.gitignore +65 -0
  161. data/lib/generators/disco_app/install/templates/root/.rspec +1 -0
  162. data/lib/generators/disco_app/install/templates/root/.rubocop.yml +758 -0
  163. data/lib/generators/disco_app/install/templates/root/.tool-versions +2 -0
  164. data/lib/generators/disco_app/{templates → install/templates}/root/CHECKS +0 -0
  165. data/lib/generators/disco_app/{templates → install/templates}/root/Procfile +0 -0
  166. data/lib/generators/disco_app/install/templates/root/README.md +26 -0
  167. data/lib/generators/disco_app/install/templates/root/package.json.tt +17 -0
  168. data/lib/generators/disco_app/install/templates/spec/rails_helper.rb +40 -0
  169. data/lib/generators/disco_app/install/templates/spec/spec_helper.rb +24 -0
  170. data/lib/generators/disco_app/install/templates/spec/support/active_job.rb +13 -0
  171. data/lib/generators/disco_app/install/templates/spec/support/coveralls.rb +3 -0
  172. data/lib/generators/disco_app/install/templates/spec/support/database_cleaner.rb +17 -0
  173. data/lib/generators/disco_app/install/templates/spec/support/factory_bot.rb +3 -0
  174. data/lib/generators/disco_app/install/templates/spec/support/helpers/json_helper.rb +13 -0
  175. data/lib/generators/disco_app/install/templates/spec/support/shared_examples/a_synchronise_job.rb +12 -0
  176. data/lib/generators/disco_app/install/templates/spec/support/shoulda.rb +6 -0
  177. data/lib/generators/disco_app/install/templates/spec/support/vcr.rb +14 -0
  178. data/lib/generators/disco_app/install/templates/spec/support/webmock.rb +8 -0
  179. data/lib/generators/disco_app/{templates → install/templates}/views/home/index.html.erb +0 -0
  180. data/lib/generators/disco_app/react/USAGE +5 -0
  181. data/lib/generators/disco_app/react/react_generator.rb +108 -0
  182. data/lib/generators/disco_app/react/templates/app/controllers/embedded/api/base_controller.rb +18 -0
  183. data/lib/generators/disco_app/react/templates/app/controllers/embedded/api/home_controller.rb +10 -0
  184. data/lib/generators/disco_app/react/templates/app/controllers/embedded/api/shops_controller.rb +11 -0
  185. data/lib/generators/disco_app/react/templates/app/controllers/embedded/api/users_controller.rb +11 -0
  186. data/lib/generators/disco_app/react/templates/app/controllers/embedded/home_controller.rb +13 -0
  187. data/lib/generators/disco_app/react/templates/app/models/api_response.rb +107 -0
  188. data/lib/generators/disco_app/react/templates/app/serializers/disco_app/shop_serializer.rb +13 -0
  189. data/lib/generators/disco_app/react/templates/app/serializers/disco_app/user_serializer.rb +13 -0
  190. data/lib/generators/disco_app/react/templates/app/serializers/empty_serializer.rb +5 -0
  191. data/lib/generators/disco_app/react/templates/app/serializers/error_serializer.rb +76 -0
  192. data/lib/generators/disco_app/react/templates/app/views/embedded/home/index.html.erb +12 -0
  193. data/lib/generators/disco_app/react/templates/app/views/layouts/embedded.html.erb +10 -0
  194. data/lib/generators/disco_app/react/templates/app/webpack/javascripts/embedded/components/App.jsx +77 -0
  195. data/lib/generators/disco_app/react/templates/app/webpack/javascripts/embedded/components/HomePage.jsx +34 -0
  196. data/lib/generators/disco_app/react/templates/app/webpack/javascripts/embedded/components/Shared/EmbeddedPage.jsx +70 -0
  197. data/lib/generators/disco_app/react/templates/app/webpack/javascripts/embedded/components/Shared/ErrorBanner.jsx +58 -0
  198. data/lib/generators/disco_app/react/templates/app/webpack/javascripts/embedded/components/Shared/PaginationWrapper.jsx +10 -0
  199. data/lib/generators/disco_app/react/templates/app/webpack/javascripts/embedded/components/Shared/ScrollToTop.jsx +23 -0
  200. data/lib/generators/disco_app/react/templates/app/webpack/javascripts/embedded/components/withApi.jsx +125 -0
  201. data/lib/generators/disco_app/react/templates/app/webpack/javascripts/embedded/index.jsx +39 -0
  202. data/lib/generators/disco_app/react/templates/app/webpack/javascripts/embedded/utils.js +19 -0
  203. data/lib/generators/disco_app/react/templates/app/webpack/packs/embedded.js +2 -0
  204. data/lib/generators/disco_app/react/templates/app/webpack/stylesheets/embedded/shared/banners.scss +7 -0
  205. data/lib/generators/disco_app/react/templates/app/webpack/stylesheets/embedded/shared/busy.scss +3 -0
  206. data/lib/generators/disco_app/react/templates/app/webpack/stylesheets/embedded/shared/index.scss +3 -0
  207. data/lib/generators/disco_app/react/templates/app/webpack/stylesheets/embedded/shared/pagination.scss +5 -0
  208. data/lib/generators/disco_app/react/templates/app/webpack/stylesheets/embedded.scss +2 -0
  209. data/lib/generators/disco_app/react/templates/config/initializers/mime_types.rb +13 -0
  210. data/lib/generators/disco_app/react/templates/config/initializers/omniauth.rb +27 -0
  211. data/lib/generators/disco_app/react/templates/config/initializers/version.rb.tt +7 -0
  212. data/lib/generators/disco_app/react/templates/config/webpack/staging.js +5 -0
  213. data/lib/generators/disco_app/react/templates/config/webpack/test.js +5 -0
  214. data/lib/generators/disco_app/react/templates/config/webpacker.yml +96 -0
  215. data/lib/generators/disco_app/react/templates/root/.eslintignore +5 -0
  216. data/lib/generators/disco_app/react/templates/root/.eslintrc +69 -0
  217. data/lib/generators/disco_app/react/templates/root/.prettierrc +3 -0
  218. data/lib/generators/disco_app/react/templates/root/VERSION +1 -0
  219. data/lib/generators/disco_app/react/templates/root/babel.config.js +72 -0
  220. data/lib/generators/disco_app/react/templates/root/package.json.tt +84 -0
  221. data/lib/generators/disco_app/react/templates/root/postcss.config.js +14 -0
  222. data/lib/tasks/api.rake +0 -2
  223. data/lib/tasks/carrier_service.rake +0 -2
  224. data/lib/tasks/database.rake +1 -1
  225. data/lib/tasks/partner_app.rake +26 -0
  226. data/lib/tasks/sessions.rake +0 -2
  227. data/lib/tasks/shops.rake +0 -2
  228. data/lib/tasks/users.rake +8 -0
  229. data/lib/tasks/webhooks.rake +0 -2
  230. data/test/clients/disco_app/api_client_test.rb +3 -3
  231. data/test/controllers/disco_app/admin/shops_controller_test.rb +1 -0
  232. data/test/controllers/disco_app/charges_controller_test.rb +19 -21
  233. data/test/controllers/disco_app/flow/trigger_usage_controller_test.rb +41 -0
  234. data/test/controllers/disco_app/install_controller_test.rb +2 -1
  235. data/test/controllers/disco_app/subscriptions_controller_test.rb +6 -5
  236. data/test/controllers/disco_app/webhooks_controller_test.rb +6 -5
  237. data/test/controllers/home_controller_test.rb +2 -2
  238. data/test/controllers/proxy_controller_test.rb +3 -3
  239. data/test/disco_app_test.rb +3 -1
  240. data/test/dummy/Rakefile +1 -1
  241. data/test/dummy/app/assets/config/manifest.js +2 -0
  242. data/test/dummy/app/controllers/application_controller.rb +2 -0
  243. data/test/dummy/app/controllers/carrier_request_controller.rb +1 -0
  244. data/test/dummy/app/controllers/disco_app/admin/shops_controller.rb +2 -1
  245. data/test/dummy/app/controllers/home_controller.rb +1 -0
  246. data/test/dummy/app/controllers/proxy_controller.rb +2 -1
  247. data/test/dummy/app/javascript/packs/application.js +18 -0
  248. data/test/dummy/app/jobs/application_job.rb +2 -0
  249. data/test/dummy/app/jobs/carts_update_job.rb +1 -1
  250. data/test/dummy/app/jobs/disco_app/app_installed_job.rb +2 -3
  251. data/test/dummy/app/jobs/disco_app/app_uninstalled_job.rb +3 -2
  252. data/test/dummy/app/jobs/products_create_job.rb +1 -1
  253. data/test/dummy/app/jobs/products_delete_job.rb +1 -1
  254. data/test/dummy/app/jobs/products_update_job.rb +1 -1
  255. data/test/dummy/app/models/application_record.rb +5 -0
  256. data/test/dummy/app/models/cart.rb +8 -7
  257. data/test/dummy/app/models/disco_app/shop.rb +8 -6
  258. data/test/dummy/app/models/js_configuration.rb +2 -1
  259. data/test/dummy/app/models/product.rb +4 -3
  260. data/test/dummy/app/models/widget_configuration.rb +2 -1
  261. data/test/dummy/babel.config.js +72 -0
  262. data/test/dummy/bin/bundle +1 -1
  263. data/test/dummy/bin/rails +1 -1
  264. data/test/dummy/bin/setup +8 -8
  265. data/test/dummy/bin/webpack +19 -0
  266. data/test/dummy/bin/webpack-dev-server +19 -0
  267. data/test/dummy/config/application.rb +3 -5
  268. data/test/dummy/config/boot.rb +2 -2
  269. data/test/dummy/config/database.yml +4 -0
  270. data/test/dummy/config/environment.rb +1 -1
  271. data/test/dummy/config/environments/staging.rb +85 -0
  272. data/test/dummy/config/environments/test.rb +2 -2
  273. data/test/dummy/config/initializers/disco_app.rb +8 -1
  274. data/test/dummy/config/initializers/omniauth.rb +3 -4
  275. data/test/dummy/config/initializers/session_store.rb +1 -1
  276. data/test/dummy/config/initializers/shopify_app.rb +1 -0
  277. data/test/dummy/config/initializers/shopify_session_repository.rb +1 -1
  278. data/test/dummy/config/routes.rb +0 -2
  279. data/test/dummy/config/secrets.yml +3 -0
  280. data/test/dummy/config/webpack/development.js +5 -0
  281. data/test/dummy/config/webpack/environment.js +3 -0
  282. data/test/dummy/config/webpack/production.js +5 -0
  283. data/test/dummy/config/webpack/test.js +5 -0
  284. data/test/dummy/config/webpacker.yml +95 -0
  285. data/test/dummy/db/migrate/20160307182229_create_products.rb +3 -1
  286. data/test/dummy/db/migrate/20160530160739_create_asset_models.rb +3 -1
  287. data/test/dummy/db/migrate/20161105054746_create_carts.rb +3 -1
  288. data/test/dummy/db/schema.rb +141 -88
  289. data/test/dummy/package.json +10 -0
  290. data/test/dummy/postcss.config.js +12 -0
  291. data/test/dummy/yarn.lock +7278 -0
  292. data/test/fixtures/api/subscriptions/valid_request.json +2 -2
  293. data/test/fixtures/api/widget_store/charges/{activate_application_charge_request.json → get_active_application_charge_response.json} +1 -1
  294. data/test/fixtures/api/widget_store/charges/{activate_recurring_application_charge_request.json → get_active_recurring_application_charge_response.json} +2 -2
  295. data/test/fixtures/api/widget_store/empty_webhooks.json +3 -0
  296. data/test/fixtures/api/widget_store/existing_webhooks.json +43 -0
  297. data/test/fixtures/api/widget_store/products/get_metafields_empty_response.json +3 -0
  298. data/test/fixtures/api/widget_store/products/get_metafields_with_existing_response.json +11 -0
  299. data/test/fixtures/api/widget_store/products/write_metafields_multiple_namespaces_request.json +4 -0
  300. data/test/fixtures/api/widget_store/products/write_metafields_single_namespace_request.json +2 -0
  301. data/test/fixtures/api/widget_store/products/write_metafields_with_existing_single_namespace_request.json +21 -0
  302. data/test/fixtures/api/widget_store/{charges/activate_application_charge_response.json → products/write_metafields_with_existing_single_namespace_response.json} +0 -0
  303. data/test/fixtures/api/widget_store/shops/get_metafields_with_existing_response.json +11 -0
  304. data/test/fixtures/api/widget_store/shops/write_metafields_with_existing_first_request.json +9 -0
  305. data/test/fixtures/api/widget_store/{charges/activate_recurring_application_charge_response.json → shops/write_metafields_with_existing_first_response.json} +0 -0
  306. data/test/fixtures/api/widget_store/shops/write_metafields_with_existing_second_request.json +9 -0
  307. data/test/fixtures/api/widget_store/shops/write_metafields_with_existing_second_response.json +1 -0
  308. data/test/fixtures/api/widget_store/users.json +42 -0
  309. data/test/fixtures/disco_app/shops.yml +9 -2
  310. data/test/fixtures/disco_app/sources.yml +3 -0
  311. data/test/fixtures/liquid/model.liquid +8 -8
  312. data/test/fixtures/webhooks/flow/trigger_usage.json +7 -0
  313. data/test/integration/synchronises_test.rb +20 -13
  314. data/test/jobs/disco_app/app_installed_job_test.rb +30 -11
  315. data/test/jobs/disco_app/app_uninstalled_job_test.rb +5 -2
  316. data/test/jobs/disco_app/send_subscription_job_test.rb +3 -2
  317. data/test/jobs/disco_app/synchronise_carrier_service_job_test.rb +1 -0
  318. data/test/jobs/disco_app/synchronise_users_job_test.rb +27 -0
  319. data/test/jobs/disco_app/synchronise_webhooks_job_test.rb +78 -9
  320. data/test/models/disco_app/can_be_liquified_test.rb +3 -1
  321. data/test/models/disco_app/has_metafields_test.rb +109 -20
  322. data/test/models/disco_app/renders_assets_test.rb +2 -1
  323. data/test/models/disco_app/session_test.rb +2 -2
  324. data/test/models/disco_app/shop_test.rb +1 -1
  325. data/test/services/disco_app/charges_service_test.rb +10 -14
  326. data/test/services/disco_app/flow/create_action_test.rb +51 -0
  327. data/test/services/disco_app/flow/create_trigger_test.rb +56 -0
  328. data/test/services/disco_app/flow/process_action_test.rb +68 -0
  329. data/test/services/disco_app/flow/process_trigger_test.rb +94 -0
  330. data/test/services/disco_app/flow/update_trigger_usage_test.rb +87 -0
  331. data/test/services/disco_app/subscription_service_test.rb +3 -2
  332. data/test/services/disco_app/synchronise_resources_service_test.rb +57 -0
  333. data/test/support/test_file_fixtures.rb +2 -2
  334. data/test/support/test_shopify_api.rb +1 -1
  335. data/test/test_helper.rb +24 -6
  336. data/test/vcr/flow_trigger_invalid_title.yml +35 -0
  337. data/test/vcr/flow_trigger_valid.yml +38 -0
  338. data/test/vcr/synchronise_products.yml +130 -0
  339. data/test/vcr/synchronise_products_paginated.yml +119 -0
  340. data/test/vcr/synchronise_products_since_id.yml +125 -0
  341. data/test/vcr/synchronise_products_with_params.yml +130 -0
  342. data/test/vcr/webhook_failure.yml +640 -0
  343. metadata +388 -142
  344. data/app/clients/disco_app/disco_api_error.rb +0 -2
  345. data/lib/generators/disco_app/USAGE +0 -5
  346. data/lib/generators/disco_app/disco_app_generator.rb +0 -236
  347. data/lib/generators/disco_app/templates/config/newrelic.yml +0 -26
  348. data/lib/generators/disco_app/templates/initializers/rollbar.rb +0 -23
  349. data/lib/generators/disco_app/templates/initializers/session_store.rb +0 -2
  350. data/lib/generators/disco_app/templates/initializers/shopify_app.rb +0 -6
  351. data/test/dummy/config/database.gitlab-ci.yml +0 -24
  352. data/test/fixtures/api/widget_store/charges/get_accepted_application_charge_response.json +0 -16
  353. data/test/fixtures/api/widget_store/charges/get_accepted_recurring_application_charge_response.json +0 -20
  354. data/test/fixtures/api/widget_store/webhooks.json +0 -1
@@ -0,0 +1,12 @@
1
+ class CreateDiscoAppSources < ActiveRecord::Migration[5.1]
2
+
3
+ def change
4
+ create_table :disco_app_sources do |t|
5
+ t.string :source, null: true
6
+ t.string :name, null: true
7
+ t.timestamps null: false
8
+ end
9
+ add_index :disco_app_sources, :source
10
+ end
11
+
12
+ end
@@ -0,0 +1,16 @@
1
+ class AddSourcesToShopSubscriptions < ActiveRecord::Migration[5.1]
2
+
3
+ def change
4
+ add_column :disco_app_subscriptions, :source_id, :integer, limit: 8, index: true
5
+ add_foreign_key :disco_app_subscriptions, :disco_app_sources, column: :source_id
6
+
7
+ DiscoApp::Subscription.where.not(source: nil).find_each do |subscription|
8
+ DiscoApp::Source.find_or_create_by(source: subscription.source) do |new_source|
9
+ new_source.name = subscription.source
10
+ end
11
+ end
12
+
13
+ remove_column :disco_app_subscriptions, :source, :string
14
+ end
15
+
16
+ end
@@ -0,0 +1,14 @@
1
+ class CreateDiscoAppUsers < ActiveRecord::Migration[5.1]
2
+
3
+ def change
4
+ create_table :disco_app_users do |t|
5
+ t.integer :shop_id, limit: 8
6
+ t.string :first_name
7
+ t.string :last_name
8
+ t.string :email
9
+ t.timestamps null: false
10
+ end
11
+ add_index :disco_app_users, :shop_id, unique: true
12
+ end
13
+
14
+ end
@@ -0,0 +1,8 @@
1
+ class FixDiscoAppUsersIndex < ActiveRecord::Migration[5.1]
2
+
3
+ def change
4
+ remove_index :disco_app_users, :shop_id
5
+ add_index :disco_app_users, [:id, :shop_id], unique: true
6
+ end
7
+
8
+ end
@@ -0,0 +1,32 @@
1
+ class CreateFlowActionsAndTriggers < ActiveRecord::Migration[5.2]
2
+
3
+ def change
4
+ create_table :disco_app_flow_actions do |t|
5
+ t.integer :shop_id, limit: 8
6
+ t.string :action_id
7
+ t.string :action_run_id
8
+ t.jsonb :properties, default: {}
9
+ t.integer :status, default: 0
10
+ t.datetime :processed_at, null: true
11
+ t.jsonb :processing_errors, default: []
12
+ t.timestamps null: false
13
+ end
14
+
15
+ create_table :disco_app_flow_triggers do |t|
16
+ t.integer :shop_id, limit: 8
17
+ t.string :title
18
+ t.string :resource_name
19
+ t.string :resource_url
20
+ t.jsonb :properties, default: {}
21
+ t.integer :status, default: 0
22
+ t.datetime :processed_at, null: true
23
+ t.jsonb :processing_errors, default: []
24
+ t.timestamps null: false
25
+ end
26
+
27
+ add_foreign_key :disco_app_flow_actions, :disco_app_shops, column: :shop_id, on_delete: :cascade
28
+ add_foreign_key :disco_app_flow_triggers, :disco_app_shops, column: :shop_id, on_delete: :cascade
29
+ add_index :disco_app_flow_actions, :action_run_id, unique: true
30
+ end
31
+
32
+ end
@@ -0,0 +1,16 @@
1
+ class CreateFlowTriggerUsages < ActiveRecord::Migration[5.2]
2
+
3
+ def change
4
+ create_table :disco_app_flow_trigger_usages do |t|
5
+ t.integer :shop_id, limit: 8
6
+ t.string :flow_trigger_definition_id
7
+ t.boolean :has_enabled_flow, default: true
8
+ t.datetime :timestamp, null: true
9
+ t.timestamps null: false
10
+ end
11
+
12
+ add_foreign_key :disco_app_flow_trigger_usages, :disco_app_shops, column: :shop_id, on_delete: :cascade
13
+ add_index :disco_app_flow_trigger_usages, [:shop_id, :flow_trigger_definition_id], unique: true, name: :index_disco_app_flow_actions_on_shop_id_and_trigger_id
14
+ end
15
+
16
+ end
@@ -8,6 +8,13 @@ module DiscoApp
8
8
  # Set the list of Shopify webhook topics to register.
9
9
  attr_accessor :webhook_topics
10
10
 
11
+ # Define the list of fields to receive for each webhook topic.
12
+ attr_accessor :webhook_fields
13
+
14
+ # Set Flow configuration
15
+ attr_accessor :flow_actions
16
+ attr_accessor :flow_triggers
17
+
11
18
  # Set the below if using an application proxy.
12
19
  attr_accessor :app_proxy_prefix
13
20
 
@@ -16,17 +23,17 @@ module DiscoApp
16
23
 
17
24
  # Set the below to create real Shopify charges.
18
25
  attr_accessor :real_charges
19
- alias_method :real_charges?, :real_charges
26
+ alias real_charges? real_charges
20
27
 
21
28
  # Optional configuration, usually useful for development environments.
22
29
  attr_accessor :skip_proxy_verification
23
- alias_method :skip_proxy_verification?, :skip_proxy_verification
30
+ alias skip_proxy_verification? skip_proxy_verification
24
31
  attr_accessor :skip_webhook_verification
25
- alias_method :skip_webhook_verification?, :skip_webhook_verification
32
+ alias skip_webhook_verification? skip_webhook_verification
26
33
  attr_accessor :skip_carrier_request_verification
27
- alias_method :skip_carrier_request_verification?, :skip_carrier_request_verification
34
+ alias skip_carrier_request_verification? skip_carrier_request_verification
28
35
  attr_accessor :skip_oauth
29
- alias_method :skip_oauth?, :skip_oauth
36
+ alias skip_oauth? skip_oauth
30
37
 
31
38
  end
32
39
 
@@ -1,4 +1,6 @@
1
1
  module DiscoApp
2
- SOURCE_COOKIE_KEY = '_disco_app_source'
3
- CODE_COOKIE_KEY = '_disco_app_code'
2
+
3
+ SOURCE_COOKIE_KEY = '_disco_app_source'.freeze
4
+ CODE_COOKIE_KEY = '_disco_app_code'.freeze
5
+
4
6
  end
@@ -19,7 +19,7 @@ module DiscoApp
19
19
 
20
20
  # Ensure our frame assets are included for precompilation.
21
21
  initializer 'disco_app.assets.precompile' do |app|
22
- app.config.assets.precompile += %w(disco_app/icon.svg disco_app/admin.css disco_app/frame.css disco_app/frame.js)
22
+ app.config.assets.precompile += %w[disco_app/icon.svg disco_app/admin.css disco_app/frame.css disco_app/frame.js]
23
23
  end
24
24
 
25
25
  end
@@ -7,6 +7,7 @@ module DiscoApp
7
7
 
8
8
  def set_shop_id!
9
9
  return false unless loaded?
10
+
10
11
  write_attribute(:shop_id, data[:shopify] || data['shopify'])
11
12
  end
12
13
 
@@ -11,7 +11,8 @@ module DiscoApp::Test
11
11
  def json_fixture(path, dir: 'json', parse: true)
12
12
  filename = Rails.root.join('test', 'fixtures', dir, "#{path}.json")
13
13
  return File.read(filename) unless parse
14
- HashWithIndifferentAccess.new(ActiveSupport::JSON.decode(File.read(filename)))
14
+
15
+ HashWithIndifferentAccess.new(JSON.parse(File.read(filename)))
15
16
  end
16
17
 
17
18
  # Webhook fixtures are special-case JSON fixtures.
@@ -1,3 +1,5 @@
1
1
  module DiscoApp
2
- VERSION = '0.12.7-puma-3'
2
+
3
+ VERSION = '0.18.4'.freeze
4
+
3
5
  end
@@ -0,0 +1,5 @@
1
+ Description:
2
+ Generate a new Shopify application.
3
+
4
+ Example:
5
+ rails generate disco_app:install
@@ -0,0 +1,297 @@
1
+ module DiscoApp
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+
5
+ source_root File.expand_path('templates', __dir__)
6
+
7
+ # Copy a number of template files to the top-level directory of our application:
8
+ #
9
+ # - .env and .env.local for settings environment variables in development with dotenv-rails;
10
+ # - Slightly customised version of the default Rails .gitignore;
11
+ # - Default simple Procfile for Heroku;
12
+ # - .editorconfig to help enforce 2-space tabs, newlines and truncated whitespace for editors that support it.
13
+ # - README/PULL REQUEST template
14
+ #
15
+ def copy_root_files
16
+ %w[.editorconfig .env .env.local .gitignore .rubocop.yml Procfile CHECKS README.md].each do |file|
17
+ copy_file "root/#{file}", file
18
+ end
19
+ directory 'root/.github'
20
+ end
21
+
22
+ # Remove a number of root files.
23
+ def remove_root_files
24
+ %w[README.rdoc].each do |file|
25
+ remove_file file
26
+ end
27
+ end
28
+
29
+ # Configure the application's Gemfile.
30
+ def configure_gemfile
31
+ # Remove sqlite.
32
+ gsub_file 'Gemfile', /^# Use sqlite3 as the database for Active Record\ngem 'sqlite3', '~> 1.4'/m, ''
33
+
34
+ # Add gem requirements.
35
+ gem 'active_link_to'
36
+ gem 'activeresource'
37
+ gem 'acts_as_singleton'
38
+ gem 'appsignal'
39
+ gem 'classnames-rails'
40
+ gem 'nokogiri'
41
+ gem 'oj'
42
+ gem 'pg', '~> 1.1'
43
+ gem 'premailer-rails'
44
+ gem 'react-rails'
45
+ gem 'render_anywhere'
46
+ gem 'shopify_app'
47
+ gem 'sidekiq'
48
+ gem 'timber', '~> 3.0'
49
+
50
+ # Indicate which gems should only be used in production.
51
+ gem_group :staging, :production do
52
+ gem 'mailgun_rails'
53
+ gem 'rails_12factor'
54
+ end
55
+
56
+ # Indicate which gems should only be used in development.
57
+ gem_group :development do
58
+ gem 'rb-readline'
59
+ gem 'rubocop'
60
+ gem 'rubocop-performance'
61
+ gem 'rubocop-rails'
62
+ end
63
+
64
+ # Indicate which gems should only be used in development and test.
65
+ gem_group :development, :test do
66
+ gem 'coveralls'
67
+ gem 'dotenv-rails'
68
+ gem 'factory_bot_rails'
69
+ gem 'faker'
70
+ gem 'mechanize'
71
+ gem 'rspec-rails'
72
+ gem 'vcr'
73
+ gem 'webmock'
74
+ end
75
+
76
+ gem_group :test do
77
+ gem 'database_cleaner'
78
+ gem 'shoulda-matchers'
79
+ end
80
+ end
81
+
82
+ # copy template for pg configuration
83
+ def update_database_config
84
+ template 'config/database.yml.tt'
85
+ end
86
+
87
+ # Run bundle install to add our new gems before running tasks.
88
+ def bundle_install
89
+ Bundler.with_clean_env do
90
+ run 'bundle install'
91
+ end
92
+ end
93
+
94
+ def support_staging_environment
95
+ copy_file 'config/environments/staging.rb', 'config/environments/staging.rb'
96
+ end
97
+
98
+ # Make any required adjustments to the application configuration.
99
+ def configure_application
100
+ # The force_ssl flag is commented by default for production.
101
+ # Uncomment to ensure config.force_ssl = true in production.
102
+ uncomment_lines 'config/environments/production.rb', /force_ssl/
103
+
104
+ # Set time zone to UTC
105
+ application "config.time_zone = 'UTC'"
106
+ application '# Ensure UTC is the default timezone'
107
+
108
+ # Set server side rendereing for components.js
109
+ application <<~CONFIG
110
+ # Enable server side react rendering
111
+ config.react.server_renderer_options = {
112
+ # files to load for prerendering
113
+ files: ['components.js']
114
+ }
115
+ CONFIG
116
+
117
+ # Set defaults for various charge attributes.
118
+ application "config.x.shopify_charges_default_trial_days = 14\n"
119
+ application 'config.x.shopify_charges_default_price = 10.00'
120
+ application 'config.x.shopify_charges_default_type = :recurring'
121
+ application '# Set defaults for charges created by the application'
122
+
123
+ # Set the "real charges" config variable to false explicitly by default.
124
+ # Only in production do we read from the environment variable and
125
+ # potentially have it become true.
126
+ application "config.x.shopify_charges_real = false\n"
127
+ application '# Explicitly prevent real charges being created by default'
128
+ application "config.x.shopify_charges_real = ENV['SHOPIFY_CHARGES_REAL'] == 'true'\n", env: :production
129
+ application '# Allow real charges in production with an ENV variable', env: :production
130
+
131
+ # Configure session storage.
132
+ application "ActiveRecord::SessionStore::Session.table_name = 'disco_app_sessions'"
133
+ application 'ActionDispatch::Session::ActiveRecordStore.session_class = DiscoApp::Session'
134
+ application '# Configure custom session storage'
135
+
136
+ # Set Sidekiq as the queue adapter in production.
137
+ application "config.active_job.queue_adapter = :sidekiq\n", env: :production
138
+ application '# Use Sidekiq as the active job backend', env: :production
139
+
140
+ # Configure to delete X-Frame-Options so that embedded app works in iframe.
141
+ application "config.action_dispatch.default_headers.delete('X-Frame-Options')"
142
+ application '# Allow iframe requests'
143
+
144
+ # Set Sidekiq as the queue adapter in staging.
145
+ application "config.active_job.queue_adapter = :sidekiq\n", env: :staging
146
+ application '# Use Sidekiq as the active job backend', env: :staging
147
+
148
+ # Ensure the application configuration uses the DEFAULT_HOST environment
149
+ # variable to set up support for reverse routing absolute URLS (needed when
150
+ # generating Webhook URLs for example).
151
+ application "routes.default_url_options[:host] = ENV['DEFAULT_HOST']\n"
152
+ application '# Set the default host for absolute URL routing purposes'
153
+
154
+ # Configure React in development, staging and production.
155
+ application 'config.react.variant = :development', env: :development
156
+ application '# Use development variant of React in development.', env: :development
157
+ application 'config.react.variant = :production', env: :staging
158
+ application '# Use production variant of React in staging.', env: :staging
159
+ application 'config.react.variant = :production', env: :production
160
+ application '# Use production variant of React in production.', env: :production
161
+
162
+ # Configure ActionDispatch::HostAuthorization to be disabled
163
+ application 'config.hosts.clear', env: :development
164
+ application '# Disable Host Authorization middleware', env: :development
165
+
166
+ # Configure Factory Bot as the Rails testing fixture replacement
167
+ application <<~CONFIG
168
+ config.generators do |g|
169
+ g.test_framework :rspec, fixtures: true, view_specs: false, helper_specs: false, routing_specs: false
170
+ g.fixture_replacement :factory_bot, dir: 'spec/factories'
171
+ end
172
+ CONFIG
173
+
174
+ # Copy over the default puma configuration.
175
+ copy_file 'config/puma.rb', 'config/puma.rb'
176
+
177
+ # Mail configuration
178
+ configuration = <<-CONFIG.strip_heredoc
179
+
180
+ # Configure ActionMailer to use MailGun
181
+ if ENV['MAILGUN_API_KEY']
182
+ config.action_mailer.delivery_method = :mailgun
183
+ config.action_mailer.mailgun_settings = {
184
+ api_key: ENV['MAILGUN_API_KEY'],
185
+ domain: ENV['MAILGUN_API_DOMAIN']
186
+ }
187
+ end
188
+ CONFIG
189
+ application configuration, env: :production
190
+ application configuration, env: :staging
191
+
192
+ # Monitoring configuration
193
+ copy_file 'config/appsignal.yml', 'config/appsignal.yml'
194
+ end
195
+
196
+ # Add entries to .env and .env.local
197
+ def add_env_variables
198
+ configuration = <<-CONFIG.strip_heredoc
199
+
200
+ MAILGUN_API_KEY=
201
+ MAILGUN_API_DOMAIN=
202
+ CONFIG
203
+ append_to_file '.env', configuration
204
+ append_to_file '.env.local', configuration
205
+ end
206
+
207
+ # Set up routes.
208
+ def setup_routes
209
+ route "mount DiscoApp::Engine, at: '/'"
210
+ end
211
+
212
+ # Run generators.
213
+ def run_generators
214
+ generate 'shopify_app:install'
215
+ generate 'shopify_app:home_controller'
216
+ rails_command 'webpacker:install'
217
+ generate 'react:install'
218
+ end
219
+
220
+ def configure_rspec
221
+ directory 'spec'
222
+ copy_file 'root/.rspec', '.rspec'
223
+ end
224
+
225
+ # Copy template files to the appropriate location. In some cases, we'll be
226
+ # overwriting or removing existing files or those created by ShopifyApp.
227
+ def copy_and_remove_files
228
+ # Copy initializers
229
+ copy_file 'initializers/shopify_app.rb', 'config/initializers/shopify_app.rb'
230
+ copy_file 'initializers/disco_app.rb', 'config/initializers/disco_app.rb'
231
+ copy_file 'initializers/shopify_session_repository.rb', 'config/initializers/shopify_session_repository.rb'
232
+ copy_file 'initializers/session_store.rb', 'config/initializers/session_store.rb'
233
+ copy_file 'initializers/timber.rb', 'config/initializers/timber.rb'
234
+
235
+ # Copy default home controller and view
236
+ copy_file 'controllers/home_controller.rb', 'app/controllers/home_controller.rb'
237
+ copy_file 'views/home/index.html.erb', 'app/views/home/index.html.erb'
238
+
239
+ # Copy assets
240
+ copy_file 'assets/stylesheets/application.scss', 'app/assets/stylesheets/application.scss'
241
+
242
+ # Remove application.css
243
+ remove_file 'app/assets/stylesheets/application.css'
244
+
245
+ # Remove the layout files created by ShopifyApp
246
+ remove_file 'app/views/layouts/application.html.erb'
247
+ remove_file 'app/views/layouts/embedded_app.html.erb'
248
+
249
+ # Remove the test directory generated by rails new
250
+ remove_dir 'test'
251
+ end
252
+
253
+ # Copy engine migrations over.
254
+ def install_migrations
255
+ rake 'disco_app:install:migrations'
256
+ end
257
+
258
+ # Create PG database
259
+ def create_database
260
+ rake 'db:create'
261
+ end
262
+
263
+ # Run migrations.
264
+ def migrate
265
+ rake 'db:migrate'
266
+ end
267
+
268
+ # Copy package.json.
269
+ def configure_package
270
+ template 'root/package.json.tt', 'package.json'
271
+ end
272
+
273
+ def yarn_install
274
+ run 'yarn install'
275
+ end
276
+
277
+ # Lock down the application to a specific Ruby version:
278
+ #
279
+ # - Via .tool-versions file for asdf in development;
280
+ #
281
+ # This should be the last operation, to allow all other operations to run in the initial Ruby version.
282
+ def set_ruby_version
283
+ copy_file 'root/.tool-versions', '.tool-versions'
284
+ end
285
+
286
+ private
287
+
288
+ # This method of finding the component.js manifest taken from the
289
+ # install generator in react-rails.
290
+ # See https://github.com/reactjs/react-rails/blob/3f0af13fa755d6e95969c17728d0354c234f3a37/lib/generators/react/install_generator.rb#L53-L55
291
+ def components
292
+ Pathname.new(destination_root).join('app/assets/javascripts', 'components.js')
293
+ end
294
+
295
+ end
296
+ end
297
+ end
@@ -0,0 +1,12 @@
1
+ default: &defaults
2
+ name: <%= ENV['SHOPIFY_APP_NAME'] || 'Unknown App' %>
3
+ push_api_key: <%= ENV['APPSIGNAL_PUSH_API_KEY'] %>
4
+ development:
5
+ <<: *defaults
6
+ active: false
7
+ staging:
8
+ <<: *defaults
9
+ active: true
10
+ production:
11
+ <<: *defaults
12
+ active: true
@@ -0,0 +1,11 @@
1
+ development:
2
+ adapter: async
3
+
4
+ test:
5
+ adapter: async
6
+
7
+ staging:
8
+ adapter: async
9
+
10
+ production:
11
+ adapter: async
@@ -3,18 +3,22 @@ default: &default
3
3
  encoding: unicode
4
4
  pool: 5
5
5
  timeout: 5000
6
-
6
+ prepared_statements: false
7
+
7
8
  development:
8
9
  <<: *default
9
10
  host: localhost
10
11
  port: 5432
11
12
  database: <%= Rails.application.class.parent_name.downcase %>
12
-
13
+
13
14
  test:
14
15
  <<: *default
15
16
  host: localhost
16
17
  port: 5432
17
18
  database: <%= Rails.application.class.parent_name.downcase %>_test
18
-
19
+
20
+ staging:
21
+ <<: *default
22
+
19
23
  production:
20
24
  <<: *default
@@ -0,0 +1,108 @@
1
+ Rails.application.configure do
2
+ # Configure ActionMailer to use MailGun
3
+ if ENV['MAILGUN_API_KEY']
4
+ config.action_mailer.delivery_method = :mailgun
5
+ config.action_mailer.mailgun_settings = {
6
+ api_key: ENV['MAILGUN_API_KEY'],
7
+ domain: ENV['MAILGUN_API_DOMAIN']
8
+ }
9
+ end
10
+
11
+ # Use production variant of React in staging.
12
+ config.react.variant = :production
13
+ # Use Sidekiq as the active job backend
14
+ config.active_job.queue_adapter = :sidekiq
15
+
16
+ # Allow real charges in production with an ENV variable
17
+ config.x.shopify_charges_real = false
18
+
19
+ # Settings specified here will take precedence over those in config/application.rb.
20
+
21
+ # Code is not reloaded between requests.
22
+ config.cache_classes = true
23
+
24
+ # Eager load code on boot. This eager loads most of Rails and
25
+ # your application in memory, allowing both threaded web servers
26
+ # and those relying on copy on write to perform better.
27
+ # Rake tasks automatically ignore this option for performance.
28
+ config.eager_load = true
29
+
30
+ # Full error reports are disabled and caching is turned on.
31
+ config.consider_all_requests_local = false
32
+ config.action_controller.perform_caching = true
33
+
34
+ # Attempt to read encrypted secrets from `config/secrets.yml.enc`.
35
+ # Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or
36
+ # `config/secrets.yml.key`.
37
+ config.read_encrypted_secrets = true
38
+
39
+ # Disable serving static files from the `/public` folder by default since
40
+ # Apache or NGINX already handles this.
41
+ config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
42
+
43
+ # Compress JavaScripts and CSS.
44
+ config.assets.js_compressor = :uglifier
45
+ # config.assets.css_compressor = :sass
46
+
47
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
48
+ config.assets.compile = false
49
+
50
+ # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
51
+
52
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
53
+ # config.action_controller.asset_host = 'http://assets.example.com'
54
+
55
+ # Specifies the header that your server uses for sending files.
56
+ # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
57
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
58
+
59
+ # Mount Action Cable outside main process or domain
60
+ # config.action_cable.mount_path = nil
61
+ # config.action_cable.url = 'wss://example.com/cable'
62
+ # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
63
+
64
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
65
+ config.force_ssl = true
66
+
67
+ # Use the lowest log level to ensure availability of diagnostic information
68
+ # when problems arise.
69
+ config.log_level = :debug
70
+
71
+ # Prepend all log lines with the following tags.
72
+ config.log_tags = [:request_id]
73
+
74
+ # Use a different cache store in staging.
75
+ # config.cache_store = :mem_cache_store
76
+
77
+ # Use a real queuing backend for Active Job (and separate queues per environment)
78
+ # config.active_job.queue_adapter = :resque
79
+ # config.active_job.queue_name_prefix = "example_app_#{Rails.env}"
80
+ config.action_mailer.perform_caching = false
81
+
82
+ # Ignore bad email addresses and do not raise email delivery errors.
83
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
84
+ # config.action_mailer.raise_delivery_errors = false
85
+
86
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
87
+ # the I18n.default_locale when a translation cannot be found).
88
+ config.i18n.fallbacks = true
89
+
90
+ # Send deprecation notices to registered listeners.
91
+ config.active_support.deprecation = :notify
92
+
93
+ # Use default logging formatter so that PID and timestamp are not suppressed.
94
+ config.log_formatter = ::Logger::Formatter.new
95
+
96
+ # Use a different logger for distributed setups.
97
+ # require 'syslog/logger'
98
+ # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
99
+
100
+ if ENV['RAILS_LOG_TO_STDOUT'].present?
101
+ logger = ActiveSupport::Logger.new(STDOUT)
102
+ logger.formatter = config.log_formatter
103
+ config.logger = ActiveSupport::TaggedLogging.new(logger)
104
+ end
105
+
106
+ # Do not dump schema after migrations.
107
+ config.active_record.dump_schema_after_migration = false
108
+ end
@@ -1,4 +1,5 @@
1
1
  class HomeController < ApplicationController
2
+
2
3
  include DiscoApp::Concerns::AuthenticatedController
3
4
 
4
5
  def index