workarea-core 3.4.45 → 3.5.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +52 -0
- data/app/assets/javascripts/workarea/core/modules/duplicate_id.js +1 -5
- data/app/assets/javascripts/workarea/core/modules/style_guide_autocomplete_fields.js +9 -42
- data/app/assets/javascripts/workarea/core/modules/url.js +14 -0
- data/app/controllers/workarea/application_controller.rb +5 -1
- data/app/controllers/workarea/authentication.rb +15 -26
- data/app/controllers/workarea/authorization.rb +3 -3
- data/app/controllers/workarea/current_referrer.rb +1 -2
- data/app/controllers/workarea/current_release.rb +1 -1
- data/app/controllers/workarea/current_segments.rb +52 -0
- data/app/controllers/workarea/current_tracking.rb +45 -0
- data/app/controllers/workarea/http_caching.rb +30 -0
- data/app/controllers/workarea/impersonation.rb +18 -44
- data/app/helpers/workarea/schema_org_helper.rb +21 -0
- data/app/mailers/workarea/application_mailer.rb +2 -4
- data/app/middleware/workarea/application_middleware.rb +44 -0
- data/app/middleware/workarea/query_cache_middleware.rb +55 -0
- data/app/middleware/workarea/release_server_middleware.rb +1 -1
- data/app/models/workarea/application_document.rb +1 -1
- data/app/models/workarea/bulk_action/product_edit.rb +6 -6
- data/app/models/workarea/calculate_percent_change.rb +1 -1
- data/app/models/workarea/catalog/category.rb +0 -2
- data/app/models/workarea/catalog/product.rb +19 -2
- data/app/models/workarea/checkout/collect_payment.rb +10 -1
- data/app/models/workarea/checkout/fraud/analyzer.rb +44 -0
- data/app/models/workarea/checkout/fraud/no_decision_analyzer.rb +14 -0
- data/app/models/workarea/checkout/fraud/test_analyzer.rb +26 -0
- data/app/models/workarea/checkout.rb +18 -6
- data/app/models/workarea/configuration/admin.rb +25 -0
- data/app/models/workarea/configuration/params.rb +45 -0
- data/app/models/workarea/content/asset.rb +5 -18
- data/app/models/workarea/content/block.rb +8 -2
- data/app/models/workarea/content/block_draft.rb +7 -2
- data/app/models/workarea/content/block_type.rb +2 -2
- data/app/models/workarea/content/block_type_definition.rb +4 -0
- data/app/models/workarea/content/preset.rb +1 -1
- data/app/models/workarea/content.rb +12 -82
- data/app/models/workarea/data_file/csv.rb +6 -8
- data/app/models/workarea/data_file/import.rb +9 -1
- data/app/models/workarea/data_file/json.rb +1 -20
- data/app/models/workarea/data_file/operation.rb +0 -4
- data/app/models/workarea/data_file/tax_rates.rb +3 -0
- data/app/models/workarea/featured_products.rb +8 -0
- data/app/models/workarea/fulfillment/policies/base.rb +21 -0
- data/app/models/workarea/fulfillment/policies/download.rb +21 -0
- data/app/models/workarea/fulfillment/policies/ignore.rb +11 -0
- data/app/models/workarea/fulfillment/policies/ship.rb +15 -0
- data/app/models/workarea/fulfillment/sku.rb +72 -0
- data/app/models/workarea/fulfillment/token.rb +36 -0
- data/app/models/workarea/inquiry.rb +1 -2
- data/app/models/workarea/insights/customer_acquisition.rb +5 -9
- data/app/models/workarea/insights/trending_products.rb +2 -2
- data/app/models/workarea/insights/trending_searches.rb +2 -2
- data/app/models/workarea/inventory/collection.rb +30 -0
- data/app/models/workarea/inventory/collection_status.rb +40 -0
- data/app/models/workarea/metrics/affinity.rb +33 -0
- data/app/models/workarea/metrics/country_by_day.rb +4 -0
- data/app/models/workarea/metrics/product_by_day.rb +3 -0
- data/app/models/workarea/metrics/product_by_week.rb +2 -0
- data/app/models/workarea/metrics/product_for_last_week.rb +8 -12
- data/app/models/workarea/metrics/sales_by_day.rb +5 -0
- data/app/models/workarea/metrics/search_by_day.rb +1 -3
- data/app/models/workarea/metrics/search_for_last_week.rb +5 -11
- data/app/models/workarea/metrics/segment_by_day.rb +31 -0
- data/app/models/workarea/metrics/sku_by_day.rb +3 -0
- data/app/models/workarea/metrics/tender_by_day.rb +11 -0
- data/app/models/workarea/metrics/update_user_aggregations.rb +77 -0
- data/app/models/workarea/metrics/user.rb +73 -87
- data/app/models/workarea/navigation/breadcrumbs.rb +10 -1
- data/app/models/workarea/order/fraud_decision.rb +18 -0
- data/app/models/workarea/order/item.rb +5 -0
- data/app/models/workarea/order/queries.rb +1 -0
- data/app/models/workarea/order/status.rb +10 -1
- data/app/models/workarea/order.rb +47 -4
- data/app/models/workarea/payment/credit_card.rb +12 -0
- data/app/models/workarea/payment.rb +7 -2
- data/app/models/workarea/pricing/cache_key.rb +9 -3
- data/app/models/workarea/pricing/calculator.rb +5 -1
- data/app/models/workarea/pricing/calculators/tax_calculator.rb +32 -5
- data/app/models/workarea/pricing/discount/application_group.rb +8 -3
- data/app/models/workarea/pricing/discount/free_gift.rb +2 -1
- data/app/models/workarea/pricing/discount/redemption.rb +1 -1
- data/app/models/workarea/pricing/discount.rb +2 -3
- data/app/models/workarea/pricing/item_tax_applier.rb +41 -0
- data/app/models/workarea/pricing/price.rb +1 -0
- data/app/models/workarea/pricing/request.rb +11 -0
- data/app/models/workarea/pricing/sku.rb +1 -0
- data/app/models/workarea/pricing/tax_application.rb +21 -0
- data/app/models/workarea/pricing/tax_applier.rb +12 -15
- data/app/models/workarea/pricing/unsupported_segmentation.rb +22 -0
- data/app/models/workarea/product_rule.rb +5 -0
- data/app/models/workarea/releasable.rb +83 -89
- data/app/models/workarea/release/activation.rb +45 -0
- data/app/models/workarea/release/changes.rb +45 -0
- data/app/models/workarea/release/changeset.rb +42 -52
- data/app/models/workarea/release/preview.rb +28 -0
- data/app/models/workarea/release/status.rb +2 -24
- data/app/models/workarea/release.rb +72 -99
- data/app/models/workarea/release_session.rb +11 -11
- data/app/models/workarea/search/admin/catalog_product.rb +1 -2
- data/app/models/workarea/search/admin/fulfillment_sku.rb +27 -0
- data/app/models/workarea/search/admin/order.rb +1 -1
- data/app/models/workarea/search/admin/pricing_discount.rb +1 -1
- data/app/models/workarea/search/admin/release.rb +1 -4
- data/app/models/workarea/search/admin/segment.rb +19 -0
- data/app/models/workarea/search/admin.rb +17 -39
- data/app/models/workarea/search/order_text.rb +23 -6
- data/app/models/workarea/search/storefront/category_query.rb +152 -0
- data/app/models/workarea/search/storefront/product/categories.rb +11 -45
- data/app/models/workarea/search/storefront.rb +33 -29
- data/app/models/workarea/segment/first_time_customer.rb +8 -0
- data/app/models/workarea/segment/first_time_visitor.rb +12 -0
- data/app/models/workarea/segment/life_cycle.rb +44 -0
- data/app/models/workarea/segment/loyal_customer.rb +12 -0
- data/app/models/workarea/segment/returning_customer.rb +14 -0
- data/app/models/workarea/segment/returning_visitor.rb +12 -0
- data/app/models/workarea/segment/rules/base.rb +16 -0
- data/app/models/workarea/segment/rules/browser_info.rb +29 -0
- data/app/models/workarea/segment/rules/geolocation.rb +29 -0
- data/app/models/workarea/segment/rules/geolocation_option.rb +53 -0
- data/app/models/workarea/segment/rules/last_order.rb +14 -0
- data/app/models/workarea/segment/rules/logged_in.rb +13 -0
- data/app/models/workarea/segment/rules/orders.rb +17 -0
- data/app/models/workarea/segment/rules/revenue.rb +17 -0
- data/app/models/workarea/segment/rules/sessions.rb +17 -0
- data/app/models/workarea/segment/rules/tags.rb +14 -0
- data/app/models/workarea/segment/rules/traffic_referrer.rb +18 -0
- data/app/models/workarea/segment.rb +54 -0
- data/app/models/workarea/segmentable.rb +66 -0
- data/app/models/workarea/sort.rb +14 -2
- data/app/models/workarea/tax/rate.rb +35 -1
- data/app/models/workarea/user/authorization.rb +19 -13
- data/app/models/workarea/user/login.rb +4 -0
- data/app/models/workarea/user/password_reset.rb +1 -3
- data/app/queries/workarea/categorization.rb +3 -3
- data/app/queries/workarea/featured_categorization.rb +53 -0
- data/app/queries/workarea/order_cancellation_metrics.rb +155 -0
- data/app/queries/workarea/order_item_details.rb +16 -3
- data/app/queries/workarea/order_metrics.rb +32 -3
- data/app/queries/workarea/product_primary_navigation.rb +13 -2
- data/app/queries/workarea/product_releases.rb +38 -0
- data/app/queries/workarea/recommendation/user_activity_based.rb +14 -6
- data/app/queries/workarea/reports/average_order_value.rb +1 -1
- data/app/queries/workarea/reports/customers.rb +14 -11
- data/app/queries/workarea/reports/first_time_vs_returning_sales.rb +1 -1
- data/app/queries/workarea/reports/group_by_time.rb +13 -17
- data/app/queries/workarea/reports/sales_by_category.rb +1 -1
- data/app/queries/workarea/reports/sales_by_country.rb +10 -3
- data/app/queries/workarea/reports/sales_by_discount.rb +1 -1
- data/app/queries/workarea/reports/sales_by_menu.rb +1 -1
- data/app/queries/workarea/reports/sales_by_product.rb +39 -4
- data/app/queries/workarea/reports/sales_by_sku.rb +39 -4
- data/app/queries/workarea/reports/sales_by_tender.rb +42 -0
- data/app/queries/workarea/reports/sales_by_traffic_referrer.rb +1 -1
- data/app/queries/workarea/reports/sales_over_time.rb +10 -3
- data/app/queries/workarea/reports/searches.rb +1 -1
- data/app/queries/workarea/reports/searches_over_time.rb +1 -1
- data/app/queries/workarea/reports/searches_without_results_over_time.rb +1 -1
- data/app/queries/workarea/search/admin_fulfillment_skus.rb +20 -0
- data/app/queries/workarea/search/admin_releases.rb +1 -4
- data/app/queries/workarea/search/admin_search.rb +0 -4
- data/app/queries/workarea/search/admin_segments.rb +16 -0
- data/app/queries/workarea/search/admin_sorting.rb +1 -1
- data/app/queries/workarea/search/pagination.rb +1 -4
- data/app/queries/workarea/search/product_display_rules.rb +40 -8
- data/app/queries/workarea/search/product_entries.rb +15 -1
- data/app/queries/workarea/search/product_search.rb +4 -1
- data/app/queries/workarea/search/storefront_search/exact_matches.rb +1 -1
- data/app/queries/workarea/search/storefront_search/response.rb +6 -4
- data/app/queries/workarea/search/storefront_search.rb +5 -4
- data/app/seeds/workarea/assets_seeds.rb +2 -1
- data/app/seeds/workarea/insights_seeds.rb +0 -23
- data/app/seeds/workarea/orders_seeds.rb +7 -6
- data/app/seeds/workarea/products_seeds.rb +2 -0
- data/app/seeds/workarea/segments_seeds.rb +8 -0
- data/app/seeds/workarea/tax_seeds.rb +3 -3
- data/app/services/workarea/cancel_order.rb +8 -3
- data/app/services/workarea/copy_order.rb +6 -0
- data/app/services/workarea/create_fulfillment.rb +5 -3
- data/app/services/workarea/direct_upload.rb +11 -19
- data/app/services/workarea/hash_update.rb +1 -18
- data/app/services/workarea/packaging.rb +1 -1
- data/app/services/workarea/save_publishing.rb +5 -1
- data/app/workers/sidekiq/callbacks.rb +4 -52
- data/app/workers/sidekiq/callbacks_worker.rb +4 -6
- data/app/workers/workarea/bulk_index_admin.rb +2 -2
- data/app/workers/workarea/bulk_index_products.rb +6 -5
- data/app/workers/workarea/bulk_index_searches.rb +5 -5
- data/app/workers/workarea/deactivate_stale_discounts.rb +3 -3
- data/app/workers/workarea/generate_insights.rb +1 -1
- data/app/workers/workarea/index_admin_search.rb +1 -0
- data/app/workers/workarea/index_categorization.rb +4 -7
- data/app/workers/workarea/index_category.rb +2 -1
- data/app/workers/workarea/index_category_changes.rb +11 -6
- data/app/workers/workarea/index_fulfillment_changes.rb +2 -1
- data/app/workers/workarea/index_help.rb +2 -1
- data/app/workers/workarea/index_page.rb +2 -1
- data/app/workers/workarea/index_payment_transactions.rb +2 -1
- data/app/workers/workarea/index_product.rb +4 -4
- data/app/workers/workarea/index_product_children.rb +4 -3
- data/app/workers/workarea/index_product_rule.rb +3 -2
- data/app/workers/workarea/index_search_customizations.rb +3 -2
- data/app/workers/workarea/index_skus.rb +5 -6
- data/app/workers/workarea/keep_product_index_fresh.rb +3 -5
- data/app/workers/workarea/process_import.rb +3 -3
- data/app/workers/workarea/process_search_recommendations.rb +5 -9
- data/app/workers/workarea/publish_release.rb +1 -0
- data/app/workers/workarea/save_metrics.rb +116 -0
- data/app/workers/workarea/save_order_cancellation_metrics.rb +35 -0
- data/app/workers/workarea/save_order_metrics.rb +10 -74
- data/app/workers/workarea/status_reporter.rb +2 -4
- data/app/workers/workarea/synchronize_user_metrics.rb +17 -0
- data/app/workers/workarea/update_payment_profile_email.rb +22 -0
- data/app/workers/workarea/verify_scheduled_releases.rb +4 -11
- data/config/initializers/00_configuration.rb +185 -0
- data/config/initializers/02_assets.rb +1 -0
- data/config/initializers/05_scheduled_jobs.rb +0 -7
- data/config/initializers/10_rack_middleware.rb +2 -5
- data/config/initializers/11_payment.rb +4 -0
- data/config/initializers/13_rack_attack.rb +2 -4
- data/config/initializers/14_content_block_types.rb +16 -16
- data/config/initializers/15_endpoint_monitoring.rb +3 -6
- data/config/initializers/{21_premailer.rb → 24_premailer.rb} +1 -0
- data/config/initializers/{20_i18n_js.rb → 25_i18n_js.rb} +0 -0
- data/config/locales/en.yml +13 -24
- data/lib/generators/workarea/content_block_type/templates/initializer.rb +1 -1
- data/lib/generators/workarea/install/USAGE +0 -1
- data/lib/generators/workarea/install/install_generator.rb +0 -21
- data/lib/generators/workarea/install/templates/initializer.rb.erb +1 -1
- data/lib/tasks/insights.rake +1 -0
- data/lib/tasks/migrate.rake +106 -0
- data/lib/tasks/search.rake +17 -19
- data/lib/tasks/tests.rake +1 -1
- data/lib/workarea/cache.rb +6 -35
- data/lib/workarea/changelog.rake +2 -2
- data/lib/workarea/configuration/administrable/definition.rb +42 -0
- data/lib/workarea/configuration/administrable/field.rb +79 -0
- data/lib/workarea/configuration/administrable/fieldset.rb +44 -0
- data/lib/workarea/configuration/administrable_options.rb +24 -0
- data/lib/workarea/configuration/cache_store.rb +3 -1
- data/lib/workarea/configuration/content_blocks.rb +17 -0
- data/lib/workarea/configuration/mongoid.rb +1 -4
- data/lib/workarea/configuration/session.rb +36 -0
- data/lib/workarea/configuration/sidekiq.rb +3 -1
- data/lib/workarea/configuration.rb +121 -148
- data/lib/workarea/core/engine.rb +3 -58
- data/lib/workarea/core.rb +15 -11
- data/lib/workarea/elasticsearch/document.rb +8 -15
- data/lib/workarea/ext/freedom_patches/action_view_cache_helper.rb +4 -6
- data/lib/workarea/ext/freedom_patches/active_support_duration.rb +14 -0
- data/lib/workarea/ext/freedom_patches/money.rb +11 -0
- data/lib/workarea/ext/freedom_patches/premailer.rb +6 -0
- data/lib/workarea/ext/freedom_patches/string.rb +19 -4
- data/lib/workarea/ext/mongoid/find_ordered.rb +2 -2
- data/lib/workarea/ext/mongoid/lookup_hash.rb +30 -0
- data/lib/workarea/geolocation.rb +24 -6
- data/lib/workarea/routes_constraints/super_admin.rb +1 -1
- data/lib/workarea/version.rb +3 -4
- data/lib/workarea/visit.rb +92 -0
- data/lib/workarea/warnings.rb +95 -0
- data/lib/workarea.rb +102 -3
- data/test/dummy/config/initializers/session_store.rb +1 -1
- data/test/fixtures/tax_rates.csv +3 -3
- data/test/generators/workarea/content_block_type_generator_test.rb +1 -1
- data/test/generators/workarea/install_generator_test.rb +0 -13
- data/test/integration/workarea/authentication_test.rb +27 -4
- data/test/integration/workarea/authorization_test.rb +5 -0
- data/test/integration/workarea/cache_varies_integration_test.rb +21 -23
- data/test/integration/workarea/monitoring_integration_test.rb +5 -10
- data/test/javascripts/duplicate_id_spec.js +1 -7
- data/test/javascripts/fixtures/{duplicate_id_fail.html.haml → duplicate_id.html.haml} +0 -1
- data/test/javascripts/form_submitting_controls_spec.js +0 -1
- data/test/lib/workarea/asset_endpoints/favicons_test.rb +11 -13
- data/test/lib/workarea/configuration/administrable/definition_test.rb +71 -0
- data/test/lib/workarea/configuration/administrable/field_test.rb +128 -0
- data/test/lib/workarea/configuration/administrable/fieldset_test.rb +78 -0
- data/test/lib/workarea/configuration/configuration_test.rb +20 -0
- data/test/lib/workarea/elasticsearch/document_test.rb +0 -20
- data/test/lib/workarea/elasticsearch/query_cache_test.rb +7 -7
- data/test/lib/workarea/ext/freedom_patches/money_test.rb +11 -0
- data/test/lib/workarea/ext/mongoid/lookup_hash_test.rb +86 -0
- data/test/lib/workarea/geolocation_test.rb +20 -0
- data/test/mailers/workarea/application_mailer_test.rb +1 -11
- data/test/middleware/workarea/query_cache_middleware_test.rb +55 -0
- data/test/models/workarea/checkout/collect_payment_test.rb +14 -6
- data/test/models/workarea/checkout_test.rb +31 -57
- data/test/models/workarea/configuration/params_test.rb +37 -0
- data/test/models/workarea/data_file/csv_test.rb +8 -73
- data/test/models/workarea/data_file/import_test.rb +31 -0
- data/test/models/workarea/data_file/json_test.rb +6 -48
- data/test/models/workarea/data_file/tax_test.rb +3 -0
- data/test/models/workarea/fulfillment/policies/download_test.rb +39 -0
- data/test/models/workarea/fulfillment/sku_test.rb +54 -0
- data/test/models/workarea/insights/best_customers_test.rb +5 -2
- data/test/models/workarea/insights/best_full_price_customers_test.rb +5 -2
- data/test/models/workarea/insights/customer_acquisition_test.rb +1 -1
- data/test/models/workarea/insights/customers_at_risk_test.rb +1 -1
- data/test/models/workarea/insights/low_aov_customers_test.rb +1 -1
- data/test/models/workarea/inventory/collection_test.rb +75 -0
- data/test/models/workarea/metrics/affinity_test.rb +85 -0
- data/test/models/workarea/metrics/product_by_week_test.rb +27 -31
- data/test/models/workarea/metrics/search_by_day_test.rb +3 -0
- data/test/models/workarea/metrics/search_by_week_test.rb +27 -31
- data/test/models/workarea/metrics/update_user_aggregations_test.rb +62 -0
- data/test/models/workarea/metrics/user_test.rb +146 -63
- data/test/models/workarea/navigation/breadcrumbs_test.rb +12 -2
- data/test/models/workarea/order/queries_test.rb +2 -0
- data/test/models/workarea/order_test.rb +44 -0
- data/test/models/workarea/payment/address_test.rb +109 -111
- data/test/models/workarea/payment/credit_card_integration_test.rb +0 -52
- data/test/models/workarea/payment/credit_card_test.rb +5 -0
- data/test/models/workarea/pricing/cache_key_test.rb +7 -1
- data/test/models/workarea/pricing/calculators/tax_calculator_test.rb +41 -1
- data/test/models/workarea/pricing/discount/collection_test.rb +27 -29
- data/test/models/workarea/pricing/discount_test.rb +22 -24
- data/test/models/workarea/pricing/item_tax_applier_test.rb +83 -0
- data/test/models/workarea/pricing/price_test.rb +9 -0
- data/test/models/workarea/pricing/request_test.rb +13 -0
- data/test/models/workarea/pricing/sku_test.rb +9 -0
- data/test/models/workarea/releasable_active_test.rb +113 -0
- data/test/models/workarea/releasable_test.rb +69 -120
- data/test/models/workarea/release/changeset_test.rb +41 -0
- data/test/models/workarea/release_jobs_test.rb +52 -0
- data/test/models/workarea/release_previewing_test.rb +43 -0
- data/test/models/workarea/release_test.rb +59 -153
- data/test/models/workarea/search/admin/content_asset_test.rb +26 -28
- data/test/models/workarea/search/order_text_test.rb +35 -0
- data/test/models/workarea/search/storefront/category_query_test.rb +81 -0
- data/test/models/workarea/search/storefront/product/categories_test.rb +10 -70
- data/test/models/workarea/search/storefront/product_test.rb +10 -11
- data/test/models/workarea/search/storefront_test.rb +1 -13
- data/test/models/workarea/segment/life_cycle_test.rb +24 -0
- data/test/models/workarea/segment/rules/browser_info_test.rb +33 -0
- data/test/models/workarea/segment/rules/geolocation_option_test.rb +16 -0
- data/test/models/workarea/segment/rules/geolocation_test.rb +49 -0
- data/test/models/workarea/segment/rules/last_order_test.rb +32 -0
- data/test/models/workarea/segment/rules/logged_in_test.rb +25 -0
- data/test/models/workarea/segment/rules/orders_test.rb +59 -0
- data/test/models/workarea/segment/rules/revenue_test.rb +59 -0
- data/test/models/workarea/segment/rules/sessions_test.rb +26 -0
- data/test/models/workarea/segment/rules/tags_test.rb +27 -0
- data/test/models/workarea/segment/rules/traffic_referrer_test.rb +31 -0
- data/test/models/workarea/segment_test.rb +80 -0
- data/test/models/workarea/segmentable_test.rb +74 -0
- data/test/models/workarea/shipping/address_test.rb +109 -111
- data/test/models/workarea/shipping/sku_test.rb +8 -12
- data/test/models/workarea/user/password_reset_test.rb +4 -12
- data/test/models/workarea/user_test.rb +13 -10
- data/test/queries/workarea/admin_search_query_wrapper_test.rb +21 -25
- data/test/queries/workarea/categorization_test.rb +49 -0
- data/test/queries/workarea/featured_categorization_test.rb +66 -0
- data/test/queries/workarea/order_cancellation_metrics_test.rb +203 -0
- data/test/queries/workarea/order_item_details_test.rb +17 -0
- data/test/queries/workarea/order_metrics_test.rb +12 -0
- data/test/queries/workarea/product_releases_test.rb +56 -0
- data/test/queries/workarea/recommendation/searches_test.rb +3 -3
- data/test/queries/workarea/recommendation/user_activity_based_test.rb +4 -4
- data/test/queries/workarea/reports/customers_test.rb +12 -8
- data/test/queries/workarea/reports/report_test.rb +4 -6
- data/test/queries/workarea/reports/sales_by_country_test.rb +18 -3
- data/test/queries/workarea/reports/sales_by_product_test.rb +28 -8
- data/test/queries/workarea/reports/sales_by_sku_test.rb +28 -8
- data/test/queries/workarea/reports/sales_by_tender_test.rb +100 -0
- data/test/queries/workarea/reports/sales_by_traffic_referrer_test.rb +6 -6
- data/test/queries/workarea/search/admin_releases_test.rb +1 -26
- data/test/queries/workarea/search/admin_search_test.rb +0 -10
- data/test/queries/workarea/search/admin_users_test.rb +2 -2
- data/test/queries/workarea/search/category_browse_test.rb +53 -0
- data/test/queries/workarea/search/facet_sorting/size_test.rb +11 -13
- data/test/queries/workarea/search/pagination_test.rb +9 -26
- data/test/queries/workarea/search/product_entries_test.rb +27 -0
- data/test/queries/workarea/search/product_search_test.rb +0 -16
- data/test/queries/workarea/search/storefront_search/response_test.rb +26 -0
- data/test/queries/workarea/search/storefront_search_test.rb +34 -36
- data/test/services/workarea/cancel_order_test.rb +27 -13
- data/test/services/workarea/copy_order_test.rb +17 -0
- data/test/services/workarea/direct_upload_test.rb +1 -46
- data/test/services/workarea/export_report_test.rb +41 -45
- data/test/services/workarea/hash_update_test.rb +12 -12
- data/test/services/workarea/packaging_test.rb +9 -11
- data/test/services/workarea/save_publishing_test.rb +23 -0
- data/test/workers/sidekiq/callbacks_test.rb +0 -22
- data/test/workers/workarea/deactivate_stale_discounts_test.rb +2 -2
- data/test/workers/workarea/index_category_changes_test.rb +5 -7
- data/test/workers/workarea/keep_product_index_fresh_test.rb +1 -1
- data/test/workers/workarea/process_import_test.rb +0 -6
- data/test/workers/workarea/process_search_recommendations_test.rb +4 -5
- data/test/workers/workarea/status_reporter_test.rb +2 -1
- data/test/workers/workarea/synchronize_user_metrics_test.rb +57 -0
- data/test/workers/workarea/update_payment_profile_email_test.rb +27 -0
- data/test/workers/workarea/verify_scheduled_releases_test.rb +0 -26
- data/workarea-core.gemspec +13 -11
- metadata +196 -92
- data/app/assets/javascripts/workarea/core/templates/ui_menu_item.jst.ejs +0 -10
- data/app/controllers/workarea/admin_guest_browsing.rb +0 -54
- data/app/middleware/workarea/rack_cache_config_middleware.rb +0 -19
- data/app/queries/workarea/search/search_suggestions.rb +0 -43
- data/app/workers/workarea/bust_discount_cache.rb +0 -16
- data/app/workers/workarea/clean_user_activity.rb +0 -11
- data/app/workers/workarea/undo_release.rb +0 -15
- data/app/workers/workarea/update_email.rb +0 -33
- data/lib/generators/workarea/docker/USAGE +0 -16
- data/lib/generators/workarea/docker/docker_generator.rb +0 -61
- data/lib/generators/workarea/docker/templates/.env.erb +0 -6
- data/lib/generators/workarea/docker/templates/Dockerfile.erb +0 -48
- data/lib/generators/workarea/docker/templates/docker-compose.yml.erb +0 -72
- data/lib/generators/workarea/docker/templates/docker-entrypoint.sh.erb +0 -6
- data/lib/generators/workarea/docker/templates/docker-sync.yml.erb +0 -8
- data/lib/generators/workarea/docker/templates/docker-wait.sh +0 -11
- data/lib/generators/workarea/docker/templates/docker.env +0 -16
- data/lib/generators/workarea/docker/templates/docker_init.rb.erb +0 -29
- data/lib/workarea/configuration/headless_chrome.rb +0 -42
- data/lib/workarea/configuration/puma.rb +0 -37
- data/lib/workarea/ext/freedom_patches/i18n_js.rb +0 -27
- data/lib/workarea/ext/freedom_patches/mongoid_localized_defaults.rb +0 -25
- data/lib/workarea/ext/jbuilder/jbuilder_cache.rb +0 -29
- data/lib/workarea/ext/referer_parser/parser.decorator +0 -43
- data/lib/workarea/queues_pauser.rb +0 -26
- data/lib/workarea/robots.rb +0 -9
- data/test/generators/workarea/docker_generator_test.rb +0 -156
- data/test/javascripts/fixtures/duplicate_id_pass.html.haml +0 -2
- data/test/lib/workarea/ext/freedom_patches/mongoid_localized_defaults_test.rb +0 -25
- data/test/lib/workarea/ext/referer_parser/parser_test.rb +0 -20
- data/test/queries/workarea/search/search_suggestions_test.rb +0 -29
- data/test/workers/workarea/undo_release_test.rb +0 -23
- data/test/workers/workarea/update_email_test.rb +0 -39
@@ -13,7 +13,8 @@ module Workarea
|
|
13
13
|
units_sold: 2,
|
14
14
|
merchandise: 10.to_m,
|
15
15
|
discounts: 0.to_m,
|
16
|
-
|
16
|
+
tax: 1.to_m,
|
17
|
+
revenue: 11.to_m
|
17
18
|
)
|
18
19
|
|
19
20
|
Metrics::SkuByDay.inc(
|
@@ -23,7 +24,10 @@ module Workarea
|
|
23
24
|
units_sold: 4,
|
24
25
|
merchandise: 20.to_m,
|
25
26
|
discounts: -5.to_m,
|
26
|
-
|
27
|
+
tax: 1.to_m,
|
28
|
+
revenue: 16.to_m,
|
29
|
+
units_canceled: 2,
|
30
|
+
refund: -10.to_m
|
27
31
|
)
|
28
32
|
|
29
33
|
Metrics::SkuByDay.inc(
|
@@ -33,7 +37,10 @@ module Workarea
|
|
33
37
|
units_sold: 6,
|
34
38
|
merchandise: 30.to_m,
|
35
39
|
discounts: -3.to_m,
|
36
|
-
|
40
|
+
tax: 2.to_m,
|
41
|
+
revenue: 29.to_m,
|
42
|
+
units_canceled: 1,
|
43
|
+
refund: -3.to_m
|
37
44
|
)
|
38
45
|
|
39
46
|
Metrics::SkuByDay.inc(
|
@@ -43,7 +50,10 @@ module Workarea
|
|
43
50
|
units_sold: 3,
|
44
51
|
merchandise: 11.to_m,
|
45
52
|
discounts: 0.to_m,
|
46
|
-
|
53
|
+
tax: 1.to_m,
|
54
|
+
revenue: 12.to_m,
|
55
|
+
units_canceled: 1,
|
56
|
+
refund: -5.to_m
|
47
57
|
)
|
48
58
|
|
49
59
|
Metrics::SkuByDay.inc(
|
@@ -53,7 +63,8 @@ module Workarea
|
|
53
63
|
units_sold: 5,
|
54
64
|
merchandise: 21.to_m,
|
55
65
|
discounts: -6.to_m,
|
56
|
-
|
66
|
+
tax: 1.to_m,
|
67
|
+
revenue: 16.to_m
|
57
68
|
)
|
58
69
|
|
59
70
|
Metrics::SkuByDay.inc(
|
@@ -63,7 +74,8 @@ module Workarea
|
|
63
74
|
units_sold: 7,
|
64
75
|
merchandise: 31.to_m,
|
65
76
|
discounts: -4.to_m,
|
66
|
-
|
77
|
+
tax: 2.to_m,
|
78
|
+
revenue: 29.to_m
|
67
79
|
)
|
68
80
|
end
|
69
81
|
|
@@ -80,14 +92,22 @@ module Workarea
|
|
80
92
|
assert_equal(12, foo['units_sold'])
|
81
93
|
assert_equal(60, foo['merchandise'])
|
82
94
|
assert_equal(-8, foo['discounts'])
|
83
|
-
assert_equal(
|
95
|
+
assert_equal(4, foo['tax'])
|
96
|
+
assert_equal(56, foo['revenue'])
|
97
|
+
assert_equal(4.33, foo['average_price'])
|
98
|
+
assert_equal(3, foo['units_canceled'])
|
99
|
+
assert_equal(-13, foo['refund'])
|
84
100
|
|
85
101
|
bar = report.results.detect { |r| r['_id'] == 'bar' }
|
86
102
|
assert_equal(9, bar['orders'])
|
87
103
|
assert_equal(15, bar['units_sold'])
|
88
104
|
assert_equal(63, bar['merchandise'])
|
89
105
|
assert_equal(-10, bar['discounts'])
|
90
|
-
assert_equal(
|
106
|
+
assert_equal(4, bar['tax'])
|
107
|
+
assert_equal(57, bar['revenue'])
|
108
|
+
assert_equal(3.53, bar['average_price'])
|
109
|
+
assert_equal(1, bar['units_canceled'])
|
110
|
+
assert_equal(-5, bar['refund'])
|
91
111
|
end
|
92
112
|
|
93
113
|
def test_date_ranges
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
module Reports
|
5
|
+
class SalesByTenderTest < TestCase
|
6
|
+
setup :add_data, :time_travel
|
7
|
+
|
8
|
+
def add_data
|
9
|
+
Metrics::TenderByDay.inc(
|
10
|
+
key: { tender: 'credit_card' },
|
11
|
+
at: Time.zone.local(2018, 10, 27),
|
12
|
+
orders: 1,
|
13
|
+
revenue: 10.to_m
|
14
|
+
)
|
15
|
+
|
16
|
+
Metrics::TenderByDay.inc(
|
17
|
+
key: { tender: 'credit_card' },
|
18
|
+
at: Time.zone.local(2018, 10, 28),
|
19
|
+
orders: 2,
|
20
|
+
revenue: 15.to_m
|
21
|
+
)
|
22
|
+
|
23
|
+
Metrics::TenderByDay.inc(
|
24
|
+
key: { tender: 'credit_card' },
|
25
|
+
at: Time.zone.local(2018, 10, 29),
|
26
|
+
orders: 3,
|
27
|
+
revenue: 27.to_m
|
28
|
+
)
|
29
|
+
|
30
|
+
Metrics::TenderByDay.inc(
|
31
|
+
key: { tender: 'store_credit' },
|
32
|
+
at: Time.zone.local(2018, 10, 27),
|
33
|
+
orders: 2,
|
34
|
+
revenue: 11.to_m
|
35
|
+
)
|
36
|
+
|
37
|
+
Metrics::TenderByDay.inc(
|
38
|
+
key: { tender: 'store_credit' },
|
39
|
+
at: Time.zone.local(2018, 10, 28),
|
40
|
+
orders: 3,
|
41
|
+
revenue: 15.to_m
|
42
|
+
)
|
43
|
+
|
44
|
+
Metrics::TenderByDay.inc(
|
45
|
+
key: { tender: 'store_credit' },
|
46
|
+
at: Time.zone.local(2018, 10, 29),
|
47
|
+
orders: 4,
|
48
|
+
revenue: 27.to_m
|
49
|
+
)
|
50
|
+
end
|
51
|
+
|
52
|
+
def time_travel
|
53
|
+
travel_to Time.zone.local(2018, 10, 30)
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_grouping_and_summing
|
57
|
+
report = SalesByTender.new
|
58
|
+
assert_equal(2, report.results.length)
|
59
|
+
|
60
|
+
credit_card = report.results.detect { |r| r['_id'] == 'credit_card' }
|
61
|
+
assert_equal(6, credit_card['orders'])
|
62
|
+
assert_equal(52, credit_card['revenue'])
|
63
|
+
|
64
|
+
store_credit = report.results.detect { |r| r['_id'] == 'store_credit' }
|
65
|
+
assert_equal(9, store_credit['orders'])
|
66
|
+
assert_equal(53, store_credit['revenue'])
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_date_ranges
|
70
|
+
report = SalesByTender.new
|
71
|
+
credit_card = report.results.detect { |r| r['_id'] == 'credit_card' }
|
72
|
+
assert_equal(6, credit_card['orders'])
|
73
|
+
|
74
|
+
report = SalesByTender.new(starts_at: '2018-10-28', ends_at: '2018-10-28')
|
75
|
+
credit_card = report.results.detect { |r| r['_id'] == 'credit_card' }
|
76
|
+
assert_equal(2, credit_card['orders'])
|
77
|
+
|
78
|
+
report = SalesByTender.new(starts_at: '2018-10-28', ends_at: '2018-10-29')
|
79
|
+
credit_card = report.results.detect { |r| r['_id'] == 'credit_card' }
|
80
|
+
assert_equal(5, credit_card['orders'])
|
81
|
+
|
82
|
+
report = SalesByTender.new(starts_at: '2018-10-28')
|
83
|
+
credit_card = report.results.detect { |r| r['_id'] == 'credit_card' }
|
84
|
+
assert_equal(5, credit_card['orders'])
|
85
|
+
|
86
|
+
report = SalesByTender.new(ends_at: '2018-10-28')
|
87
|
+
credit_card = report.results.detect { |r| r['_id'] == 'credit_card' }
|
88
|
+
assert_equal(3, credit_card['orders'])
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_sorting
|
92
|
+
report = SalesByTender.new(sort_by: 'orders', sort_direction: 'asc')
|
93
|
+
assert_equal('credit_card', report.results.first['_id'])
|
94
|
+
|
95
|
+
report = SalesByTender.new(sort_by: 'orders', sort_direction: 'desc')
|
96
|
+
assert_equal('store_credit', report.results.first['_id'])
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -99,12 +99,12 @@ module Workarea
|
|
99
99
|
assert_equal(-10, facebook['discounts'])
|
100
100
|
assert_equal(53, facebook['revenue'])
|
101
101
|
|
102
|
-
|
103
|
-
assert_equal(3,
|
104
|
-
assert_equal(3,
|
105
|
-
assert_equal(30,
|
106
|
-
assert_equal(0,
|
107
|
-
assert_equal(30,
|
102
|
+
twitter = report.results.detect { |r| r['_id']['source'] == 'Twitter' }
|
103
|
+
assert_equal(3, twitter['orders'])
|
104
|
+
assert_equal(3, twitter['units_sold'])
|
105
|
+
assert_equal(30, twitter['merchandise'])
|
106
|
+
assert_equal(0, twitter['discounts'])
|
107
|
+
assert_equal(30, twitter['revenue'])
|
108
108
|
end
|
109
109
|
|
110
110
|
def test_date_ranges
|
@@ -9,10 +9,6 @@ module Workarea
|
|
9
9
|
@scheduled = create_release(name: 'Scheduled Release', publish_at: 1.week.from_now)
|
10
10
|
@unscheduled = create_release(name: 'Unscheduled Release', created_at: Time.zone.local(2016, 6, 6))
|
11
11
|
@published = create_release(name: 'Published Release', published_at: 1.week.ago)
|
12
|
-
@undone = create_release(name: 'Undone Release', published_at: 2.week.ago, undone_at: 1.day.ago)
|
13
|
-
@scheduled_undo_1 = create_release(name: 'Scheduled Undo Release 1', published_at: 5.week.ago, undo_at: 1.day.from_now)
|
14
|
-
@scheduled_undo_2 = create_release(name: 'Scheduled Undo Release 2', published_at: 4.week.ago, undo_at: 3.day.from_now)
|
15
|
-
@scheduled_undo_3 = create_release(name: 'Scheduled Undo Release 3', published_at: 3.week.ago, undo_at: 2.day.from_now)
|
16
12
|
end
|
17
13
|
|
18
14
|
def test_filter
|
@@ -25,34 +21,13 @@ module Workarea
|
|
25
21
|
assert_includes(search.results, @unscheduled)
|
26
22
|
|
27
23
|
search = AdminReleases.new(publishing: 'published')
|
28
|
-
assert_equal(5, search.total)
|
29
|
-
assert_includes(search.results, @published)
|
30
|
-
assert_includes(search.results, @undone)
|
31
|
-
assert_includes(search.results, @scheduled_undo_1)
|
32
|
-
assert_includes(search.results, @scheduled_undo_2)
|
33
|
-
assert_includes(search.results, @scheduled_undo_3)
|
34
|
-
|
35
|
-
search = AdminReleases.new(publishing: 'undone')
|
36
24
|
assert_equal(1, search.total)
|
37
|
-
assert_includes(search.results, @
|
38
|
-
|
39
|
-
search = AdminReleases.new(publishing: 'scheduled_undo')
|
40
|
-
assert_equal(3, search.total)
|
41
|
-
assert_includes(search.results, @scheduled_undo_1)
|
42
|
-
assert_includes(search.results, @scheduled_undo_2)
|
43
|
-
assert_includes(search.results, @scheduled_undo_3)
|
25
|
+
assert_includes(search.results, @published)
|
44
26
|
end
|
45
27
|
|
46
28
|
def test_sort
|
47
29
|
search = AdminReleases.new(sort: 'published_date')
|
48
30
|
assert_equal(@published, search.results.first)
|
49
|
-
assert_equal(@undone, search.results.second)
|
50
|
-
assert_equal(@scheduled_undo_3, search.results.third)
|
51
|
-
|
52
|
-
search = AdminReleases.new(sort: 'undo_date')
|
53
|
-
assert_equal(@scheduled_undo_1, search.results.first)
|
54
|
-
assert_equal(@scheduled_undo_3, search.results.second)
|
55
|
-
assert_equal(@scheduled_undo_2, search.results.third)
|
56
31
|
end
|
57
32
|
|
58
33
|
def test_filter_by_date
|
@@ -81,16 +81,6 @@ module Workarea
|
|
81
81
|
assert_equal(results.reverse, search.results)
|
82
82
|
end
|
83
83
|
|
84
|
-
def test_default_sort_by_score
|
85
|
-
# Unlike other admin searches (primarily indexes), we want searching to
|
86
|
-
# default sort by score. Testing scores directly is unreliable so just
|
87
|
-
# do a simple check here.
|
88
|
-
assert_equal(
|
89
|
-
[{ _score: :desc }, { updated_at: :desc }],
|
90
|
-
AdminSearch.new.default_admin_sort
|
91
|
-
)
|
92
|
-
end
|
93
|
-
|
94
84
|
def test_selected_sorting
|
95
85
|
results = [
|
96
86
|
create_product(name: 'A', variants: []),
|
@@ -7,8 +7,8 @@ module Workarea
|
|
7
7
|
one = create_user(email: 'foo@workarea.com')
|
8
8
|
two = create_user(email: 'bar@workarea.com')
|
9
9
|
|
10
|
-
Metrics::User.
|
11
|
-
Metrics::User.
|
10
|
+
Metrics::User.save_order(email: one.email, revenue: 50)
|
11
|
+
Metrics::User.save_order(email: two.email, revenue: 5)
|
12
12
|
Search::Admin::User.new(one).save
|
13
13
|
Search::Admin::User.new(two).save
|
14
14
|
|
@@ -329,6 +329,59 @@ module Workarea
|
|
329
329
|
search = CategoryBrowse.new(sort: %w(featured), category_ids: [category.id])
|
330
330
|
assert_equal(%w(1 2 3), search.results.map { |r| r[:model].id })
|
331
331
|
end
|
332
|
+
|
333
|
+
def test_different_products_by_segment
|
334
|
+
segment_one = create_segment(name: 'One')
|
335
|
+
segment_two = create_segment(name: 'Two')
|
336
|
+
product_one = create_product(id: '1', active: true, active_segment_ids: [segment_one.id])
|
337
|
+
product_two = create_product(id: '2', active: true, active_segment_ids: [segment_two.id])
|
338
|
+
product_three = create_product(id: '3', active: false, active_segment_ids: [segment_one.id])
|
339
|
+
product_four = create_product(id: '4', active: true)
|
340
|
+
product_five = create_product(id: '5', active: false)
|
341
|
+
rules = [ProductRule.new(name: 'search', operator: 'equals', value: '*')]
|
342
|
+
|
343
|
+
search = CategoryBrowse.new(rules: rules)
|
344
|
+
result_ids = search.results.map { |r| r[:model].id }
|
345
|
+
|
346
|
+
refute_includes(result_ids, product_one.id)
|
347
|
+
refute_includes(result_ids, product_two.id)
|
348
|
+
refute_includes(result_ids, product_three.id)
|
349
|
+
assert_includes(result_ids, product_four.id)
|
350
|
+
refute_includes(result_ids, product_five.id)
|
351
|
+
|
352
|
+
Segment.with_current(segment_one) do
|
353
|
+
search = CategoryBrowse.new(rules: rules)
|
354
|
+
result_ids = search.results.map { |r| r[:model].id }
|
355
|
+
|
356
|
+
assert_includes(result_ids, product_one.id)
|
357
|
+
refute_includes(result_ids, product_two.id)
|
358
|
+
refute_includes(result_ids, product_three.id)
|
359
|
+
assert_includes(result_ids, product_four.id)
|
360
|
+
refute_includes(result_ids, product_five.id)
|
361
|
+
end
|
362
|
+
|
363
|
+
Segment.with_current(segment_two) do
|
364
|
+
search = CategoryBrowse.new(rules: rules)
|
365
|
+
result_ids = search.results.map { |r| r[:model].id }
|
366
|
+
|
367
|
+
refute_includes(result_ids, product_one.id)
|
368
|
+
assert_includes(result_ids, product_two.id)
|
369
|
+
refute_includes(result_ids, product_three.id)
|
370
|
+
assert_includes(result_ids, product_four.id)
|
371
|
+
refute_includes(result_ids, product_five.id)
|
372
|
+
end
|
373
|
+
|
374
|
+
Segment.with_current(segment_one, segment_two) do
|
375
|
+
search = CategoryBrowse.new(rules: rules)
|
376
|
+
result_ids = search.results.map { |r| r[:model].id }
|
377
|
+
|
378
|
+
assert_includes(result_ids, product_one.id)
|
379
|
+
assert_includes(result_ids, product_two.id)
|
380
|
+
refute_includes(result_ids, product_three.id)
|
381
|
+
assert_includes(result_ids, product_four.id)
|
382
|
+
refute_includes(result_ids, product_five.id)
|
383
|
+
end
|
384
|
+
end
|
332
385
|
end
|
333
386
|
end
|
334
387
|
end
|
@@ -5,21 +5,19 @@ module Workarea
|
|
5
5
|
class FacetSorting
|
6
6
|
class SizeTest < TestCase
|
7
7
|
def test_call
|
8
|
-
Workarea.
|
9
|
-
config.search_facet_size_sort = %(XS S M L XL)
|
8
|
+
Workarea.config.search_facet_size_sort = %(XS S M L XL)
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
results = { 'M' => 50, 'L' => 40, 'S' => 30, 'XL' => 20, 'XS' => 10 }
|
11
|
+
assert_equal(
|
12
|
+
{ 'XS' => 10, 'S' => 30, 'M' => 50, 'L' => 40, 'XL' => 20 },
|
13
|
+
Size.call(:size, results)
|
14
|
+
)
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
16
|
+
results = { 'M' => 50, 'Small' => 40, 'XXL' => 30, 'XL' => 20 }
|
17
|
+
assert_equal(
|
18
|
+
{ 'M' => 50, 'XL' => 20, 'Small' => 40, 'XXL' => 30 },
|
19
|
+
Size.call(:size, results)
|
20
|
+
)
|
23
21
|
end
|
24
22
|
end
|
25
23
|
end
|
@@ -19,39 +19,22 @@ module Workarea
|
|
19
19
|
assert_equal(1, Paginate.new(page: 'asdf').page)
|
20
20
|
end
|
21
21
|
|
22
|
-
def test_per_page
|
23
|
-
assert_equal(Workarea.config.per_page, Paginate.new.per_page)
|
24
|
-
assert_equal(2, Paginate.new(per_page: 2).per_page)
|
25
|
-
assert_equal(Workarea.config.per_page, Paginate.new(per_page: -1).per_page)
|
26
|
-
assert_equal(Workarea.config.per_page, Paginate.new(per_page: 0).per_page)
|
27
|
-
assert_equal(3, Paginate.new(per_page: '3').per_page)
|
28
|
-
assert_equal(Workarea.config.per_page, Paginate.new(per_page: 'asdf').per_page)
|
29
|
-
end
|
30
|
-
|
31
22
|
def test_from
|
32
|
-
Workarea.
|
33
|
-
|
34
|
-
assert_equal(0, Paginate.new(page: 1).from)
|
35
|
-
end
|
23
|
+
Workarea.config.per_page = 30
|
24
|
+
assert_equal(0, Paginate.new(page: 1).from)
|
36
25
|
|
37
|
-
Workarea.
|
38
|
-
|
39
|
-
assert_equal(15, Paginate.new(page: 2).from)
|
40
|
-
end
|
26
|
+
Workarea.config.per_page = 15
|
27
|
+
assert_equal(15, Paginate.new(page: 2).from)
|
41
28
|
|
42
|
-
Workarea.
|
43
|
-
|
44
|
-
assert_equal(90, Paginate.new(page: 3).from)
|
45
|
-
end
|
29
|
+
Workarea.config.per_page = 45
|
30
|
+
assert_equal(90, Paginate.new(page: 3).from)
|
46
31
|
end
|
47
32
|
|
48
33
|
def test_size
|
49
|
-
Workarea.
|
50
|
-
config.per_page = 30
|
34
|
+
Workarea.config.per_page = 30
|
51
35
|
|
52
|
-
|
53
|
-
|
54
|
-
end
|
36
|
+
search = Paginate.new(page: 2)
|
37
|
+
assert_equal(30, search.size)
|
55
38
|
end
|
56
39
|
|
57
40
|
def test_each_by
|
@@ -9,6 +9,33 @@ module Workarea
|
|
9
9
|
assert_equal(1, ProductEntries.new(products.first).entries.size)
|
10
10
|
assert_equal(3, ProductEntries.new(products).entries.size)
|
11
11
|
end
|
12
|
+
|
13
|
+
def test_live_entries
|
14
|
+
product = create_product(name: 'Foo')
|
15
|
+
create_release.as_current do
|
16
|
+
product.update!(name: 'Bar')
|
17
|
+
product.reload
|
18
|
+
end
|
19
|
+
assert_equal('Bar', product.name)
|
20
|
+
|
21
|
+
results = ProductEntries.new(product).live_entries
|
22
|
+
assert_equal(1, results.size)
|
23
|
+
assert_equal('Foo', results.first.model.name)
|
24
|
+
refute_equal(product.object_id, results.first.model.object_id)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_release_entries
|
28
|
+
product = create_product(name: 'Foo')
|
29
|
+
release = create_release
|
30
|
+
release.as_current { product.update!(name: 'Bar') }
|
31
|
+
assert_equal('Foo', product.name)
|
32
|
+
|
33
|
+
results = ProductEntries.new(product).release_entries
|
34
|
+
assert_equal(1, results.size)
|
35
|
+
assert_equal('Bar', results.first.model.name)
|
36
|
+
assert_equal(release.id, results.first.release_id)
|
37
|
+
refute_equal(product.object_id, results.first.model.object_id)
|
38
|
+
end
|
12
39
|
end
|
13
40
|
end
|
14
41
|
end
|
@@ -408,22 +408,6 @@ module Workarea
|
|
408
408
|
assert(result[:raw].present?)
|
409
409
|
assert_kind_of(Float, result[:raw]['_score'])
|
410
410
|
end
|
411
|
-
|
412
|
-
def test_locale
|
413
|
-
# No simple way to run this test without fallbacks or localized fields
|
414
|
-
return unless Workarea.config.localized_active_fields
|
415
|
-
|
416
|
-
set_locales(available: [:en, :es], default: :en, current: :en)
|
417
|
-
Search::Storefront.reset_indexes!
|
418
|
-
|
419
|
-
product = create_product(active_translations: { 'en' => true, 'es' => false })
|
420
|
-
|
421
|
-
I18n.locale = :es
|
422
|
-
assert_equal([], ProductSearch.new(q: '*').results.pluck(:model))
|
423
|
-
|
424
|
-
I18n.locale = :en
|
425
|
-
assert_equal([product], ProductSearch.new(q: '*').results.pluck(:model))
|
426
|
-
end
|
427
411
|
end
|
428
412
|
end
|
429
413
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
module Search
|
5
|
+
class StorefrontSearch
|
6
|
+
class ResponseTest < TestCase
|
7
|
+
def test_only_uses_active_product_rules
|
8
|
+
customization = create_search_customization(
|
9
|
+
id: 'foo',
|
10
|
+
product_rules: [
|
11
|
+
{ name: 'excluded_products', operator: 'equals', value: '1' },
|
12
|
+
{ name: 'excluded_products', operator: 'equals', value: '2', active: false }
|
13
|
+
]
|
14
|
+
)
|
15
|
+
|
16
|
+
response = Response.new(q: 'foo', customization: customization)
|
17
|
+
assert_equal(customization.product_rules.take(1), response.query.params[:rules])
|
18
|
+
|
19
|
+
customization.product_rules.first.update!(active: false)
|
20
|
+
response.reset!(q: 'foo')
|
21
|
+
assert_empty(response.query.params[:rules])
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -55,56 +55,54 @@ module Workarea
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def test_only_finds_active_customizations
|
58
|
-
Search::Customization.find_by_query('
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
58
|
+
customization = Search::Customization.find_by_query('foo')
|
59
|
+
search = StorefrontSearch.new(q: 'foo')
|
60
|
+
assert_equal(customization, search.customization)
|
61
|
+
|
62
|
+
customization.update!(active: false)
|
63
|
+
search = StorefrontSearch.new(q: 'foo')
|
64
|
+
refute_equal(customization, search.customization)
|
63
65
|
refute(search.customization.persisted?)
|
64
66
|
end
|
65
67
|
|
66
68
|
def test_keeps_track_of_middleware
|
67
|
-
Workarea.
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
Workarea::Search::StorefrontSearch::Template
|
75
|
-
)
|
69
|
+
Workarea.config.storefront_search_middleware = SwappableList.new(
|
70
|
+
%w(
|
71
|
+
Workarea::Search::StorefrontSearch::Redirect
|
72
|
+
Workarea::Search::StorefrontSearch::ExactMatches
|
73
|
+
Workarea::Search::StorefrontSearch::ProductMultipass
|
74
|
+
Workarea::Search::StorefrontSearch::SpellingCorrection
|
75
|
+
Workarea::Search::StorefrontSearch::Template
|
76
76
|
)
|
77
|
+
)
|
77
78
|
|
78
|
-
|
79
|
+
assert_equal(5, StorefrontSearch.new(q: '*').used_middleware.size)
|
79
80
|
|
80
|
-
|
81
|
-
|
81
|
+
product = create_product(name: 'Foo Product')
|
82
|
+
IndexProduct.perform(product)
|
82
83
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
end
|
84
|
+
exact_match = StorefrontSearch.new(q: product.id)
|
85
|
+
assert_equal(2, exact_match.used_middleware.size)
|
86
|
+
assert_kind_of(StorefrontSearch::ExactMatches, exact_match.used_middleware.last)
|
87
87
|
end
|
88
88
|
|
89
89
|
def test_tracing
|
90
|
-
Workarea.
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
Workarea::Search::StorefrontSearch::Template
|
98
|
-
)
|
90
|
+
Workarea.config.storefront_search_middleware = SwappableList.new(
|
91
|
+
%w(
|
92
|
+
Workarea::Search::StorefrontSearch::Redirect
|
93
|
+
Workarea::Search::StorefrontSearch::ExactMatches
|
94
|
+
Workarea::Search::StorefrontSearch::ProductMultipass
|
95
|
+
Workarea::Search::StorefrontSearch::SpellingCorrection
|
96
|
+
Workarea::Search::StorefrontSearch::Template
|
99
97
|
)
|
98
|
+
)
|
100
99
|
|
101
|
-
|
100
|
+
trace = StorefrontSearch.new(q: '*').response.trace
|
102
101
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
end
|
102
|
+
assert_equal(3, trace.size)
|
103
|
+
assert_nil(trace.first.reset_by)
|
104
|
+
assert_kind_of(StorefrontSearch::ProductMultipass, trace.second.reset_by)
|
105
|
+
assert_kind_of(StorefrontSearch::ProductMultipass, trace.third.reset_by)
|
108
106
|
end
|
109
107
|
|
110
108
|
def test_exact_match_customization
|
@@ -1,20 +1,15 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
# TODO: Factor out remaining calls to this service and then remove
|
4
|
-
# Plugins call Order#cancel directly and no longer go through this service
|
5
3
|
module Workarea
|
6
|
-
class CancelOrderTest <
|
7
|
-
setup :
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
Storefront::FulfillmentMailer.stubs(:shipped).returns(stub_everything)
|
13
|
-
Storefront::FulfillmentMailer.stubs(:canceled).returns(stub_everything)
|
14
|
-
end
|
4
|
+
class CancelOrderTest < TestCase
|
5
|
+
setup :build_order
|
6
|
+
|
7
|
+
def build_order
|
8
|
+
create_product(id: 'PROD1', variants: [{ sku: 'SKU1', regular: 5.to_m }])
|
9
|
+
create_product(id: 'PROD2', variants: [{ sku: 'SKU2', regular: 3.to_m }])
|
15
10
|
|
16
|
-
setup do
|
17
11
|
@order = Order.new(
|
12
|
+
email: 'test@workarea.com',
|
18
13
|
items: [
|
19
14
|
{ product_id: 'PROD1', sku: 'SKU1', quantity: 2 },
|
20
15
|
{ product_id: 'PROD2', sku: 'SKU2', quantity: 3 }
|
@@ -106,13 +101,32 @@ module Workarea
|
|
106
101
|
end
|
107
102
|
|
108
103
|
def test_marking_the_order_canceled
|
109
|
-
@order
|
104
|
+
complete_checkout(@order)
|
105
|
+
|
106
|
+
SaveOrderMetrics.perform(@order)
|
107
|
+
|
108
|
+
assert_equal(1, Metrics::User.first.orders)
|
109
|
+
|
110
|
+
product_metric = Metrics::ProductByDay.by_product('PROD1').first
|
111
|
+
assert_equal(2, product_metric.units_sold)
|
112
|
+
|
113
|
+
travel_to 1.week.from_now
|
110
114
|
|
111
115
|
cancel = CancelOrder.new(@order)
|
112
116
|
cancel.perform
|
113
117
|
|
114
118
|
@order.reload
|
115
119
|
assert(@order.canceled?)
|
120
|
+
|
121
|
+
assert_equal(1, Metrics::User.first.cancellations)
|
122
|
+
|
123
|
+
product_metric.reload
|
124
|
+
assert_equal(2, product_metric.units_sold)
|
125
|
+
assert_equal(0, product_metric.units_canceled)
|
126
|
+
|
127
|
+
product_metric = Metrics::ProductByDay.by_product('PROD1').last
|
128
|
+
assert_equal(0, product_metric.units_sold)
|
129
|
+
assert_equal(2, product_metric.units_canceled)
|
116
130
|
end
|
117
131
|
end
|
118
132
|
end
|