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
@@ -107,11 +107,51 @@ module Workarea
|
|
107
107
|
postal_code: '19106'
|
108
108
|
)
|
109
109
|
|
110
|
-
TaxCalculator.test_adjust(shipping)
|
110
|
+
TaxCalculator.test_adjust(Order.new, shipping)
|
111
111
|
|
112
112
|
assert_equal(1, shipping.price_adjustments.length)
|
113
113
|
assert_equal('shipping', shipping.price_adjustments.last.price)
|
114
114
|
end
|
115
|
+
|
116
|
+
def test_assign_tax_to_item_with_no_shipping_required
|
117
|
+
create_pricing_sku(
|
118
|
+
id: 'SKU',
|
119
|
+
tax_code: '001',
|
120
|
+
prices: [{ regular: 5.to_m }]
|
121
|
+
)
|
122
|
+
|
123
|
+
create_tax_category(
|
124
|
+
code: '001',
|
125
|
+
rates: [{ percentage: 0.06, region: 'PA', country: 'US' }]
|
126
|
+
)
|
127
|
+
|
128
|
+
order = Order.new(
|
129
|
+
items: [
|
130
|
+
{
|
131
|
+
requires_shipping: false,
|
132
|
+
price_adjustments: [
|
133
|
+
{
|
134
|
+
price: 'item',
|
135
|
+
amount: 5.to_m,
|
136
|
+
data: { 'tax_code' => '001' }
|
137
|
+
}
|
138
|
+
]
|
139
|
+
}
|
140
|
+
]
|
141
|
+
)
|
142
|
+
|
143
|
+
payment = create_payment(
|
144
|
+
id: order.id,
|
145
|
+
address: factory_defaults_config.billing_address
|
146
|
+
)
|
147
|
+
|
148
|
+
TaxCalculator.test_adjust(order)
|
149
|
+
|
150
|
+
item = order.items.first
|
151
|
+
assert_equal(2, item.price_adjustments.length)
|
152
|
+
assert_equal('tax', item.price_adjustments.last.price)
|
153
|
+
assert_equal(0.30.to_m, item.price_adjustments.last.amount)
|
154
|
+
end
|
115
155
|
end
|
116
156
|
end
|
117
157
|
end
|
@@ -5,38 +5,36 @@ module Workarea
|
|
5
5
|
class Discount
|
6
6
|
class CollectionTest < TestCase
|
7
7
|
def test_all
|
8
|
-
Workarea.
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
)
|
8
|
+
Workarea.config.discount_application_order = %w(
|
9
|
+
Workarea::Pricing::Discount::Product
|
10
|
+
Workarea::Pricing::Discount::ProductAttribute
|
11
|
+
Workarea::Pricing::Discount::Category
|
12
|
+
Workarea::Pricing::Discount::BuySomeGetSome
|
13
|
+
Workarea::Pricing::Discount::QuantityFixedPrice
|
14
|
+
Workarea::Pricing::Discount::FreeGift
|
15
|
+
Workarea::Pricing::Discount::Shipping
|
16
|
+
Workarea::Pricing::Discount::OrderTotal
|
17
|
+
)
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
19
|
+
buy_some_get_some = create_buy_some_get_some_discount
|
20
|
+
category = create_category_discount
|
21
|
+
free_gift = create_free_gift_discount
|
22
|
+
order_total = create_order_total_discount
|
23
|
+
product_attribute = create_product_attribute_discount
|
24
|
+
product = create_product_discount
|
25
|
+
fixed_price = create_quantity_fixed_price_discount
|
26
|
+
shipping = create_shipping_discount
|
28
27
|
|
29
|
-
|
28
|
+
collection = Collection.new
|
30
29
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
30
|
+
assert_equal(product, collection.all[0])
|
31
|
+
assert_equal(product_attribute, collection.all[1])
|
32
|
+
assert_equal(category, collection.all[2])
|
33
|
+
assert_equal(buy_some_get_some, collection.all[3])
|
34
|
+
assert_equal(fixed_price, collection.all[4])
|
35
|
+
assert_equal(free_gift, collection.all[5])
|
36
|
+
assert_equal(shipping, collection.all[6])
|
37
|
+
assert_equal(order_total, collection.all[7])
|
40
38
|
end
|
41
39
|
end
|
42
40
|
end
|
@@ -35,30 +35,28 @@ module Workarea
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def test_comparison_operator # <==>
|
38
|
-
Workarea.
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
assert_equal(-1, product_1 <=> product_2)
|
61
|
-
end
|
38
|
+
Workarea.config.discount_application_order = %w(
|
39
|
+
Workarea::Pricing::Discount::Product
|
40
|
+
Workarea::Pricing::Discount::ProductAttribute
|
41
|
+
Workarea::Pricing::Discount::Category
|
42
|
+
Workarea::Pricing::Discount::BuySomeGetSome
|
43
|
+
Workarea::Pricing::Discount::QuantityFixedPrice
|
44
|
+
Workarea::Pricing::Discount::FreeGift
|
45
|
+
Workarea::Pricing::Discount::Shipping
|
46
|
+
Workarea::Pricing::Discount::OrderTotal
|
47
|
+
)
|
48
|
+
|
49
|
+
product = create_product_discount
|
50
|
+
product_attribute = create_product_attribute_discount
|
51
|
+
|
52
|
+
assert_equal(-1, product <=> product_attribute)
|
53
|
+
assert_equal(1, product_attribute <=> product)
|
54
|
+
assert_equal(0, product <=> product)
|
55
|
+
|
56
|
+
product_1 = create_product_discount(id: 1)
|
57
|
+
product_2 = create_product_discount(id: 2)
|
58
|
+
|
59
|
+
assert_equal(-1, product_1 <=> product_2)
|
62
60
|
end
|
63
61
|
|
64
62
|
def test_qualifies?
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
module Pricing
|
5
|
+
class ItemTaxApplierTest < TestCase
|
6
|
+
setup :set_models
|
7
|
+
|
8
|
+
def set_models
|
9
|
+
@item = Order::Item.new
|
10
|
+
@address = Workarea::Address.new(factory_defaults_config.billing_address)
|
11
|
+
|
12
|
+
@adjustments_to_tax = PriceAdjustmentSet.new(
|
13
|
+
[
|
14
|
+
@item.price_adjustments.build(
|
15
|
+
price: 'item',
|
16
|
+
amount: 5.to_m,
|
17
|
+
data: { 'tax_code' => 101 }
|
18
|
+
)
|
19
|
+
]
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_adds_a_tax_price_adjustment_to_an_item
|
24
|
+
create_tax_category(code: '101')
|
25
|
+
|
26
|
+
applier = ItemTaxApplier.new(@address, @adjustments_to_tax)
|
27
|
+
applier.apply
|
28
|
+
|
29
|
+
price_adjustment = @item.price_adjustments.last
|
30
|
+
assert_equal('tax', price_adjustment.price)
|
31
|
+
assert_equal(0.3.to_m, price_adjustment.amount)
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_guards_against_negative_tax_amounts
|
35
|
+
create_tax_category(
|
36
|
+
code: '101',
|
37
|
+
rates: [{ percentage: -0.06, country: 'US', region: 'PA' }]
|
38
|
+
)
|
39
|
+
|
40
|
+
applier = ItemTaxApplier.new(@address, @adjustments_to_tax)
|
41
|
+
applier.apply
|
42
|
+
|
43
|
+
assert_equal(1, @item.price_adjustments.size)
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_with_multiple_tax_codes_and_discount
|
47
|
+
create_tax_category(
|
48
|
+
code: '101',
|
49
|
+
rates: [{ percentage: 0.07, country: 'US', region: 'PA' }]
|
50
|
+
)
|
51
|
+
|
52
|
+
create_tax_category(
|
53
|
+
code: '102',
|
54
|
+
rates: [{ percentage: 0.05, country: 'US', region: 'PA' }]
|
55
|
+
)
|
56
|
+
|
57
|
+
item_2 = Order::Item.new
|
58
|
+
@adjustments_to_tax.concat([
|
59
|
+
@item.price_adjustments.build(
|
60
|
+
price: 'item',
|
61
|
+
amount: -1.to_m,
|
62
|
+
data: { 'discount_value' => 1.to_m }
|
63
|
+
),
|
64
|
+
item_2.price_adjustments.build(
|
65
|
+
price: 'item',
|
66
|
+
amount: 10.to_m,
|
67
|
+
data: { 'tax_code' => 102 }
|
68
|
+
)
|
69
|
+
])
|
70
|
+
|
71
|
+
applier = ItemTaxApplier.new(@address, @adjustments_to_tax)
|
72
|
+
applier.apply
|
73
|
+
|
74
|
+
|
75
|
+
assert_equal(3, @item.price_adjustments.size)
|
76
|
+
assert_equal(0.28.to_m, @item.price_adjustments.last.amount)
|
77
|
+
|
78
|
+
assert_equal(2, item_2.price_adjustments.size)
|
79
|
+
assert_equal(0.50.to_m, item_2.price_adjustments.last.amount)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -53,6 +53,15 @@ module Workarea
|
|
53
53
|
price.on_sale = false
|
54
54
|
refute(price.on_sale?)
|
55
55
|
end
|
56
|
+
|
57
|
+
def test_unsupported_segmentation
|
58
|
+
price = Price.new(active_segment_ids: %w(foo bar))
|
59
|
+
refute(price.valid?)
|
60
|
+
assert_includes(
|
61
|
+
price.errors[:active_segment_ids],
|
62
|
+
t('workarea.errors.messages.unsupported_segmentation')
|
63
|
+
)
|
64
|
+
end
|
56
65
|
end
|
57
66
|
end
|
58
67
|
end
|
@@ -18,6 +18,11 @@ module Workarea
|
|
18
18
|
@order.add_item(product_id: 'PRODUCT', sku: 'SKU', quantity: 2)
|
19
19
|
@order.save!
|
20
20
|
|
21
|
+
@payment = create_payment(
|
22
|
+
id: @order.id,
|
23
|
+
address: factory_defaults_config.billing_address
|
24
|
+
)
|
25
|
+
|
21
26
|
@discount = create_product_discount(promo_codes: ['promo-code'])
|
22
27
|
|
23
28
|
@shipping = Shipping.create!(shipping_service: { name: 'Ground' })
|
@@ -81,6 +86,14 @@ module Workarea
|
|
81
86
|
|
82
87
|
assert @request.stale?
|
83
88
|
end
|
89
|
+
|
90
|
+
def test_payment_breaks_cache
|
91
|
+
@payment.address.street = '225 Arch St.'
|
92
|
+
@payment.save!
|
93
|
+
|
94
|
+
@request = Request.new(@order, @shipping)
|
95
|
+
assert @request.stale?
|
96
|
+
end
|
84
97
|
end
|
85
98
|
end
|
86
99
|
end
|
@@ -32,6 +32,15 @@ module Workarea
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
def test_unsupported_segmentation
|
36
|
+
sku = Sku.new(active_segment_ids: %w(foo bar))
|
37
|
+
refute(sku.valid?)
|
38
|
+
assert_includes(
|
39
|
+
sku.errors[:active_segment_ids],
|
40
|
+
t('workarea.errors.messages.unsupported_segmentation')
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
35
44
|
private
|
36
45
|
|
37
46
|
def configure_locales
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
class ReleasableActiveTest < TestCase
|
5
|
+
class Foo
|
6
|
+
include Mongoid::Document
|
7
|
+
include Mongoid::Timestamps
|
8
|
+
include Releasable
|
9
|
+
field :name, type: String
|
10
|
+
field :blank_field, type: String
|
11
|
+
field :slug, type: String
|
12
|
+
validates :name, presence: true
|
13
|
+
|
14
|
+
embeds_many :bars
|
15
|
+
embeds_one :baz
|
16
|
+
end
|
17
|
+
|
18
|
+
class Bar
|
19
|
+
include Mongoid::Document
|
20
|
+
include Releasable
|
21
|
+
field :name, type: String
|
22
|
+
embedded_in :foo
|
23
|
+
end
|
24
|
+
|
25
|
+
class Baz
|
26
|
+
include Mongoid::Document
|
27
|
+
include Releasable
|
28
|
+
field :name, type: String
|
29
|
+
embedded_in :foo
|
30
|
+
end
|
31
|
+
|
32
|
+
setup :set_release
|
33
|
+
|
34
|
+
def set_release
|
35
|
+
@release = create_release
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_save_can_schedule_activation
|
39
|
+
model = Foo.create!(
|
40
|
+
name: 'Test',
|
41
|
+
active: true,
|
42
|
+
activate_with: @release.id
|
43
|
+
)
|
44
|
+
|
45
|
+
model.reload
|
46
|
+
|
47
|
+
refute(model.active)
|
48
|
+
assert_equal(1, model.changesets.length)
|
49
|
+
assert_equal(@release.id, model.changesets.first.release_id)
|
50
|
+
assert_equal(1, model.changesets.first.changeset.size)
|
51
|
+
assert(model.changesets.first.changeset['active'][I18n.locale.to_s])
|
52
|
+
assert_equal(1, model.changesets.first.original.size)
|
53
|
+
refute(model.changesets.first.original['active'][I18n.locale.to_s])
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_save_can_schedule_activation_for_an_embedded_document
|
57
|
+
model = Foo.create!(name: 'Test')
|
58
|
+
|
59
|
+
embedded_1 = model.bars.create!(
|
60
|
+
name: 'Bar',
|
61
|
+
active: true,
|
62
|
+
activate_with: @release.id
|
63
|
+
)
|
64
|
+
|
65
|
+
embedded_2 = model.bars.create!(
|
66
|
+
name: 'Baz',
|
67
|
+
active: true,
|
68
|
+
activate_with: @release.id
|
69
|
+
)
|
70
|
+
|
71
|
+
model.reload
|
72
|
+
|
73
|
+
refute(embedded_1.active)
|
74
|
+
assert_equal(1, embedded_1.changesets.length)
|
75
|
+
assert_equal(@release.id, embedded_1.changesets.first.release_id)
|
76
|
+
assert_equal(1, embedded_1.changesets.first.changeset.size)
|
77
|
+
assert(embedded_1.changesets.first.changeset['active'][I18n.locale.to_s])
|
78
|
+
assert_equal(1, embedded_1.changesets.first.original.size)
|
79
|
+
refute(embedded_1.changesets.first.original['active'][I18n.locale.to_s])
|
80
|
+
|
81
|
+
refute(embedded_2.active)
|
82
|
+
assert_equal(1, embedded_2.changesets.length)
|
83
|
+
assert_equal(@release.id, embedded_2.changesets.first.release_id)
|
84
|
+
assert_equal(1, embedded_2.changesets.first.changeset.size)
|
85
|
+
assert(embedded_2.changesets.first.changeset['active'][I18n.locale.to_s])
|
86
|
+
assert_equal(1, embedded_2.changesets.first.original.size)
|
87
|
+
refute(embedded_2.changesets.first.original['active'][I18n.locale.to_s])
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_creating_and_activating_embedded
|
91
|
+
model = Foo.create!(name: 'Foo')
|
92
|
+
|
93
|
+
embedded = Release.with_current(@release.id) do
|
94
|
+
model.bars.create!(
|
95
|
+
name: 'Test',
|
96
|
+
active: true,
|
97
|
+
activate_with: @release.id
|
98
|
+
)
|
99
|
+
end
|
100
|
+
|
101
|
+
model.reload
|
102
|
+
|
103
|
+
refute(embedded.active)
|
104
|
+
assert_equal(1, embedded.changesets.length)
|
105
|
+
assert_equal(@release.id, embedded.changesets.first.release_id)
|
106
|
+
assert_equal(1, embedded.changesets.first.changeset.size)
|
107
|
+
assert(embedded.changesets.first.changeset['active'][I18n.locale.to_s])
|
108
|
+
assert_equal(1, embedded.changesets.first.original.size)
|
109
|
+
refute(embedded.changesets.first.original['active'][I18n.locale.to_s])
|
110
|
+
assert(embedded.changesets.first.document_path.present?)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|