disco_app 0.15.2 → 0.18.1
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/Rakefile +1 -5
- data/app/clients/disco_app/api_client.rb +25 -19
- data/app/clients/disco_app/graphql_client.rb +85 -0
- data/app/controllers/disco_app/admin/app_settings_controller.rb +2 -0
- data/app/controllers/disco_app/admin/application_controller.rb +1 -0
- data/app/controllers/disco_app/admin/concerns/app_settings_controller.rb +2 -1
- data/app/controllers/disco_app/admin/concerns/authenticated_controller.rb +5 -3
- data/app/controllers/disco_app/admin/concerns/plans_controller.rb +3 -2
- data/app/controllers/disco_app/admin/concerns/shops_controller.rb +1 -0
- data/app/controllers/disco_app/admin/concerns/sources_controller.rb +2 -1
- data/app/controllers/disco_app/admin/concerns/subscriptions_controller.rb +3 -2
- data/app/controllers/disco_app/admin/plans_controller.rb +2 -0
- data/app/controllers/disco_app/admin/resources/shops_controller.rb +2 -0
- data/app/controllers/disco_app/admin/shops_controller.rb +2 -0
- data/app/controllers/disco_app/admin/sources_controller.rb +2 -0
- data/app/controllers/disco_app/admin/subscriptions_controller.rb +2 -0
- data/app/controllers/disco_app/charges_controller.rb +6 -7
- data/app/controllers/disco_app/concerns/app_proxy_controller.rb +6 -6
- data/app/controllers/disco_app/concerns/authenticated_controller.rb +26 -27
- data/app/controllers/disco_app/concerns/carrier_request_controller.rb +22 -11
- data/app/controllers/disco_app/concerns/user_authenticated_controller.rb +1 -0
- data/app/controllers/disco_app/concerns/webhooks_controller.rb +13 -12
- data/app/controllers/disco_app/flow/actions_controller.rb +9 -0
- data/app/controllers/disco_app/flow/concerns/actions_controller.rb +23 -0
- data/app/controllers/disco_app/flow/concerns/trigger_usage_controller.rb +29 -0
- data/app/controllers/disco_app/flow/concerns/verifies_flow_payload.rb +39 -0
- data/app/controllers/disco_app/flow/trigger_usage_controller.rb +9 -0
- data/app/controllers/disco_app/frame_controller.rb +0 -1
- data/app/controllers/disco_app/install_controller.rb +3 -6
- data/app/controllers/disco_app/subscriptions_controller.rb +12 -4
- data/app/controllers/disco_app/user_sessions_controller.rb +1 -0
- data/app/controllers/disco_app/webhooks_controller.rb +2 -0
- data/app/controllers/sessions_controller.rb +5 -6
- data/app/helpers/disco_app/application_helper.rb +7 -7
- data/app/jobs/disco_app/app_installed_job.rb +2 -0
- data/app/jobs/disco_app/app_uninstalled_job.rb +2 -0
- data/app/jobs/disco_app/concerns/app_installed_job.rb +2 -3
- data/app/jobs/disco_app/concerns/app_uninstalled_job.rb +2 -1
- data/app/jobs/disco_app/concerns/customers_data_request_job.rb +13 -0
- data/app/jobs/disco_app/concerns/customers_redact_job.rb +13 -0
- data/app/jobs/disco_app/concerns/render_asset_group_job.rb +1 -0
- data/app/jobs/disco_app/concerns/shop_redact_job.rb +13 -0
- data/app/jobs/disco_app/concerns/shop_update_job.rb +9 -2
- data/app/jobs/disco_app/concerns/subscription_changed_job.rb +2 -1
- data/app/jobs/disco_app/concerns/synchronise_carrier_service_job.rb +8 -7
- data/app/jobs/disco_app/concerns/synchronise_resources_job.rb +1 -0
- data/app/jobs/disco_app/concerns/synchronise_users_job.rb +6 -3
- data/app/jobs/disco_app/concerns/synchronise_webhooks_job.rb +24 -11
- data/app/jobs/disco_app/customers_data_request_job.rb +5 -0
- data/app/jobs/disco_app/customers_redact_job.rb +5 -0
- data/app/jobs/disco_app/flow/process_action_job.rb +11 -0
- data/app/jobs/disco_app/flow/process_trigger_job.rb +11 -0
- data/app/jobs/disco_app/render_asset_group_job.rb +2 -0
- data/app/jobs/disco_app/shop_job.rb +10 -10
- data/app/jobs/disco_app/shop_redact_job.rb +5 -0
- data/app/jobs/disco_app/shop_update_job.rb +2 -0
- data/app/jobs/disco_app/subscription_changed_job.rb +2 -0
- data/app/jobs/disco_app/synchronise_carrier_service_job.rb +2 -0
- data/app/jobs/disco_app/synchronise_resources_job.rb +2 -0
- data/app/jobs/disco_app/synchronise_users_job.rb +2 -0
- data/app/jobs/disco_app/synchronise_webhooks_job.rb +2 -0
- data/app/models/application_record.rb +2 -0
- data/app/models/disco_app/app_settings.rb +2 -0
- data/app/models/disco_app/application_charge.rb +1 -1
- data/app/models/disco_app/concerns/app_settings.rb +2 -0
- data/app/models/disco_app/concerns/can_be_liquified.rb +29 -14
- data/app/models/disco_app/concerns/has_metafields.rb +1 -2
- data/app/models/disco_app/concerns/plan.rb +3 -4
- data/app/models/disco_app/concerns/plan_code.rb +1 -2
- data/app/models/disco_app/concerns/renders_assets.rb +15 -21
- data/app/models/disco_app/concerns/shop.rb +20 -14
- data/app/models/disco_app/concerns/source.rb +2 -3
- data/app/models/disco_app/concerns/subscription.rb +3 -3
- data/app/models/disco_app/concerns/synchronises.rb +10 -15
- data/app/models/disco_app/concerns/taggable.rb +1 -0
- data/app/models/disco_app/concerns/user.rb +3 -2
- data/app/models/disco_app/flow/action.rb +9 -0
- data/app/models/disco_app/flow/concerns/action.rb +27 -0
- data/app/models/disco_app/flow/concerns/trigger.rb +28 -0
- data/app/models/disco_app/flow/concerns/trigger_usage.rb +17 -0
- data/app/models/disco_app/flow/trigger.rb +9 -0
- data/app/models/disco_app/flow/trigger_usage.rb +9 -0
- data/app/models/disco_app/plan.rb +2 -0
- data/app/models/disco_app/plan_code.rb +2 -0
- data/app/models/disco_app/session_storage.rb +5 -2
- data/app/models/disco_app/shop.rb +2 -0
- data/app/models/disco_app/source.rb +2 -0
- data/app/models/disco_app/subscription.rb +2 -0
- data/app/models/disco_app/user.rb +2 -0
- data/app/resources/disco_app/admin/resources/concerns/shop_resource.rb +12 -15
- data/app/resources/disco_app/admin/resources/shop_resource.rb +1 -0
- data/app/services/disco_app/carrier_request_service.rb +3 -3
- data/app/services/disco_app/charges_service.rb +26 -34
- data/app/services/disco_app/flow/create_action.rb +35 -0
- data/app/services/disco_app/flow/create_trigger.rb +34 -0
- data/app/services/disco_app/flow/process_action.rb +50 -0
- data/app/services/disco_app/flow/process_trigger.rb +72 -0
- data/app/services/disco_app/flow/update_trigger_usage.rb +42 -0
- data/app/services/disco_app/partner_app_service.rb +1 -1
- data/app/services/disco_app/proxy_service.rb +2 -2
- data/app/services/disco_app/request_validation_service.rb +2 -2
- data/app/services/disco_app/subscription_service.rb +60 -32
- data/app/services/disco_app/webhook_service.rb +9 -11
- data/app/views/layouts/admin.html.erb +1 -2
- data/app/views/layouts/application.html.erb +1 -2
- data/app/views/layouts/embedded_app.html.erb +2 -4
- data/app/views/layouts/embedded_app_modal.html.erb +2 -3
- data/app/views/shopify_app/sessions/new.html.erb +2 -4
- data/config/routes.rb +11 -3
- data/db/migrate/20150525000000_create_shops_if_not_existent.rb +80 -80
- data/db/migrate/20170315062548_create_disco_app_sources.rb +2 -0
- data/db/migrate/20170315062629_add_sources_to_shop_subscriptions.rb +3 -1
- data/db/migrate/20170327214540_create_disco_app_users.rb +2 -1
- data/db/migrate/20170606160751_fix_disco_app_users_index.rb +2 -0
- data/db/migrate/20181229100327_create_flow_actions_and_triggers.rb +32 -0
- data/db/migrate/20200405000000_create_flow_trigger_usages.rb +16 -0
- data/lib/disco_app/configuration.rb +12 -5
- data/lib/disco_app/constants.rb +4 -2
- data/lib/disco_app/engine.rb +1 -1
- data/lib/disco_app/session.rb +1 -0
- data/lib/disco_app/support/file_fixtures.rb +2 -1
- data/lib/disco_app/version.rb +3 -1
- data/lib/generators/disco_app/install/USAGE +5 -0
- data/lib/generators/disco_app/install/install_generator.rb +297 -0
- data/lib/generators/disco_app/{templates → install/templates}/assets/javascripts/application.js +0 -0
- data/lib/generators/disco_app/{templates → install/templates}/assets/javascripts/components.js +0 -0
- data/lib/generators/disco_app/{templates → install/templates}/assets/stylesheets/application.scss +0 -0
- data/lib/generators/disco_app/install/templates/config/appsignal.yml +12 -0
- data/lib/generators/disco_app/install/templates/config/cable.yml.tt +11 -0
- data/lib/generators/disco_app/{templates → install/templates}/config/database.yml.tt +6 -3
- data/lib/generators/disco_app/install/templates/config/environments/staging.rb +108 -0
- data/lib/generators/disco_app/{templates → install/templates}/config/puma.rb +0 -0
- data/lib/generators/disco_app/{templates → install/templates}/controllers/home_controller.rb +1 -0
- data/lib/generators/disco_app/{templates → install/templates}/initializers/disco_app.rb +5 -0
- data/lib/generators/disco_app/install/templates/initializers/session_store.rb +2 -0
- data/lib/generators/disco_app/install/templates/initializers/shopify_app.rb +11 -0
- data/lib/generators/disco_app/{templates → install/templates}/initializers/shopify_session_repository.rb +0 -0
- data/lib/generators/disco_app/install/templates/initializers/timber.rb +4 -0
- data/lib/generators/disco_app/{templates → install/templates}/root/.editorconfig +0 -0
- data/lib/generators/disco_app/{templates → install/templates}/root/.env +7 -0
- data/lib/generators/disco_app/{templates → install/templates}/root/.env.local +4 -0
- data/lib/generators/disco_app/{templates → install/templates}/root/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- data/lib/generators/disco_app/{templates → install/templates}/root/.gitignore +6 -0
- data/lib/generators/disco_app/install/templates/root/.rspec +1 -0
- data/lib/generators/disco_app/{templates → install/templates}/root/.rubocop.yml +315 -217
- data/lib/generators/disco_app/install/templates/root/.tool-versions +2 -0
- data/lib/generators/disco_app/{templates → install/templates}/root/CHECKS +0 -0
- data/lib/generators/disco_app/{templates → install/templates}/root/Procfile +0 -0
- data/lib/generators/disco_app/{templates → install/templates}/root/README.md +0 -0
- data/lib/generators/disco_app/install/templates/root/package.json.tt +17 -0
- data/lib/generators/disco_app/install/templates/spec/rails_helper.rb +40 -0
- data/lib/generators/disco_app/install/templates/spec/spec_helper.rb +24 -0
- data/lib/generators/disco_app/install/templates/spec/support/active_job.rb +13 -0
- data/lib/generators/disco_app/install/templates/spec/support/coveralls.rb +3 -0
- data/lib/generators/disco_app/install/templates/spec/support/database_cleaner.rb +17 -0
- data/lib/generators/disco_app/install/templates/spec/support/factory_bot.rb +3 -0
- data/lib/generators/disco_app/install/templates/spec/support/helpers/json_helper.rb +13 -0
- data/lib/generators/disco_app/install/templates/spec/support/shared_examples/a_synchronise_job.rb +12 -0
- data/lib/generators/disco_app/install/templates/spec/support/shoulda.rb +6 -0
- data/lib/generators/disco_app/install/templates/spec/support/vcr.rb +14 -0
- data/lib/generators/disco_app/install/templates/spec/support/webmock.rb +8 -0
- data/lib/generators/disco_app/{templates → install/templates}/views/home/index.html.erb +0 -0
- data/lib/generators/disco_app/react/USAGE +5 -0
- data/lib/generators/disco_app/react/react_generator.rb +108 -0
- data/lib/generators/disco_app/react/templates/app/controllers/embedded/api/base_controller.rb +18 -0
- data/lib/generators/disco_app/react/templates/app/controllers/embedded/api/home_controller.rb +10 -0
- data/lib/generators/disco_app/react/templates/app/controllers/embedded/api/shops_controller.rb +11 -0
- data/lib/generators/disco_app/react/templates/app/controllers/embedded/api/users_controller.rb +11 -0
- data/lib/generators/disco_app/react/templates/app/controllers/embedded/home_controller.rb +13 -0
- data/lib/generators/disco_app/react/templates/app/models/api_response.rb +107 -0
- data/lib/generators/disco_app/react/templates/app/serializers/disco_app/shop_serializer.rb +13 -0
- data/lib/generators/disco_app/react/templates/app/serializers/disco_app/user_serializer.rb +13 -0
- data/lib/generators/disco_app/react/templates/app/serializers/empty_serializer.rb +5 -0
- data/lib/generators/disco_app/react/templates/app/serializers/error_serializer.rb +76 -0
- data/lib/generators/disco_app/react/templates/app/views/embedded/home/index.html.erb +12 -0
- data/lib/generators/disco_app/react/templates/app/views/layouts/embedded.html.erb +10 -0
- data/lib/generators/disco_app/react/templates/app/webpack/javascripts/embedded/components/App.jsx +77 -0
- data/lib/generators/disco_app/react/templates/app/webpack/javascripts/embedded/components/HomePage.jsx +34 -0
- data/lib/generators/disco_app/react/templates/app/webpack/javascripts/embedded/components/Shared/EmbeddedPage.jsx +70 -0
- data/lib/generators/disco_app/react/templates/app/webpack/javascripts/embedded/components/Shared/ErrorBanner.jsx +58 -0
- data/lib/generators/disco_app/react/templates/app/webpack/javascripts/embedded/components/Shared/PaginationWrapper.jsx +10 -0
- data/lib/generators/disco_app/react/templates/app/webpack/javascripts/embedded/components/Shared/ScrollToTop.jsx +23 -0
- data/lib/generators/disco_app/react/templates/app/webpack/javascripts/embedded/components/withApi.jsx +125 -0
- data/lib/generators/disco_app/react/templates/app/webpack/javascripts/embedded/index.jsx +39 -0
- data/lib/generators/disco_app/react/templates/app/webpack/javascripts/embedded/utils.js +19 -0
- data/lib/generators/disco_app/react/templates/app/webpack/packs/embedded.js +2 -0
- data/lib/generators/disco_app/react/templates/app/webpack/stylesheets/embedded/shared/banners.scss +7 -0
- data/lib/generators/disco_app/react/templates/app/webpack/stylesheets/embedded/shared/busy.scss +3 -0
- data/lib/generators/disco_app/react/templates/app/webpack/stylesheets/embedded/shared/index.scss +3 -0
- data/lib/generators/disco_app/react/templates/app/webpack/stylesheets/embedded/shared/pagination.scss +5 -0
- data/lib/generators/disco_app/react/templates/app/webpack/stylesheets/embedded.scss +2 -0
- data/lib/generators/disco_app/react/templates/config/initializers/mime_types.rb +13 -0
- data/lib/generators/disco_app/react/templates/config/initializers/omniauth.rb +27 -0
- data/lib/generators/disco_app/react/templates/config/initializers/version.rb.tt +7 -0
- data/lib/generators/disco_app/react/templates/config/webpack/staging.js +5 -0
- data/lib/generators/disco_app/react/templates/config/webpack/test.js +5 -0
- data/lib/generators/disco_app/react/templates/config/webpacker.yml +96 -0
- data/lib/generators/disco_app/react/templates/root/.eslintignore +5 -0
- data/lib/generators/disco_app/react/templates/root/.eslintrc +69 -0
- data/lib/generators/disco_app/react/templates/root/.prettierrc +3 -0
- data/lib/generators/disco_app/react/templates/root/VERSION +1 -0
- data/lib/generators/disco_app/react/templates/root/babel.config.js +72 -0
- data/lib/generators/disco_app/react/templates/root/package.json.tt +84 -0
- data/lib/generators/disco_app/react/templates/root/postcss.config.js +14 -0
- data/lib/tasks/api.rake +0 -2
- data/lib/tasks/carrier_service.rake +0 -2
- data/lib/tasks/database.rake +1 -1
- data/lib/tasks/sessions.rake +0 -2
- data/lib/tasks/shops.rake +0 -2
- data/lib/tasks/users.rake +0 -2
- data/lib/tasks/webhooks.rake +0 -2
- data/test/clients/disco_app/api_client_test.rb +3 -3
- data/test/controllers/disco_app/admin/shops_controller_test.rb +1 -0
- data/test/controllers/disco_app/charges_controller_test.rb +8 -9
- data/test/controllers/disco_app/flow/trigger_usage_controller_test.rb +41 -0
- data/test/controllers/disco_app/install_controller_test.rb +2 -1
- data/test/controllers/disco_app/subscriptions_controller_test.rb +2 -1
- data/test/controllers/disco_app/webhooks_controller_test.rb +1 -0
- data/test/controllers/home_controller_test.rb +1 -1
- data/test/disco_app_test.rb +3 -1
- data/test/dummy/Rakefile +1 -1
- data/test/dummy/app/assets/config/manifest.js +2 -0
- data/test/dummy/app/controllers/application_controller.rb +2 -0
- data/test/dummy/app/controllers/carrier_request_controller.rb +1 -0
- data/test/dummy/app/controllers/disco_app/admin/shops_controller.rb +1 -0
- data/test/dummy/app/controllers/home_controller.rb +1 -0
- data/test/dummy/app/controllers/proxy_controller.rb +1 -0
- data/test/dummy/app/javascript/packs/application.js +18 -0
- data/test/dummy/app/jobs/disco_app/app_installed_job.rb +2 -3
- data/test/dummy/app/jobs/disco_app/app_uninstalled_job.rb +1 -0
- data/test/dummy/app/models/application_record.rb +2 -0
- data/test/dummy/app/models/cart.rb +4 -3
- data/test/dummy/app/models/disco_app/shop.rb +4 -5
- data/test/dummy/app/models/js_configuration.rb +1 -0
- data/test/dummy/app/models/product.rb +3 -2
- data/test/dummy/app/models/widget_configuration.rb +1 -0
- data/test/dummy/babel.config.js +72 -0
- data/test/dummy/bin/bundle +1 -1
- data/test/dummy/bin/rails +1 -1
- data/test/dummy/bin/setup +8 -8
- data/test/dummy/bin/webpack +19 -0
- data/test/dummy/bin/webpack-dev-server +19 -0
- data/test/dummy/config/application.rb +4 -3
- data/test/dummy/config/boot.rb +2 -2
- data/test/dummy/config/database.yml +3 -0
- data/test/dummy/config/environment.rb +1 -1
- data/test/dummy/config/environments/staging.rb +85 -0
- data/test/dummy/config/initializers/disco_app.rb +8 -1
- data/test/dummy/config/initializers/omniauth.rb +3 -4
- data/test/dummy/config/initializers/session_store.rb +1 -1
- data/test/dummy/config/initializers/shopify_app.rb +1 -0
- data/test/dummy/config/routes.rb +0 -2
- data/test/dummy/config/secrets.yml +3 -0
- data/test/dummy/config/webpack/development.js +5 -0
- data/test/dummy/config/webpack/environment.js +3 -0
- data/test/dummy/config/webpack/production.js +5 -0
- data/test/dummy/config/webpack/test.js +5 -0
- data/test/dummy/config/webpacker.yml +95 -0
- data/test/dummy/db/migrate/20160307182229_create_products.rb +3 -1
- data/test/dummy/db/migrate/20160530160739_create_asset_models.rb +3 -1
- data/test/dummy/db/migrate/20161105054746_create_carts.rb +2 -1
- data/test/dummy/db/schema.rb +45 -6
- data/test/dummy/package.json +8 -0
- data/test/dummy/postcss.config.js +12 -0
- data/test/dummy/yarn.lock +7244 -0
- data/test/fixtures/api/subscriptions/valid_request.json +1 -1
- data/test/fixtures/api/widget_store/empty_webhooks.json +3 -0
- data/test/fixtures/api/widget_store/existing_webhooks.json +43 -0
- data/test/fixtures/disco_app/shops.yml +3 -0
- data/test/fixtures/webhooks/flow/trigger_usage.json +7 -0
- data/test/integration/synchronises_test.rb +2 -1
- data/test/jobs/disco_app/app_installed_job_test.rb +28 -9
- data/test/jobs/disco_app/app_uninstalled_job_test.rb +5 -2
- data/test/jobs/disco_app/send_subscription_job_test.rb +3 -2
- data/test/jobs/disco_app/synchronise_carrier_service_job_test.rb +1 -0
- data/test/jobs/disco_app/synchronise_users_job_test.rb +1 -0
- data/test/jobs/disco_app/synchronise_webhooks_job_test.rb +70 -13
- data/test/models/disco_app/can_be_liquified_test.rb +3 -1
- data/test/models/disco_app/has_metafields_test.rb +37 -18
- data/test/models/disco_app/renders_assets_test.rb +2 -1
- data/test/models/disco_app/session_test.rb +2 -2
- data/test/models/disco_app/shop_test.rb +1 -1
- data/test/services/disco_app/charges_service_test.rb +7 -8
- data/test/services/disco_app/flow/create_action_test.rb +51 -0
- data/test/services/disco_app/flow/create_trigger_test.rb +56 -0
- data/test/services/disco_app/flow/process_action_test.rb +68 -0
- data/test/services/disco_app/flow/process_trigger_test.rb +94 -0
- data/test/services/disco_app/flow/update_trigger_usage_test.rb +87 -0
- data/test/services/disco_app/subscription_service_test.rb +3 -2
- data/test/support/test_file_fixtures.rb +2 -2
- data/test/support/test_shopify_api.rb +1 -1
- data/test/test_helper.rb +10 -7
- data/test/vcr/flow_trigger_invalid_title.yml +35 -0
- data/test/vcr/flow_trigger_valid.yml +38 -0
- data/test/vcr/webhook_failure.yml +13 -13
- metadata +282 -148
- data/app/clients/disco_app/disco_api_error.rb +0 -2
- data/app/clients/disco_app/rollbar_client.rb +0 -53
- data/app/clients/disco_app/rollbar_client_error.rb +0 -2
- data/lib/generators/disco_app/USAGE +0 -5
- data/lib/generators/disco_app/disco_app_generator.rb +0 -236
- data/lib/generators/disco_app/templates/config/newrelic.yml +0 -26
- data/lib/generators/disco_app/templates/initializers/rollbar.rb +0 -23
- data/lib/generators/disco_app/templates/initializers/session_store.rb +0 -2
- data/lib/generators/disco_app/templates/initializers/shopify_app.rb +0 -6
- data/lib/generators/disco_app/templates/root/.codeclimate.yml +0 -7
- data/lib/generators/disco_app/templates/root/.ruby-version +0 -1
- data/lib/tasks/rollbar.rake +0 -24
- data/test/fixtures/api/widget_store/webhooks.json +0 -1
@@ -9,7 +9,7 @@
|
|
9
9
|
"domain": null,
|
10
10
|
"plan_name": null,
|
11
11
|
"name": null,
|
12
|
-
"data": {"timezone": "(GMT+10:00) Melbourne", "country_name": "Australia"}
|
12
|
+
"data": {"timezone": "(GMT+10:00) Melbourne", "country_name": "Australia", "iana_timezone": "Australia/Melbourne"}
|
13
13
|
},
|
14
14
|
"subscription": {
|
15
15
|
"id": 304261385,
|
@@ -0,0 +1,43 @@
|
|
1
|
+
{
|
2
|
+
"webhooks": [
|
3
|
+
{
|
4
|
+
"id": 748073353265,
|
5
|
+
"address": "https://test.example.com/webhooks",
|
6
|
+
"topic": "shop/update",
|
7
|
+
"created_at": "2020-04-01T00:00:00Z",
|
8
|
+
"updated_at": "2020-04-01T00:00:00Z",
|
9
|
+
"format": "json",
|
10
|
+
"fields": [],
|
11
|
+
"metafield_namespaces": [],
|
12
|
+
"api_version": "2020-04",
|
13
|
+
"private_metafield_namespaces": []
|
14
|
+
},
|
15
|
+
{
|
16
|
+
"id": 748073353266,
|
17
|
+
"address": "https://old.example.com/webhooks",
|
18
|
+
"topic": "orders/create",
|
19
|
+
"created_at": "2020-04-01T00:00:00Z",
|
20
|
+
"updated_at": "2020-04-01T00:00:00Z",
|
21
|
+
"format": "json",
|
22
|
+
"fields": [],
|
23
|
+
"metafield_namespaces": [],
|
24
|
+
"api_version": "2020-04",
|
25
|
+
"private_metafield_namespaces": []
|
26
|
+
},
|
27
|
+
{
|
28
|
+
"id": 748073353267,
|
29
|
+
"address": "https://test.example.com/webhooks",
|
30
|
+
"topic": "orders/paid",
|
31
|
+
"created_at": "2020-04-01T00:00:00Z",
|
32
|
+
"updated_at": "2020-04-01T00:00:00Z",
|
33
|
+
"format": "json",
|
34
|
+
"fields": [
|
35
|
+
"id",
|
36
|
+
"financial_status"
|
37
|
+
],
|
38
|
+
"metafield_namespaces": [],
|
39
|
+
"api_version": "2020-04",
|
40
|
+
"private_metafield_namespaces": []
|
41
|
+
}
|
42
|
+
]
|
43
|
+
}
|
@@ -6,6 +6,7 @@ widget_store:
|
|
6
6
|
data:
|
7
7
|
country_name: 'Australia'
|
8
8
|
timezone: '(GMT+10:00) Melbourne'
|
9
|
+
iana_timezone: 'Australia/Melbourne'
|
9
10
|
|
10
11
|
widget_store_dev:
|
11
12
|
shopify_domain: widgets-dev.myshopify.com
|
@@ -14,3 +15,5 @@ widget_store_dev:
|
|
14
15
|
data:
|
15
16
|
country_name: 'Sweden'
|
16
17
|
primary_locale: 'sv'
|
18
|
+
created_at: "2017-03-07T06:06:25.000Z"
|
19
|
+
updated_at: "2017-03-07T06:06:25.000Z"
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class SynchronisesTest < ActionDispatch::IntegrationTest
|
4
|
+
|
4
5
|
include ActiveJob::TestHelper
|
5
6
|
fixtures :all
|
6
7
|
|
@@ -57,7 +58,7 @@ class SynchronisesTest < ActionDispatch::IntegrationTest
|
|
57
58
|
test 'shopify api model still allows synchronisation' do
|
58
59
|
assert_equal({}, @product.data)
|
59
60
|
|
60
|
-
shopify_product = ShopifyAPI::Product.new(
|
61
|
+
shopify_product = ShopifyAPI::Product.new(JSON.parse(webhook_fixture('product_updated')))
|
61
62
|
Product.synchronise(@shop, shopify_product)
|
62
63
|
|
63
64
|
# Assert the product was updated locally, with the correct attributes.
|
@@ -1,17 +1,18 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class DiscoApp::AppInstalledJobTest < ActionController::TestCase
|
4
|
+
|
4
5
|
include ActiveJob::TestHelper
|
5
6
|
|
6
7
|
def setup
|
7
8
|
@shop = disco_app_shops(:widget_store)
|
8
9
|
|
9
|
-
stub_request(:get, "#{@shop.admin_url}/webhooks.json").to_return(status: 200, body: api_fixture('widget_store/
|
10
|
+
stub_request(:get, "#{@shop.admin_url}/webhooks.json").to_return(status: 200, body: api_fixture('widget_store/empty_webhooks').to_json)
|
10
11
|
stub_request(:post, "#{@shop.admin_url}/webhooks.json").to_return(status: 200)
|
11
12
|
stub_request(:get, "#{@shop.admin_url}/shop.json").to_return(status: 200, body: api_fixture('widget_store/shop').to_json)
|
12
13
|
stub_request(:get, "#{@shop.admin_url}/carrier_services.json").to_return(status: 200, body: api_fixture('widget_store/carrier_services').to_json)
|
13
14
|
stub_request(:post, "#{@shop.admin_url}/carrier_services.json").to_return(status: 200)
|
14
|
-
stub_request(:post,
|
15
|
+
stub_request(:post, 'https://api.discolabs.com/v1/app_subscriptions.json').to_return(status: 200)
|
15
16
|
end
|
16
17
|
|
17
18
|
def teardown
|
@@ -20,9 +21,11 @@ class DiscoApp::AppInstalledJobTest < ActionController::TestCase
|
|
20
21
|
end
|
21
22
|
|
22
23
|
test 'app installed job performs shop update job' do
|
23
|
-
|
24
|
-
|
25
|
-
|
24
|
+
with_suppressed_output do
|
25
|
+
# Assert the main install job can be enqueued and performed.
|
26
|
+
perform_enqueued_jobs do
|
27
|
+
DiscoApp::AppInstalledJob.perform_later(@shop)
|
28
|
+
end
|
26
29
|
end
|
27
30
|
|
28
31
|
# Assert the update shop job was performed.
|
@@ -33,8 +36,10 @@ class DiscoApp::AppInstalledJobTest < ActionController::TestCase
|
|
33
36
|
test 'app installed job automatically subscribes stores to the correct default plan' do
|
34
37
|
@shop.current_subscription.destroy
|
35
38
|
|
36
|
-
|
37
|
-
|
39
|
+
with_suppressed_output do
|
40
|
+
perform_enqueued_jobs do
|
41
|
+
DiscoApp::AppInstalledJob.perform_later(@shop)
|
42
|
+
end
|
38
43
|
end
|
39
44
|
|
40
45
|
# Assert the shop was subscribed to the development plan.
|
@@ -44,8 +49,10 @@ class DiscoApp::AppInstalledJobTest < ActionController::TestCase
|
|
44
49
|
test 'app installed job automatically subscribes stores to the correct default plan with a plan code and a source' do
|
45
50
|
@shop.current_subscription.destroy
|
46
51
|
|
47
|
-
|
48
|
-
|
52
|
+
with_suppressed_output do
|
53
|
+
perform_enqueued_jobs do
|
54
|
+
DiscoApp::AppInstalledJob.perform_later(@shop, 'PODCAST', 'smp')
|
55
|
+
end
|
49
56
|
end
|
50
57
|
|
51
58
|
# Assert the shop was subscribed to the development plan.
|
@@ -54,4 +61,16 @@ class DiscoApp::AppInstalledJobTest < ActionController::TestCase
|
|
54
61
|
assert_equal 'smpodcast', @shop.current_subscription.source.name
|
55
62
|
end
|
56
63
|
|
64
|
+
private
|
65
|
+
|
66
|
+
# Prevents the output from the webhook synchronisation from
|
67
|
+
# printing to STDOUT and messing up the test output
|
68
|
+
def with_suppressed_output
|
69
|
+
original_stdout = $stdout.clone
|
70
|
+
$stdout.reopen(File.new('/dev/null', 'w'))
|
71
|
+
yield
|
72
|
+
ensure
|
73
|
+
$stdout.reopen(original_stdout)
|
74
|
+
end
|
75
|
+
|
57
76
|
end
|
@@ -1,11 +1,12 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class DiscoApp::AppUninstalledJobTest < ActionController::TestCase
|
4
|
+
|
4
5
|
include ActiveJob::TestHelper
|
5
6
|
|
6
7
|
def setup
|
7
8
|
@shop = disco_app_shops(:widget_store)
|
8
|
-
stub_request(:post,
|
9
|
+
stub_request(:post, 'https://api.discolabs.com/v1/app_subscriptions.json').to_return(status: 200)
|
9
10
|
perform_enqueued_jobs do
|
10
11
|
DiscoApp::AppUninstalledJob.perform_later(@shop, {})
|
11
12
|
end
|
@@ -25,6 +26,8 @@ class DiscoApp::AppUninstalledJobTest < ActionController::TestCase
|
|
25
26
|
test 'app uninstalled job can be extended using concerns' do
|
26
27
|
assert_performed_jobs 2
|
27
28
|
@shop.reload
|
28
|
-
|
29
|
+
# Assert extended method called.
|
30
|
+
assert_equal 'Nowhere', @shop.data[:country_name]
|
29
31
|
end
|
32
|
+
|
30
33
|
end
|
@@ -1,11 +1,12 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class DiscoApp::SendSubscriptionJobTest < ActionController::TestCase
|
4
|
+
|
4
5
|
include ActiveJob::TestHelper
|
5
6
|
|
6
7
|
def setup
|
7
8
|
@shop = disco_app_shops(:widget_store)
|
8
|
-
stub_request(:post,
|
9
|
+
stub_request(:post, 'https://api.discolabs.com/v1/app_subscriptions.json').to_return(status: 200)
|
9
10
|
end
|
10
11
|
|
11
12
|
def teardown
|
@@ -18,7 +19,7 @@ class DiscoApp::SendSubscriptionJobTest < ActionController::TestCase
|
|
18
19
|
perform_enqueued_jobs do
|
19
20
|
DiscoApp::SendSubscriptionJob.perform_later(@shop)
|
20
21
|
end
|
21
|
-
assert_requested(:post,
|
22
|
+
assert_requested(:post, 'https://api.discolabs.com/v1/app_subscriptions.json', times: 1)
|
22
23
|
end
|
23
24
|
|
24
25
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class DiscoApp::SynchroniseWebhooksJobTest < ActionController::TestCase
|
4
|
+
|
4
5
|
include ActiveJob::TestHelper
|
5
6
|
|
6
7
|
def setup
|
@@ -13,30 +14,86 @@ class DiscoApp::SynchroniseWebhooksJobTest < ActionController::TestCase
|
|
13
14
|
end
|
14
15
|
|
15
16
|
test 'webhook synchronisation job creates webhooks for all expected topics' do
|
16
|
-
|
17
|
-
|
17
|
+
with_suppressed_output do
|
18
|
+
stub_request(:get, "#{@shop.admin_url}/webhooks.json").to_return(status: 200, body: api_fixture('widget_store/empty_webhooks').to_json)
|
19
|
+
stub_request(:post, "#{@shop.admin_url}/webhooks.json").to_return(status: 200)
|
20
|
+
|
21
|
+
perform_enqueued_jobs do
|
22
|
+
DiscoApp::SynchroniseWebhooksJob.perform_later(@shop)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Assert that all 3 webhook topics without field lists were POSTed to.
|
26
|
+
['app/uninstalled', 'shop/update', 'orders/create'].each do |expected_webhook_topic|
|
27
|
+
assert_requested(:post, "#{@shop.admin_url}/webhooks.json", times: 1) do |request|
|
28
|
+
request.body.include?(%Q("topic":"#{expected_webhook_topic}")) && request.body.include?('"fields":[]')
|
29
|
+
end
|
30
|
+
end
|
18
31
|
|
19
|
-
|
20
|
-
|
32
|
+
# Assert that the orders/paid webhook topic was posted to with a field restriction.
|
33
|
+
assert_requested(:post, "#{@shop.admin_url}/webhooks.json", times: 1) do |request|
|
34
|
+
request.body.include?('"topic":"orders/paid"') && request.body.include?('"fields":["id"]')
|
35
|
+
end
|
21
36
|
end
|
37
|
+
end
|
38
|
+
|
39
|
+
test 'webhook synchronisation job only creates and updates webhooks when required' do
|
40
|
+
with_suppressed_output do
|
41
|
+
stub_request(:get, "#{@shop.admin_url}/webhooks.json").to_return(status: 200, body: api_fixture('widget_store/existing_webhooks').to_json)
|
42
|
+
stub_request(:put, "#{@shop.admin_url}/webhooks/748073353266.json").to_return(status: 200)
|
43
|
+
stub_request(:put, "#{@shop.admin_url}/webhooks/748073353267.json").to_return(status: 200)
|
44
|
+
stub_request(:post, "#{@shop.admin_url}/webhooks.json").to_return(status: 200)
|
22
45
|
|
23
|
-
|
24
|
-
|
25
|
-
|
46
|
+
perform_enqueued_jobs do
|
47
|
+
DiscoApp::SynchroniseWebhooksJob.perform_later(@shop)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Assert that a missing webhook was created.
|
51
|
+
assert_requested(:post, "#{@shop.admin_url}/webhooks.json", times: 1) do |request|
|
52
|
+
request.body.include?('"topic":"app/uninstalled"')
|
53
|
+
end
|
54
|
+
|
55
|
+
# Assert that no request was made to update an existing webhook with the expected values.
|
56
|
+
assert_requested(:post, "#{@shop.admin_url}/webhooks.json", times: 0) do |request|
|
57
|
+
request.body.include?('"topic":"shop/update"')
|
58
|
+
end
|
59
|
+
|
60
|
+
# Assert that a request was made to update the URL of a webhook with an out of date URL.
|
61
|
+
assert_requested(:put, "#{@shop.admin_url}/webhooks/748073353266.json", times: 1) do |request|
|
62
|
+
request.body.include?('"topic":"orders/create"') && request.body.include?('"address":"https://test.example.com/webhooks"')
|
63
|
+
end
|
64
|
+
|
65
|
+
# Assert that a request was made to update the fields of a webhook with out of date fields.
|
66
|
+
assert_requested(:put, "#{@shop.admin_url}/webhooks/748073353267.json", times: 1) do |request|
|
67
|
+
request.body.include?('"topic":"orders/paid"') && request.body.include?('"fields":["id"]')
|
68
|
+
end
|
26
69
|
end
|
27
70
|
end
|
28
71
|
|
29
72
|
test 'returns error messages for webhooks that cannot be registered' do
|
30
73
|
VCR.use_cassette('webhook_failure') do
|
31
|
-
|
32
|
-
|
33
|
-
|
74
|
+
with_suppressed_output do
|
75
|
+
output = capture_io do
|
76
|
+
perform_enqueued_jobs do
|
77
|
+
DiscoApp::SynchroniseWebhooksJob.perform_later(@shop)
|
78
|
+
end
|
34
79
|
end
|
35
|
-
end
|
36
80
|
|
37
|
-
|
38
|
-
|
81
|
+
assert output.first.include?('Invalid topic specified.')
|
82
|
+
assert output.first.include?('orders/create - not registered')
|
83
|
+
end
|
39
84
|
end
|
40
85
|
end
|
41
86
|
|
87
|
+
private
|
88
|
+
|
89
|
+
# Prevents the output from the webhook synchronisation from
|
90
|
+
# printing to STDOUT and messing up the test output
|
91
|
+
def with_suppressed_output
|
92
|
+
original_stdout = $stdout.clone
|
93
|
+
$stdout.reopen(File.new('/dev/null', 'w'))
|
94
|
+
yield
|
95
|
+
ensure
|
96
|
+
$stdout.reopen(original_stdout)
|
97
|
+
end
|
98
|
+
|
42
99
|
end
|
@@ -3,6 +3,7 @@ require 'test_helper'
|
|
3
3
|
class DiscoApp::CanBeLiquifiedTest < ActiveSupport::TestCase
|
4
4
|
|
5
5
|
class Model
|
6
|
+
|
6
7
|
include ActiveModel::Model
|
7
8
|
include DiscoApp::Concerns::CanBeLiquified
|
8
9
|
|
@@ -17,6 +18,7 @@ class DiscoApp::CanBeLiquifiedTest < ActiveSupport::TestCase
|
|
17
18
|
def liquid_model_name
|
18
19
|
'model'
|
19
20
|
end
|
21
|
+
|
20
22
|
end
|
21
23
|
|
22
24
|
def setup
|
@@ -48,7 +50,7 @@ class DiscoApp::CanBeLiquifiedTest < ActiveSupport::TestCase
|
|
48
50
|
|
49
51
|
# Return an asset fixture as a string.
|
50
52
|
def liquid_fixture(path)
|
51
|
-
filename = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), 'fixtures', 'liquid',
|
53
|
+
filename = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), 'fixtures', 'liquid', path.to_s)
|
52
54
|
File.read(filename).strip
|
53
55
|
end
|
54
56
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class DiscoApp::HasMetafieldsTest < ActiveSupport::TestCase
|
4
|
+
|
4
5
|
include DiscoApp::Test::ShopifyAPI
|
5
6
|
|
6
7
|
def setup
|
@@ -14,27 +15,45 @@ class DiscoApp::HasMetafieldsTest < ActiveSupport::TestCase
|
|
14
15
|
end
|
15
16
|
|
16
17
|
test 'can write metafields with a single namespace' do
|
17
|
-
stub_api_request(
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
18
|
+
stub_api_request(
|
19
|
+
:put,
|
20
|
+
"#{@shop.admin_url}/products/#{@product.id}.json",
|
21
|
+
'widget_store/products/write_metafields_single_namespace'
|
22
|
+
)
|
23
|
+
|
24
|
+
assert(
|
25
|
+
@shop.with_api_context do
|
26
|
+
@product.write_metafields(
|
27
|
+
namespace1: {
|
28
|
+
key1: 'value1',
|
29
|
+
key2: 2
|
30
|
+
}
|
31
|
+
)
|
32
|
+
end
|
33
|
+
)
|
24
34
|
end
|
25
35
|
|
26
36
|
test 'can write metafields with multiple namespaces' do
|
27
|
-
stub_api_request(
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
37
|
+
stub_api_request(
|
38
|
+
:put,
|
39
|
+
"#{@shop.admin_url}/products/#{@product.id}.json",
|
40
|
+
'widget_store/products/write_metafields_multiple_namespaces'
|
41
|
+
)
|
42
|
+
|
43
|
+
assert(
|
44
|
+
@shop.with_api_context do
|
45
|
+
@product.write_metafields(
|
46
|
+
namespace1: {
|
47
|
+
n1key1: 'value1',
|
48
|
+
n1key2: 2
|
49
|
+
},
|
50
|
+
namespace2: {
|
51
|
+
n2key3: 'value3',
|
52
|
+
n2key4: 2
|
53
|
+
}
|
54
|
+
)
|
55
|
+
end
|
56
|
+
)
|
38
57
|
end
|
39
58
|
|
40
59
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class DiscoApp::RendersAssetsTest < ActiveSupport::TestCase
|
4
|
+
|
4
5
|
include ActiveJob::TestHelper
|
5
6
|
include DiscoApp::Test::ShopifyAPI
|
6
7
|
|
@@ -102,7 +103,7 @@ class DiscoApp::RendersAssetsTest < ActiveSupport::TestCase
|
|
102
103
|
|
103
104
|
# Return an asset fixture as a string.
|
104
105
|
def asset_fixture(path)
|
105
|
-
filename = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), 'fixtures', 'assets',
|
106
|
+
filename = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), 'fixtures', 'assets', path.to_s)
|
106
107
|
File.read(filename)
|
107
108
|
end
|
108
109
|
|
@@ -7,8 +7,8 @@ class DiscoApp::SessionTest < ActiveSupport::TestCase
|
|
7
7
|
@session = DiscoApp::Session.create(
|
8
8
|
session_id: 'a91bfc51fa79c9d09d43e2615d9345d4',
|
9
9
|
data: {
|
10
|
-
:
|
11
|
-
:
|
10
|
+
shopify: @shop.id,
|
11
|
+
shopify_domain: @shop.shopify_domain
|
12
12
|
}
|
13
13
|
)
|
14
14
|
end
|
@@ -25,7 +25,7 @@ class DiscoApp::ShopTest < ActiveSupport::TestCase
|
|
25
25
|
end
|
26
26
|
|
27
27
|
test 'time_zone helper returns correct time zone instance when known timezone defined' do
|
28
|
-
assert_equal 'Melbourne', @shop.time_zone.name
|
28
|
+
assert_equal 'Australia/Melbourne', @shop.time_zone.name
|
29
29
|
end
|
30
30
|
|
31
31
|
test 'time_zone helper returns default Rails timezone when no known timezone defined' do
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class DiscoApp::ChargesServiceTest < ActiveSupport::TestCase
|
4
|
+
|
4
5
|
include DiscoApp::Test::ShopifyAPI
|
5
6
|
|
6
7
|
def setup
|
@@ -30,15 +31,13 @@ class DiscoApp::ChargesServiceTest < ActiveSupport::TestCase
|
|
30
31
|
end
|
31
32
|
|
32
33
|
test 'creating a new charge for a recurring subscription is successful' do
|
33
|
-
res = { "recurring_application_charge": { "name":
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
} }
|
34
|
+
res = { "recurring_application_charge": { "name": 'Basic',
|
35
|
+
"price": '9.99',
|
36
|
+
"trial_days": 14,
|
37
|
+
"return_url": %r{^https://test\.example\.com/subscriptions/304261385/charges/53297050(1|2)/activate$},
|
38
|
+
"test": true } }
|
39
39
|
stub_request(:post, "#{@shop.admin_url}/recurring_application_charges.json")
|
40
|
-
.with(body: res
|
41
|
-
).to_return(status: 201, body:api_fixture("widget_store/charges/create_recurring_application_charge_response").to_json)
|
40
|
+
.with(body: res).to_return(status: 201, body: api_fixture('widget_store/charges/create_recurring_application_charge_response').to_json)
|
42
41
|
|
43
42
|
new_charge = DiscoApp::ChargesService.create(@shop, @subscription)
|
44
43
|
assert_equal 654381179, new_charge.shopify_id
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module DiscoApp
|
4
|
+
module Flow
|
5
|
+
class CreateActionTest < ActiveSupport::TestCase
|
6
|
+
|
7
|
+
include ActiveJob::TestHelper
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@shop = disco_app_shops(:widget_store)
|
11
|
+
end
|
12
|
+
|
13
|
+
def teardown
|
14
|
+
@shop = nil
|
15
|
+
end
|
16
|
+
|
17
|
+
test 'call to create flow action creates model' do
|
18
|
+
result = CreateAction.call(shop: @shop, action_id: action_id, action_run_id: action_run_id, properties: properties)
|
19
|
+
assert result.success?
|
20
|
+
assert result.action.persisted?
|
21
|
+
assert result.action.pending?
|
22
|
+
assert_equal action_id, result.action.action_id
|
23
|
+
assert_equal action_run_id, result.action.action_run_id
|
24
|
+
assert_equal properties, result.action.properties
|
25
|
+
end
|
26
|
+
|
27
|
+
test 'call to create flow action enqueues processing job' do
|
28
|
+
assert_enqueued_with(job: ProcessActionJob) do
|
29
|
+
CreateAction.call(shop: @shop, action_id: action_id, action_run_id: action_run_id, properties: properties)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def action_id
|
36
|
+
'test_action_id'
|
37
|
+
end
|
38
|
+
|
39
|
+
def action_run_id
|
40
|
+
'bdb15e45-4f9d-4c80-88c8-7b43a24edaac-30892-cc8eb62a-14db-43fc-bc33-d6dea41ae623'
|
41
|
+
end
|
42
|
+
|
43
|
+
def properties
|
44
|
+
{
|
45
|
+
'customer_email' => 'name@example.com'
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module DiscoApp
|
4
|
+
module Flow
|
5
|
+
class CreateTriggerTest < ActiveSupport::TestCase
|
6
|
+
|
7
|
+
include ActiveJob::TestHelper
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@shop = disco_app_shops(:widget_store)
|
11
|
+
end
|
12
|
+
|
13
|
+
def teardown
|
14
|
+
@shop = nil
|
15
|
+
end
|
16
|
+
|
17
|
+
test 'call to create flow trigger creates model' do
|
18
|
+
result = CreateTrigger.call(shop: @shop, title: title, resource_name: resource_name, resource_url: resource_url, properties: properties)
|
19
|
+
assert result.success?
|
20
|
+
assert result.trigger.persisted?
|
21
|
+
assert result.trigger.pending?
|
22
|
+
assert_equal title, result.trigger.title
|
23
|
+
assert_equal resource_name, result.trigger.resource_name
|
24
|
+
assert_equal resource_url, result.trigger.resource_url
|
25
|
+
assert_equal properties, result.trigger.properties
|
26
|
+
end
|
27
|
+
|
28
|
+
test 'call to create flow trigger enqueues processing job' do
|
29
|
+
assert_enqueued_with(job: ProcessTriggerJob) do
|
30
|
+
CreateTrigger.call(shop: @shop, title: title, resource_name: resource_name, resource_url: resource_url, properties: properties)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def title
|
37
|
+
'Test trigger'
|
38
|
+
end
|
39
|
+
|
40
|
+
def resource_name
|
41
|
+
'test_resource_name'
|
42
|
+
end
|
43
|
+
|
44
|
+
def resource_url
|
45
|
+
'https://example.com/test-resource-url'
|
46
|
+
end
|
47
|
+
|
48
|
+
def properties
|
49
|
+
{
|
50
|
+
'Customer email' => 'name@example.com'
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|