workarea-core 3.4.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +52 -0
- data/README.md +19 -0
- data/Rakefile +23 -0
- data/app/assets/images/workarea/core/favicon_placeholder.png +0 -0
- data/app/assets/images/workarea/core/icon.svg +4 -0
- data/app/assets/images/workarea/core/open_graph_placeholder.png +0 -0
- data/app/assets/images/workarea/core/placeholder.png +0 -0
- data/app/assets/images/workarea/core/product_placeholder.jpg +0 -0
- data/app/assets/javascripts/workarea/core/config.js +59 -0
- data/app/assets/javascripts/workarea/core/modules/cookie.js +64 -0
- data/app/assets/javascripts/workarea/core/modules/date.js +111 -0
- data/app/assets/javascripts/workarea/core/modules/deletion_forms.js +45 -0
- data/app/assets/javascripts/workarea/core/modules/duplicate_id.js +78 -0
- data/app/assets/javascripts/workarea/core/modules/environment.js +23 -0
- data/app/assets/javascripts/workarea/core/modules/form_submitting_controls.js +52 -0
- data/app/assets/javascripts/workarea/core/modules/forms.js +14 -0
- data/app/assets/javascripts/workarea/core/modules/image.js +43 -0
- data/app/assets/javascripts/workarea/core/modules/jquery.js +34 -0
- data/app/assets/javascripts/workarea/core/modules/local_time.js +16 -0
- data/app/assets/javascripts/workarea/core/modules/reveal_password.js +47 -0
- data/app/assets/javascripts/workarea/core/modules/string.js +62 -0
- data/app/assets/javascripts/workarea/core/modules/style_guide_accordions.js +21 -0
- data/app/assets/javascripts/workarea/core/modules/style_guide_autocomplete_fields.js +42 -0
- data/app/assets/javascripts/workarea/core/modules/style_guide_empty_links.js +23 -0
- data/app/assets/javascripts/workarea/core/modules/transition_events.js +71 -0
- data/app/assets/javascripts/workarea/core/modules/url.js +123 -0
- data/app/assets/javascripts/workarea/core/routes.js +9 -0
- data/app/assets/javascripts/workarea/core/templates/hidden_input.jst.ejs +1 -0
- data/app/assets/javascripts/workarea/core/templates/lorem_ipsum_view.jst.ejs +6 -0
- data/app/assets/javascripts/workarea/core/templates/reveal_password_button.jst.ejs +4 -0
- data/app/assets/javascripts/workarea/core/templates/ui_menu_item.jst.ejs +10 -0
- data/app/assets/javascripts/workarea/core/workarea.js +63 -0
- data/app/controllers/workarea/admin_guest_browsing.rb +54 -0
- data/app/controllers/workarea/application_controller.rb +42 -0
- data/app/controllers/workarea/authentication.rb +117 -0
- data/app/controllers/workarea/authorization.rb +46 -0
- data/app/controllers/workarea/current_referrer.rb +14 -0
- data/app/controllers/workarea/current_release.rb +56 -0
- data/app/controllers/workarea/impersonation.rb +92 -0
- data/app/controllers/workarea/style_guides.rb +17 -0
- data/app/helpers/workarea/addresses_helper.rb +48 -0
- data/app/helpers/workarea/application_helper.rb +70 -0
- data/app/helpers/workarea/content_assets_helper.rb +22 -0
- data/app/helpers/workarea/details_helper.rb +12 -0
- data/app/helpers/workarea/facets_helper.rb +53 -0
- data/app/helpers/workarea/i18n_helper.rb +19 -0
- data/app/helpers/workarea/plugins_helper.rb +23 -0
- data/app/helpers/workarea/style_guides_helper.rb +88 -0
- data/app/mailers/workarea/application_mailer.rb +13 -0
- data/app/middleware/workarea/audit_log_client_middleware.rb +8 -0
- data/app/middleware/workarea/audit_log_server_middleware.rb +14 -0
- data/app/middleware/workarea/enforce_host_middleware.rb +39 -0
- data/app/middleware/workarea/i18n_client_middleware.rb +8 -0
- data/app/middleware/workarea/i18n_server_middleware.rb +11 -0
- data/app/middleware/workarea/rack_cache_config_middleware.rb +19 -0
- data/app/middleware/workarea/release_server_middleware.rb +11 -0
- data/app/middleware/workarea/skip_rack_cache_middleware.rb +19 -0
- data/app/middleware/workarea/strip_http_caching_middleware.rb +23 -0
- data/app/models/workarea/address.rb +149 -0
- data/app/models/workarea/application_document.rb +75 -0
- data/app/models/workarea/bulk_action.rb +82 -0
- data/app/models/workarea/bulk_action/deletion.rb +11 -0
- data/app/models/workarea/bulk_action/product_edit.rb +83 -0
- data/app/models/workarea/bulk_action/sequential_product_edit.rb +21 -0
- data/app/models/workarea/calculate_percent_change.rb +8 -0
- data/app/models/workarea/catalog/category.rb +31 -0
- data/app/models/workarea/catalog/clean_details.rb +18 -0
- data/app/models/workarea/catalog/customizations.rb +81 -0
- data/app/models/workarea/catalog/details_queries.rb +57 -0
- data/app/models/workarea/catalog/product.rb +154 -0
- data/app/models/workarea/catalog/product_image.rb +59 -0
- data/app/models/workarea/catalog/product_placeholder_image.rb +57 -0
- data/app/models/workarea/catalog/product_positions.rb +40 -0
- data/app/models/workarea/catalog/variant.rb +26 -0
- data/app/models/workarea/checkout.rb +234 -0
- data/app/models/workarea/checkout/auto_complete.rb +74 -0
- data/app/models/workarea/checkout/collect_payment.rb +40 -0
- data/app/models/workarea/checkout/credit_card_params.rb +54 -0
- data/app/models/workarea/checkout/shipping_options.rb +99 -0
- data/app/models/workarea/checkout/steps/addresses.rb +102 -0
- data/app/models/workarea/checkout/steps/base.rb +35 -0
- data/app/models/workarea/checkout/steps/payment.rb +71 -0
- data/app/models/workarea/checkout/steps/shipping.rb +82 -0
- data/app/models/workarea/comment.rb +15 -0
- data/app/models/workarea/commentable.rb +35 -0
- data/app/models/workarea/content.rb +231 -0
- data/app/models/workarea/content/asset.rb +162 -0
- data/app/models/workarea/content/asset_lookup.rb +14 -0
- data/app/models/workarea/content/block.rb +157 -0
- data/app/models/workarea/content/block_draft.rb +36 -0
- data/app/models/workarea/content/block_name.rb +45 -0
- data/app/models/workarea/content/block_type.rb +195 -0
- data/app/models/workarea/content/block_type_definition.rb +16 -0
- data/app/models/workarea/content/email.rb +31 -0
- data/app/models/workarea/content/field.rb +49 -0
- data/app/models/workarea/content/fields/asset.rb +15 -0
- data/app/models/workarea/content/fields/boolean.rb +11 -0
- data/app/models/workarea/content/fields/breakpoints.rb +11 -0
- data/app/models/workarea/content/fields/category.rb +8 -0
- data/app/models/workarea/content/fields/color.rb +11 -0
- data/app/models/workarea/content/fields/integer.rb +11 -0
- data/app/models/workarea/content/fields/options.rb +11 -0
- data/app/models/workarea/content/fields/products.rb +11 -0
- data/app/models/workarea/content/fields/range.rb +23 -0
- data/app/models/workarea/content/fields/string.rb +11 -0
- data/app/models/workarea/content/fields/taxonomy.rb +8 -0
- data/app/models/workarea/content/fields/text.rb +8 -0
- data/app/models/workarea/content/fields/url.rb +8 -0
- data/app/models/workarea/content/fieldset.rb +31 -0
- data/app/models/workarea/content/page.rb +18 -0
- data/app/models/workarea/content/preset.rb +66 -0
- data/app/models/workarea/contentable.rb +9 -0
- data/app/models/workarea/data_file/csv.rb +161 -0
- data/app/models/workarea/data_file/csv_fields.rb +82 -0
- data/app/models/workarea/data_file/export.rb +38 -0
- data/app/models/workarea/data_file/format.rb +85 -0
- data/app/models/workarea/data_file/import.rb +82 -0
- data/app/models/workarea/data_file/json.rb +56 -0
- data/app/models/workarea/data_file/operation.rb +71 -0
- data/app/models/workarea/data_file/tax_import.rb +33 -0
- data/app/models/workarea/data_file/tax_rates.rb +58 -0
- data/app/models/workarea/data_file/unknown_format_error.rb +5 -0
- data/app/models/workarea/details.rb +111 -0
- data/app/models/workarea/discount_ids.rb +34 -0
- data/app/models/workarea/email.rb +21 -0
- data/app/models/workarea/email/signup.rb +18 -0
- data/app/models/workarea/featured_products.rb +39 -0
- data/app/models/workarea/fulfillment.rb +166 -0
- data/app/models/workarea/fulfillment/event.rb +14 -0
- data/app/models/workarea/fulfillment/item.rb +27 -0
- data/app/models/workarea/fulfillment/package.rb +46 -0
- data/app/models/workarea/fulfillment/status.rb +55 -0
- data/app/models/workarea/guard_negative_price.rb +6 -0
- data/app/models/workarea/help/article.rb +71 -0
- data/app/models/workarea/help/asset.rb +26 -0
- data/app/models/workarea/inquiry.rb +30 -0
- data/app/models/workarea/insights/base.rb +66 -0
- data/app/models/workarea/insights/best_customers.rb +30 -0
- data/app/models/workarea/insights/best_full_price_customers.rb +31 -0
- data/app/models/workarea/insights/cold_products.rb +49 -0
- data/app/models/workarea/insights/cold_searches.rb +49 -0
- data/app/models/workarea/insights/customer_acquisition.rb +62 -0
- data/app/models/workarea/insights/customers_at_risk.rb +26 -0
- data/app/models/workarea/insights/hot_products.rb +49 -0
- data/app/models/workarea/insights/hot_searches.rb +49 -0
- data/app/models/workarea/insights/low_aov_customers.rb +27 -0
- data/app/models/workarea/insights/most_discount_given.rb +52 -0
- data/app/models/workarea/insights/most_discounted_products.rb +25 -0
- data/app/models/workarea/insights/new_products.rb +33 -0
- data/app/models/workarea/insights/non_sellers.rb +25 -0
- data/app/models/workarea/insights/popular_searches.rb +29 -0
- data/app/models/workarea/insights/popular_searches_without_results.rb +30 -0
- data/app/models/workarea/insights/products_purchased_together.rb +30 -0
- data/app/models/workarea/insights/products_to_improve.rb +44 -0
- data/app/models/workarea/insights/promising_products.rb +47 -0
- data/app/models/workarea/insights/release_reminder.rb +20 -0
- data/app/models/workarea/insights/repeat_purchase_rate.rb +38 -0
- data/app/models/workarea/insights/sales_by_navigation.rb +50 -0
- data/app/models/workarea/insights/searches_to_improve.rb +44 -0
- data/app/models/workarea/insights/star_products.rb +30 -0
- data/app/models/workarea/insights/star_searches.rb +30 -0
- data/app/models/workarea/insights/top_categories.rb +51 -0
- data/app/models/workarea/insights/top_discounts.rb +51 -0
- data/app/models/workarea/insights/top_products.rb +51 -0
- data/app/models/workarea/insights/trending_products.rb +69 -0
- data/app/models/workarea/insights/trending_searches.rb +69 -0
- data/app/models/workarea/insights/upcoming_releases.rb +20 -0
- data/app/models/workarea/invalid_display.rb +3 -0
- data/app/models/workarea/inventory.rb +72 -0
- data/app/models/workarea/inventory/capture.rb +100 -0
- data/app/models/workarea/inventory/collection.rb +50 -0
- data/app/models/workarea/inventory/policies/allow_backorder.rb +38 -0
- data/app/models/workarea/inventory/policies/base.rb +44 -0
- data/app/models/workarea/inventory/policies/displayable_when_out_of_stock.rb +11 -0
- data/app/models/workarea/inventory/policies/ignore.rb +20 -0
- data/app/models/workarea/inventory/policies/standard.rb +23 -0
- data/app/models/workarea/inventory/sku.rb +158 -0
- data/app/models/workarea/inventory/transaction.rb +102 -0
- data/app/models/workarea/inventory/transaction_item.rb +19 -0
- data/app/models/workarea/inventory/unit_of_work.rb +81 -0
- data/app/models/workarea/lock.rb +75 -0
- data/app/models/workarea/lockable.rb +58 -0
- data/app/models/workarea/metrics/by_day.rb +59 -0
- data/app/models/workarea/metrics/by_week.rb +36 -0
- data/app/models/workarea/metrics/calculate_percentiles.rb +42 -0
- data/app/models/workarea/metrics/category_by_day.rb +21 -0
- data/app/models/workarea/metrics/country_by_day.rb +20 -0
- data/app/models/workarea/metrics/discount_by_day.rb +17 -0
- data/app/models/workarea/metrics/menu_by_day.rb +21 -0
- data/app/models/workarea/metrics/product_by_day.rb +22 -0
- data/app/models/workarea/metrics/product_by_week.rb +32 -0
- data/app/models/workarea/metrics/product_for_last_week.rb +185 -0
- data/app/models/workarea/metrics/revenue_change.rb +39 -0
- data/app/models/workarea/metrics/sales_by_day.rb +20 -0
- data/app/models/workarea/metrics/scoring.rb +30 -0
- data/app/models/workarea/metrics/search_by_day.rb +35 -0
- data/app/models/workarea/metrics/search_by_week.rb +36 -0
- data/app/models/workarea/metrics/search_for_last_week.rb +192 -0
- data/app/models/workarea/metrics/sku_by_day.rb +19 -0
- data/app/models/workarea/metrics/traffic_referrer_by_day.rb +20 -0
- data/app/models/workarea/metrics/user.rb +128 -0
- data/app/models/workarea/navigable.rb +46 -0
- data/app/models/workarea/navigation/breadcrumbs.rb +58 -0
- data/app/models/workarea/navigation/menu.rb +30 -0
- data/app/models/workarea/navigation/redirect.rb +61 -0
- data/app/models/workarea/navigation/search_results.rb +49 -0
- data/app/models/workarea/navigation/taxon.rb +150 -0
- data/app/models/workarea/navigation/taxon_cache.rb +43 -0
- data/app/models/workarea/normalize_email.rb +13 -0
- data/app/models/workarea/order.rb +335 -0
- data/app/models/workarea/order/item.rb +139 -0
- data/app/models/workarea/order/items_extension.rb +14 -0
- data/app/models/workarea/order/queries.rb +200 -0
- data/app/models/workarea/order/status.rb +48 -0
- data/app/models/workarea/ordering.rb +47 -0
- data/app/models/workarea/payment.rb +179 -0
- data/app/models/workarea/payment/address.rb +9 -0
- data/app/models/workarea/payment/authorize/credit_card.rb +42 -0
- data/app/models/workarea/payment/authorize/store_credit.rb +43 -0
- data/app/models/workarea/payment/capture.rb +43 -0
- data/app/models/workarea/payment/capture/credit_card.rb +25 -0
- data/app/models/workarea/payment/capture/store_credit.rb +25 -0
- data/app/models/workarea/payment/credit_card.rb +120 -0
- data/app/models/workarea/payment/credit_card_operation.rb +20 -0
- data/app/models/workarea/payment/insufficient_funds.rb +5 -0
- data/app/models/workarea/payment/operation.rb +50 -0
- data/app/models/workarea/payment/operation_implementation.rb +24 -0
- data/app/models/workarea/payment/processing.rb +102 -0
- data/app/models/workarea/payment/profile.rb +59 -0
- data/app/models/workarea/payment/purchase/credit_card.rb +42 -0
- data/app/models/workarea/payment/purchase/store_credit.rb +7 -0
- data/app/models/workarea/payment/refund.rb +44 -0
- data/app/models/workarea/payment/refund/credit_card.rb +25 -0
- data/app/models/workarea/payment/refund/store_credit.rb +35 -0
- data/app/models/workarea/payment/saved_credit_card.rb +43 -0
- data/app/models/workarea/payment/status.rb +74 -0
- data/app/models/workarea/payment/store_credit_card.rb +34 -0
- data/app/models/workarea/payment/tender.rb +80 -0
- data/app/models/workarea/payment/tender/credit_card.rb +49 -0
- data/app/models/workarea/payment/tender/store_credit.rb +27 -0
- data/app/models/workarea/payment/transaction.rb +148 -0
- data/app/models/workarea/payment_reference.rb +18 -0
- data/app/models/workarea/price_adjustment.rb +46 -0
- data/app/models/workarea/price_adjustment_extension.rb +19 -0
- data/app/models/workarea/price_adjustment_set.rb +69 -0
- data/app/models/workarea/pricing.rb +56 -0
- data/app/models/workarea/pricing/cache_key.rb +51 -0
- data/app/models/workarea/pricing/calculator.rb +37 -0
- data/app/models/workarea/pricing/calculators/customizations_calculator.rb +33 -0
- data/app/models/workarea/pricing/calculators/discount_calculator.rb +38 -0
- data/app/models/workarea/pricing/calculators/item_calculator.rb +28 -0
- data/app/models/workarea/pricing/calculators/overrides_calculator.rb +105 -0
- data/app/models/workarea/pricing/calculators/tax_calculator.rb +29 -0
- data/app/models/workarea/pricing/collection.rb +84 -0
- data/app/models/workarea/pricing/discount.rb +370 -0
- data/app/models/workarea/pricing/discount/amount_calculator.rb +57 -0
- data/app/models/workarea/pricing/discount/application_group.rb +126 -0
- data/app/models/workarea/pricing/discount/buy_some_get_some.rb +120 -0
- data/app/models/workarea/pricing/discount/buy_some_get_some/item_application.rb +65 -0
- data/app/models/workarea/pricing/discount/buy_some_get_some/order_items_by_product.rb +38 -0
- data/app/models/workarea/pricing/discount/buy_some_get_some/product_application.rb +83 -0
- data/app/models/workarea/pricing/discount/category.rb +59 -0
- data/app/models/workarea/pricing/discount/code_list.rb +100 -0
- data/app/models/workarea/pricing/discount/collection.rb +61 -0
- data/app/models/workarea/pricing/discount/conditions/item_quantity.rb +42 -0
- data/app/models/workarea/pricing/discount/conditions/order_total.rb +53 -0
- data/app/models/workarea/pricing/discount/conditions/promo_codes.rb +78 -0
- data/app/models/workarea/pricing/discount/conditions/user_tags.rb +36 -0
- data/app/models/workarea/pricing/discount/flat_or_percent_off.rb +47 -0
- data/app/models/workarea/pricing/discount/free_gift.rb +136 -0
- data/app/models/workarea/pricing/discount/generated_promo_code.rb +96 -0
- data/app/models/workarea/pricing/discount/order.rb +104 -0
- data/app/models/workarea/pricing/discount/order_total.rb +52 -0
- data/app/models/workarea/pricing/discount/product.rb +60 -0
- data/app/models/workarea/pricing/discount/product_attribute.rb +65 -0
- data/app/models/workarea/pricing/discount/product_attribute/item_qualifier.rb +52 -0
- data/app/models/workarea/pricing/discount/quantity_fixed_price.rb +102 -0
- data/app/models/workarea/pricing/discount/quantity_fixed_price/application_calculator.rb +57 -0
- data/app/models/workarea/pricing/discount/quantity_fixed_price/item_shares.rb +64 -0
- data/app/models/workarea/pricing/discount/reconcile_total.rb +39 -0
- data/app/models/workarea/pricing/discount/redemption.rb +33 -0
- data/app/models/workarea/pricing/discount/shipping.rb +80 -0
- data/app/models/workarea/pricing/order_totals.rb +56 -0
- data/app/models/workarea/pricing/override.rb +36 -0
- data/app/models/workarea/pricing/price.rb +52 -0
- data/app/models/workarea/pricing/price_distributor.rb +88 -0
- data/app/models/workarea/pricing/request.rb +146 -0
- data/app/models/workarea/pricing/shipping_totals.rb +27 -0
- data/app/models/workarea/pricing/sku.rb +88 -0
- data/app/models/workarea/pricing/tax_applier.rb +90 -0
- data/app/models/workarea/product_list.rb +11 -0
- data/app/models/workarea/product_rule.rb +139 -0
- data/app/models/workarea/query_string.rb +58 -0
- data/app/models/workarea/recommendation/product_predictor.rb +10 -0
- data/app/models/workarea/recommendation/search_predictor.rb +10 -0
- data/app/models/workarea/recommendation/settings.rb +24 -0
- data/app/models/workarea/recommendation/user_activity.rb +53 -0
- data/app/models/workarea/releasable.rb +171 -0
- data/app/models/workarea/release.rb +232 -0
- data/app/models/workarea/release/changeset.rb +137 -0
- data/app/models/workarea/release/status.rb +52 -0
- data/app/models/workarea/release_session.rb +45 -0
- data/app/models/workarea/reports/export.rb +62 -0
- data/app/models/workarea/search/admin.rb +133 -0
- data/app/models/workarea/search/admin/catalog_category.rb +67 -0
- data/app/models/workarea/search/admin/catalog_product.rb +98 -0
- data/app/models/workarea/search/admin/content.rb +37 -0
- data/app/models/workarea/search/admin/content_asset.rb +46 -0
- data/app/models/workarea/search/admin/content_page.rb +25 -0
- data/app/models/workarea/search/admin/inventory_sku.rb +27 -0
- data/app/models/workarea/search/admin/navigation.rb +50 -0
- data/app/models/workarea/search/admin/navigation_menu.rb +13 -0
- data/app/models/workarea/search/admin/order.rb +74 -0
- data/app/models/workarea/search/admin/payment_transaction.rb +68 -0
- data/app/models/workarea/search/admin/pricing_discount.rb +37 -0
- data/app/models/workarea/search/admin/pricing_sku.rb +25 -0
- data/app/models/workarea/search/admin/releasable.rb +41 -0
- data/app/models/workarea/search/admin/release.rb +38 -0
- data/app/models/workarea/search/admin/user.rb +59 -0
- data/app/models/workarea/search/customization.rb +81 -0
- data/app/models/workarea/search/facet_values.rb +16 -0
- data/app/models/workarea/search/hash_text.rb +32 -0
- data/app/models/workarea/search/help.rb +17 -0
- data/app/models/workarea/search/order_text.rb +75 -0
- data/app/models/workarea/search/settings.rb +79 -0
- data/app/models/workarea/search/storefront.rb +101 -0
- data/app/models/workarea/search/storefront/category.rb +19 -0
- data/app/models/workarea/search/storefront/page.rb +19 -0
- data/app/models/workarea/search/storefront/product.rb +133 -0
- data/app/models/workarea/search/storefront/product/analytics.rb +26 -0
- data/app/models/workarea/search/storefront/product/categories.rb +86 -0
- data/app/models/workarea/search/storefront/product/facets.rb +62 -0
- data/app/models/workarea/search/storefront/product/inventory.rb +34 -0
- data/app/models/workarea/search/storefront/product/pricing.rb +56 -0
- data/app/models/workarea/search/storefront/product/sorting.rb +25 -0
- data/app/models/workarea/search/storefront/product/text.rb +71 -0
- data/app/models/workarea/search/storefront/search.rb +27 -0
- data/app/models/workarea/search/user_text.rb +45 -0
- data/app/models/workarea/shipping.rb +176 -0
- data/app/models/workarea/shipping/address.rb +22 -0
- data/app/models/workarea/shipping/location_query.rb +49 -0
- data/app/models/workarea/shipping/rate.rb +19 -0
- data/app/models/workarea/shipping/rate_lookup.rb +55 -0
- data/app/models/workarea/shipping/service.rb +89 -0
- data/app/models/workarea/shipping/service_selection.rb +15 -0
- data/app/models/workarea/shipping/sku.rb +35 -0
- data/app/models/workarea/shipping_option.rb +53 -0
- data/app/models/workarea/sort.rb +153 -0
- data/app/models/workarea/status_calculator.rb +40 -0
- data/app/models/workarea/tax.rb +29 -0
- data/app/models/workarea/tax/category.rb +48 -0
- data/app/models/workarea/tax/rate.rb +30 -0
- data/app/models/workarea/tax/rate_lookup.rb +107 -0
- data/app/models/workarea/traffic_referrer.rb +9 -0
- data/app/models/workarea/user.rb +90 -0
- data/app/models/workarea/user/addresses.rb +51 -0
- data/app/models/workarea/user/admin_bookmark.rb +40 -0
- data/app/models/workarea/user/admin_visit.rb +39 -0
- data/app/models/workarea/user/authorization.rb +72 -0
- data/app/models/workarea/user/avatar.rb +32 -0
- data/app/models/workarea/user/login.rb +76 -0
- data/app/models/workarea/user/password_reset.rb +37 -0
- data/app/models/workarea/user/passwords.rb +67 -0
- data/app/models/workarea/user/recent_password.rb +27 -0
- data/app/models/workarea/user/saved_address.rb +13 -0
- data/app/models/workarea/user/system_users.rb +30 -0
- data/app/queries/workarea/admin_query_operation.rb +58 -0
- data/app/queries/workarea/admin_search_query_wrapper.rb +68 -0
- data/app/queries/workarea/alerts.rb +82 -0
- data/app/queries/workarea/bulk_action_selections.rb +39 -0
- data/app/queries/workarea/categorization.rb +63 -0
- data/app/queries/workarea/extract_content_block_text.rb +33 -0
- data/app/queries/workarea/find_pipeline_asset.rb +30 -0
- data/app/queries/workarea/find_taxonomy_slug.rb +24 -0
- data/app/queries/workarea/find_unique_slug.rb +35 -0
- data/app/queries/workarea/metadata.rb +56 -0
- data/app/queries/workarea/metadata/catalog_category.rb +45 -0
- data/app/queries/workarea/metadata/content_page.rb +37 -0
- data/app/queries/workarea/metadata/home_page.rb +48 -0
- data/app/queries/workarea/order_item_details.rb +55 -0
- data/app/queries/workarea/order_metrics.rb +203 -0
- data/app/queries/workarea/pricing_override_params.rb +31 -0
- data/app/queries/workarea/product_primary_image_url.rb +34 -0
- data/app/queries/workarea/product_primary_navigation.rb +41 -0
- data/app/queries/workarea/recommendation/order_based.rb +48 -0
- data/app/queries/workarea/recommendation/product_based.rb +47 -0
- data/app/queries/workarea/recommendation/searches.rb +21 -0
- data/app/queries/workarea/recommendation/user_activity_based.rb +40 -0
- data/app/queries/workarea/reports/average_order_value.rb +44 -0
- data/app/queries/workarea/reports/customers.rb +46 -0
- data/app/queries/workarea/reports/first_time_vs_returning_sales.rb +59 -0
- data/app/queries/workarea/reports/group_by_time.rb +84 -0
- data/app/queries/workarea/reports/low_inventory.rb +36 -0
- data/app/queries/workarea/reports/report.rb +83 -0
- data/app/queries/workarea/reports/sales_by_category.rb +51 -0
- data/app/queries/workarea/reports/sales_by_country.rb +56 -0
- data/app/queries/workarea/reports/sales_by_discount.rb +47 -0
- data/app/queries/workarea/reports/sales_by_menu.rb +51 -0
- data/app/queries/workarea/reports/sales_by_product.rb +54 -0
- data/app/queries/workarea/reports/sales_by_sku.rb +61 -0
- data/app/queries/workarea/reports/sales_by_traffic_referrer.rb +64 -0
- data/app/queries/workarea/reports/sales_over_time.rb +73 -0
- data/app/queries/workarea/reports/searches.rb +65 -0
- data/app/queries/workarea/reports/searches_over_time.rb +37 -0
- data/app/queries/workarea/reports/searches_without_results_over_time.rb +38 -0
- data/app/queries/workarea/search/admin_assets.rb +23 -0
- data/app/queries/workarea/search/admin_categories.rb +20 -0
- data/app/queries/workarea/search/admin_discounts.rb +30 -0
- data/app/queries/workarea/search/admin_index_search.rb +127 -0
- data/app/queries/workarea/search/admin_inventory_skus.rb +20 -0
- data/app/queries/workarea/search/admin_orders.rb +49 -0
- data/app/queries/workarea/search/admin_pages.rb +16 -0
- data/app/queries/workarea/search/admin_payment_transactions.rb +24 -0
- data/app/queries/workarea/search/admin_pricing_skus.rb +16 -0
- data/app/queries/workarea/search/admin_product_rules_preview.rb +10 -0
- data/app/queries/workarea/search/admin_products.rb +39 -0
- data/app/queries/workarea/search/admin_releasables.rb +18 -0
- data/app/queries/workarea/search/admin_releases.rb +38 -0
- data/app/queries/workarea/search/admin_search.rb +16 -0
- data/app/queries/workarea/search/admin_sorting.rb +38 -0
- data/app/queries/workarea/search/admin_users.rb +39 -0
- data/app/queries/workarea/search/categorization.rb +14 -0
- data/app/queries/workarea/search/categorization_filtering.rb +38 -0
- data/app/queries/workarea/search/category_browse.rb +119 -0
- data/app/queries/workarea/search/date_filter.rb +49 -0
- data/app/queries/workarea/search/facet.rb +71 -0
- data/app/queries/workarea/search/facet_matches.rb +39 -0
- data/app/queries/workarea/search/facet_sorting.rb +67 -0
- data/app/queries/workarea/search/facet_sorting/size.rb +15 -0
- data/app/queries/workarea/search/facets.rb +29 -0
- data/app/queries/workarea/search/filter.rb +70 -0
- data/app/queries/workarea/search/help_search.rb +58 -0
- data/app/queries/workarea/search/load_product_results.rb +36 -0
- data/app/queries/workarea/search/pagination.rb +46 -0
- data/app/queries/workarea/search/product_display_rules.rb +68 -0
- data/app/queries/workarea/search/product_entries.rb +24 -0
- data/app/queries/workarea/search/product_rules.rb +122 -0
- data/app/queries/workarea/search/product_rules_filtering.rb +14 -0
- data/app/queries/workarea/search/product_search.rb +218 -0
- data/app/queries/workarea/search/query.rb +131 -0
- data/app/queries/workarea/search/query_suggestions.rb +71 -0
- data/app/queries/workarea/search/range_facet.rb +60 -0
- data/app/queries/workarea/search/range_filter.rb +25 -0
- data/app/queries/workarea/search/range_parameter.rb +71 -0
- data/app/queries/workarea/search/related_help.rb +58 -0
- data/app/queries/workarea/search/related_products.rb +96 -0
- data/app/queries/workarea/search/search_suggestions.rb +43 -0
- data/app/queries/workarea/search/storefront_search.rb +51 -0
- data/app/queries/workarea/search/storefront_search/exact_matches.rb +34 -0
- data/app/queries/workarea/search/storefront_search/middleware.rb +26 -0
- data/app/queries/workarea/search/storefront_search/product_auto_redirect.rb +19 -0
- data/app/queries/workarea/search/storefront_search/product_multipass.rb +50 -0
- data/app/queries/workarea/search/storefront_search/redirect.rb +17 -0
- data/app/queries/workarea/search/storefront_search/response.rb +72 -0
- data/app/queries/workarea/search/storefront_search/spelling_correction.rb +31 -0
- data/app/queries/workarea/search/storefront_search/template.rb +17 -0
- data/app/queries/workarea/search/term_filter.rb +10 -0
- data/app/queries/workarea/search/terms_facet.rb +62 -0
- data/app/queries/workarea/taxonomy_sitemap.rb +34 -0
- data/app/seeds/workarea/admins_seeds.rb +53 -0
- data/app/seeds/workarea/assets_seeds.rb +23 -0
- data/app/seeds/workarea/browse_navigation_seeds.rb +30 -0
- data/app/seeds/workarea/browsing_pages_seeds.rb +33 -0
- data/app/seeds/workarea/categories_seeds.rb +50 -0
- data/app/seeds/workarea/customer_service_navigation_seeds.rb +16 -0
- data/app/seeds/workarea/customer_service_pages_seeds.rb +33 -0
- data/app/seeds/workarea/customers_seeds.rb +24 -0
- data/app/seeds/workarea/discounts_seeds.rb +79 -0
- data/app/seeds/workarea/dynamic_content_seeds.rb +62 -0
- data/app/seeds/workarea/email_content_seeds.rb +11 -0
- data/app/seeds/workarea/help_seeds.rb +65 -0
- data/app/seeds/workarea/inquiries_seeds.rb +15 -0
- data/app/seeds/workarea/insights_seeds.rb +65 -0
- data/app/seeds/workarea/orders_seeds.rb +113 -0
- data/app/seeds/workarea/products_seeds.rb +104 -0
- data/app/seeds/workarea/search_settings_seeds.rb +31 -0
- data/app/seeds/workarea/shipping_services_seeds.rb +61 -0
- data/app/seeds/workarea/system_content_seeds.rb +90 -0
- data/app/seeds/workarea/tax_seeds.rb +33 -0
- data/app/services/workarea/add_multiple_cart_items.rb +21 -0
- data/app/services/workarea/add_multiple_cart_items/item.rb +79 -0
- data/app/services/workarea/cancel_order.rb +68 -0
- data/app/services/workarea/cart_cleaner.rb +59 -0
- data/app/services/workarea/clean_range_facets.rb +38 -0
- data/app/services/workarea/copy_order.rb +73 -0
- data/app/services/workarea/copy_product.rb +27 -0
- data/app/services/workarea/create_fulfillment.rb +24 -0
- data/app/services/workarea/direct_upload.rb +77 -0
- data/app/services/workarea/direct_upload/asset.rb +14 -0
- data/app/services/workarea/direct_upload/processor.rb +20 -0
- data/app/services/workarea/direct_upload/product_image.rb +42 -0
- data/app/services/workarea/export_report.rb +88 -0
- data/app/services/workarea/hash_update.rb +32 -0
- data/app/services/workarea/inventory_adjustment.rb +45 -0
- data/app/services/workarea/login.rb +39 -0
- data/app/services/workarea/new_discount.rb +17 -0
- data/app/services/workarea/order_merge.rb +34 -0
- data/app/services/workarea/packaging.rb +103 -0
- data/app/services/workarea/save_publishing.rb +34 -0
- data/app/services/workarea/save_taxonomy.rb +39 -0
- data/app/services/workarea/set_navigable.rb +71 -0
- data/app/services/workarea/sort_navigation_menus_by_orders.rb +32 -0
- data/app/services/workarea/tag_update.rb +15 -0
- data/app/view_models/workarea/application_view_model.rb +72 -0
- data/app/view_models/workarea/shipping_carrier_view_model.rb +24 -0
- data/app/workers/sidekiq/callbacks.rb +242 -0
- data/app/workers/sidekiq/callbacks_worker.rb +73 -0
- data/app/workers/workarea/bulk_index_admin.rb +34 -0
- data/app/workers/workarea/bulk_index_products.rb +28 -0
- data/app/workers/workarea/bulk_index_searches.rb +33 -0
- data/app/workers/workarea/bust_discount_cache.rb +16 -0
- data/app/workers/workarea/bust_navigation_cache.rb +18 -0
- data/app/workers/workarea/bust_sku_cache.rb +16 -0
- data/app/workers/workarea/clean_inventory_transactions.rb +9 -0
- data/app/workers/workarea/clean_orders.rb +10 -0
- data/app/workers/workarea/clean_product_recommendations.rb +13 -0
- data/app/workers/workarea/clean_user_activity.rb +11 -0
- data/app/workers/workarea/deactivate_stale_discounts.rb +38 -0
- data/app/workers/workarea/generate_content_metadata.rb +17 -0
- data/app/workers/workarea/generate_insights.rb +37 -0
- data/app/workers/workarea/generate_promo_codes.rb +12 -0
- data/app/workers/workarea/index_admin_search.rb +40 -0
- data/app/workers/workarea/index_categorization.rb +24 -0
- data/app/workers/workarea/index_category.rb +20 -0
- data/app/workers/workarea/index_category_changes.rb +40 -0
- data/app/workers/workarea/index_fulfillment_changes.rb +16 -0
- data/app/workers/workarea/index_help.rb +18 -0
- data/app/workers/workarea/index_page.rb +20 -0
- data/app/workers/workarea/index_payment_transactions.rb +23 -0
- data/app/workers/workarea/index_product.rb +26 -0
- data/app/workers/workarea/index_product_children.rb +20 -0
- data/app/workers/workarea/index_product_rule.rb +22 -0
- data/app/workers/workarea/index_search_customizations.rb +18 -0
- data/app/workers/workarea/index_skus.rb +20 -0
- data/app/workers/workarea/keep_product_index_fresh.rb +32 -0
- data/app/workers/workarea/mark_discounts_as_redeemed.rb +30 -0
- data/app/workers/workarea/order_reminder.rb +16 -0
- data/app/workers/workarea/process_direct_upload.rb +10 -0
- data/app/workers/workarea/process_export.rb +21 -0
- data/app/workers/workarea/process_import.rb +29 -0
- data/app/workers/workarea/process_product_recommendations.rb +31 -0
- data/app/workers/workarea/process_reports_export.rb +20 -0
- data/app/workers/workarea/process_search_recommendations.rb +35 -0
- data/app/workers/workarea/publish_bulk_action.rb +14 -0
- data/app/workers/workarea/publish_release.rb +15 -0
- data/app/workers/workarea/redirect_navigable_slugs.rb +51 -0
- data/app/workers/workarea/save_order_metrics.rb +105 -0
- data/app/workers/workarea/save_user_order_details.rb +72 -0
- data/app/workers/workarea/send_refund_email.rb +17 -0
- data/app/workers/workarea/status_reporter.rb +12 -0
- data/app/workers/workarea/undo_release.rb +15 -0
- data/app/workers/workarea/update_elasticsearch_settings.rb +28 -0
- data/app/workers/workarea/update_payment_profile_email.rb +22 -0
- data/app/workers/workarea/verify_scheduled_releases.rb +35 -0
- data/bin/rails +18 -0
- data/config/i18n-js.yml +2 -0
- data/config/initializers/00_mongoid.rb +2 -0
- data/config/initializers/01_eager_load.rb +1 -0
- data/config/initializers/02_assets.rb +17 -0
- data/config/initializers/03_js_routes.rb +3 -0
- data/config/initializers/04_sidekiq.rb +1 -0
- data/config/initializers/05_scheduled_jobs.rb +92 -0
- data/config/initializers/06_predictor.rb +1 -0
- data/config/initializers/07_dragonfly.rb +117 -0
- data/config/initializers/08_inflections.rb +3 -0
- data/config/initializers/09_geocoder.rb +15 -0
- data/config/initializers/10_rack_middleware.rb +29 -0
- data/config/initializers/11_payment.rb +8 -0
- data/config/initializers/12_filter_parameters.rb +13 -0
- data/config/initializers/13_rack_attack.rb +178 -0
- data/config/initializers/14_content_block_types.rb +240 -0
- data/config/initializers/15_endpoint_monitoring.rb +41 -0
- data/config/initializers/16_turbolinks.rb +1 -0
- data/config/initializers/17_audit_log.rb +1 -0
- data/config/initializers/18_time_formats.rb +11 -0
- data/config/initializers/19_mailer_previews.rb +20 -0
- data/config/initializers/20_i18n_js.rb +3 -0
- data/config/initializers/20_mail_interceptor.rb +1 -0
- data/config/initializers/21_premailer.rb +3 -0
- data/config/initializers/21_serviceworkers.rb +16 -0
- data/config/initializers/22_session_store.rb +11 -0
- data/config/initializers/23_chartkick.rb +3 -0
- data/config/locales/en.yml +168 -0
- data/config/routes.rb +13 -0
- data/data/content_assets/100x100.png +0 -0
- data/data/content_assets/960x470_dark.png +0 -0
- data/data/content_assets/960x470_light.png +0 -0
- data/data/help/howto/add_help_articles/body.md +50 -0
- data/data/help/howto/add_help_articles/summary.md +1 -0
- data/lib/generators/workarea/content_block_type/USAGE +16 -0
- data/lib/generators/workarea/content_block_type/content_block_type_generator.rb +71 -0
- data/lib/generators/workarea/content_block_type/templates/block.svg +1 -0
- data/lib/generators/workarea/content_block_type/templates/initializer.rb +3 -0
- data/lib/generators/workarea/content_block_type/templates/storefront_view.html.haml.erb +4 -0
- data/lib/generators/workarea/content_block_type/templates/stylesheet.scss.erb +7 -0
- data/lib/generators/workarea/content_block_type/templates/view_model.rb.erb +16 -0
- data/lib/generators/workarea/decorator/USAGE +15 -0
- data/lib/generators/workarea/decorator/decorator_generator.rb +79 -0
- data/lib/generators/workarea/decorator/templates/decorator.rb.erb +20 -0
- data/lib/generators/workarea/decorator/templates/test_decorator.rb.erb +13 -0
- data/lib/generators/workarea/discount/USAGE +16 -0
- data/lib/generators/workarea/discount/discount_generator.rb +48 -0
- data/lib/generators/workarea/discount/templates/model.rb.erb +22 -0
- data/lib/generators/workarea/discount/templates/model_test.rb.erb +13 -0
- data/lib/generators/workarea/discount/templates/partial.html.haml +10 -0
- data/lib/generators/workarea/discount/templates/select_type_partial.rb.erb +6 -0
- data/lib/generators/workarea/discount/templates/view_model.rb.erb +11 -0
- data/lib/generators/workarea/discount/templates/view_model_test.rb.erb +11 -0
- data/lib/generators/workarea/docker/USAGE +16 -0
- data/lib/generators/workarea/docker/docker_generator.rb +61 -0
- data/lib/generators/workarea/docker/templates/.env.erb +6 -0
- data/lib/generators/workarea/docker/templates/Dockerfile.erb +48 -0
- data/lib/generators/workarea/docker/templates/docker-compose.yml.erb +72 -0
- data/lib/generators/workarea/docker/templates/docker-entrypoint.sh.erb +6 -0
- data/lib/generators/workarea/docker/templates/docker-sync.yml.erb +8 -0
- data/lib/generators/workarea/docker/templates/docker-wait.sh +11 -0
- data/lib/generators/workarea/docker/templates/docker.env +16 -0
- data/lib/generators/workarea/docker/templates/docker_init.rb.erb +29 -0
- data/lib/generators/workarea/install/USAGE +19 -0
- data/lib/generators/workarea/install/install_generator.rb +71 -0
- data/lib/generators/workarea/install/templates/initializer.rb.erb +22 -0
- data/lib/generators/workarea/js_adapter/USAGE +8 -0
- data/lib/generators/workarea/js_adapter/js_adapter_generator.rb +28 -0
- data/lib/generators/workarea/js_adapter/templates/js_adapter.js.erb +21 -0
- data/lib/generators/workarea/js_module/USAGE +8 -0
- data/lib/generators/workarea/js_module/js_module_generator.rb +30 -0
- data/lib/generators/workarea/js_module/templates/js_module.js.erb +33 -0
- data/lib/generators/workarea/override/USAGE +22 -0
- data/lib/generators/workarea/override/override_generator.rb +85 -0
- data/lib/generators/workarea/pricing_calculator/USAGE +9 -0
- data/lib/generators/workarea/pricing_calculator/pricing_calculator_generator.rb +26 -0
- data/lib/generators/workarea/pricing_calculator/templates/calculator.rb.erb +13 -0
- data/lib/generators/workarea/pricing_calculator/templates/test.rb.erb +13 -0
- data/lib/generators/workarea/product_template/USAGE +11 -0
- data/lib/generators/workarea/product_template/product_template_generator.rb +26 -0
- data/lib/generators/workarea/product_template/templates/view_model.rb.erb +16 -0
- data/lib/generators/workarea/seeds/USAGE +11 -0
- data/lib/generators/workarea/seeds/seeds_generator.rb +15 -0
- data/lib/generators/workarea/seeds/templates/seeds.rb.erb +15 -0
- data/lib/generators/workarea/style_guide/USAGE +24 -0
- data/lib/generators/workarea/style_guide/style_guide_generator.rb +35 -0
- data/lib/generators/workarea/style_guide/templates/style_guide_partial.html.haml.erb +51 -0
- data/lib/minitest/workarea_plugin.rb +11 -0
- data/lib/tasks/assets.rake +3 -0
- data/lib/tasks/cache.rake +40 -0
- data/lib/tasks/cleanup.rake +13 -0
- data/lib/tasks/help.rake +59 -0
- data/lib/tasks/insights.rake +49 -0
- data/lib/tasks/lint.rake +7 -0
- data/lib/tasks/search.rake +89 -0
- data/lib/tasks/services.rake +73 -0
- data/lib/tasks/tests.rake +96 -0
- data/lib/workarea.rb +88 -0
- data/lib/workarea/asset_endpoints/base.rb +23 -0
- data/lib/workarea/asset_endpoints/favicons.rb +22 -0
- data/lib/workarea/asset_endpoints/product_images.rb +16 -0
- data/lib/workarea/asset_endpoints/product_placeholder_images.rb +9 -0
- data/lib/workarea/autoexpire_cache_redis.rb +29 -0
- data/lib/workarea/bogus_carrier.rb +18 -0
- data/lib/workarea/cache.rb +106 -0
- data/lib/workarea/changelog.rake +87 -0
- data/lib/workarea/configuration.rb +1273 -0
- data/lib/workarea/configuration/action_mailer.rb +24 -0
- data/lib/workarea/configuration/asset_host.rb +13 -0
- data/lib/workarea/configuration/cache_store.rb +21 -0
- data/lib/workarea/configuration/dragonfly.rb +43 -0
- data/lib/workarea/configuration/elasticsearch.rb +39 -0
- data/lib/workarea/configuration/error_handling.rb +15 -0
- data/lib/workarea/configuration/headless_chrome.rb +42 -0
- data/lib/workarea/configuration/i18n.rb +12 -0
- data/lib/workarea/configuration/localized_active_fields.rb +26 -0
- data/lib/workarea/configuration/logstasher.rb +16 -0
- data/lib/workarea/configuration/mongoid.rb +27 -0
- data/lib/workarea/configuration/mongoid_client.rb +53 -0
- data/lib/workarea/configuration/puma.rb +37 -0
- data/lib/workarea/configuration/redis.rb +78 -0
- data/lib/workarea/configuration/s3.rb +68 -0
- data/lib/workarea/configuration/sidekiq.rb +120 -0
- data/lib/workarea/constants.rb +29 -0
- data/lib/workarea/core.rb +221 -0
- data/lib/workarea/core/engine.rb +134 -0
- data/lib/workarea/elasticsearch/document.rb +109 -0
- data/lib/workarea/elasticsearch/index.rb +143 -0
- data/lib/workarea/elasticsearch/query_cache.rb +132 -0
- data/lib/workarea/elasticsearch/serializer.rb +43 -0
- data/lib/workarea/ext/active_shipping/workarea.rb +7 -0
- data/lib/workarea/ext/freedom_patches/action_view_cache_helper.rb +26 -0
- data/lib/workarea/ext/freedom_patches/action_view_conditional_url_helper.rb +23 -0
- data/lib/workarea/ext/freedom_patches/action_view_number_helper.rb +23 -0
- data/lib/workarea/ext/freedom_patches/action_view_path_resolver.rb +16 -0
- data/lib/workarea/ext/freedom_patches/bson.rb +11 -0
- data/lib/workarea/ext/freedom_patches/country.rb +15 -0
- data/lib/workarea/ext/freedom_patches/dragonfly_attachment.rb +14 -0
- data/lib/workarea/ext/freedom_patches/dragonfly_callable_url_host.rb +28 -0
- data/lib/workarea/ext/freedom_patches/dragonfly_job_fetch_url.rb +22 -0
- data/lib/workarea/ext/freedom_patches/float.rb +13 -0
- data/lib/workarea/ext/freedom_patches/global_id.rb +24 -0
- data/lib/workarea/ext/freedom_patches/money.rb +23 -0
- data/lib/workarea/ext/freedom_patches/mongoid_simple_tags.rb +87 -0
- data/lib/workarea/ext/freedom_patches/net_http_ssl_connection.rb +19 -0
- data/lib/workarea/ext/freedom_patches/routes_reloader.rb +21 -0
- data/lib/workarea/ext/freedom_patches/string.rb +16 -0
- data/lib/workarea/ext/freedom_patches/uri.rb +7 -0
- data/lib/workarea/ext/jbuilder/jbuilder_append_partials.rb +16 -0
- data/lib/workarea/ext/mongoid/audit_log_entry.decorator +66 -0
- data/lib/workarea/ext/mongoid/each_by.rb +46 -0
- data/lib/workarea/ext/mongoid/error.rb +17 -0
- data/lib/workarea/ext/mongoid/except.rb +5 -0
- data/lib/workarea/ext/mongoid/find_ordered.rb +21 -0
- data/lib/workarea/ext/mongoid/list_field.rb +21 -0
- data/lib/workarea/ext/mongoid/moped_bson.rb +6 -0
- data/lib/workarea/ext/mongoid/timestamps_timeless.rb +51 -0
- data/lib/workarea/ext/sprockets/ruby_processor.rb +19 -0
- data/lib/workarea/ext/sprockets/task.rb +31 -0
- data/lib/workarea/geolocation.rb +71 -0
- data/lib/workarea/i18n.rb +71 -0
- data/lib/workarea/image_optim_processor.rb +13 -0
- data/lib/workarea/lint.rb +89 -0
- data/lib/workarea/lint/inconsistent_details.rb +32 -0
- data/lib/workarea/lint/products_missing_images.rb +13 -0
- data/lib/workarea/lint/products_missing_variants.rb +13 -0
- data/lib/workarea/lint/skus_missing_inventory.rb +19 -0
- data/lib/workarea/lint/skus_missing_pricing.rb +19 -0
- data/lib/workarea/lint/skus_missing_variants.rb +17 -0
- data/lib/workarea/mail_interceptor.rb +15 -0
- data/lib/workarea/monitoring/elasticsearch_check.rb +24 -0
- data/lib/workarea/monitoring/load_balancing_check.rb +9 -0
- data/lib/workarea/monitoring/mongoid_check.rb +23 -0
- data/lib/workarea/monitoring/sidekiq_queue_size_check.rb +16 -0
- data/lib/workarea/mount_point.rb +27 -0
- data/lib/workarea/paged_array.rb +37 -0
- data/lib/workarea/passenger.rb +5 -0
- data/lib/workarea/ping_home_base.rb +69 -0
- data/lib/workarea/plugin.rb +117 -0
- data/lib/workarea/plugin/asset_appends_helper.rb +36 -0
- data/lib/workarea/robots.rb +9 -0
- data/lib/workarea/routes_constraints/redirect.rb +11 -0
- data/lib/workarea/routes_constraints/super_admin.rb +11 -0
- data/lib/workarea/scheduled_jobs.rb +15 -0
- data/lib/workarea/scheduler.rb +44 -0
- data/lib/workarea/seeds.rb +69 -0
- data/lib/workarea/string_id.rb +45 -0
- data/lib/workarea/svg_asset_finder.rb +43 -0
- data/lib/workarea/swappable_list.rb +64 -0
- data/lib/workarea/url_token.rb +24 -0
- data/lib/workarea/validators/email_validator.rb +24 -0
- data/lib/workarea/validators/ip_address_validator.rb +7 -0
- data/lib/workarea/validators/parameter_validator.rb +9 -0
- data/lib/workarea/validators/password_validator.rb +32 -0
- data/lib/workarea/validators/url_validator.rb +11 -0
- data/lib/workarea/version.rb +28 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/images/workarea/core/foo.png +0 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/mailers/.keep +0 -0
- data/test/dummy/app/models/.keep +0 -0
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +5 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +34 -0
- data/test/dummy/bin/update +29 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +21 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/cable.yml +9 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +51 -0
- data/test/dummy/config/environments/production.rb +86 -0
- data/test/dummy/config/environments/test.rb +43 -0
- data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/new_framework_defaults.rb +17 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/workarea.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/puma.rb +47 -0
- data/test/dummy/config/routes.rb +8 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config/spring.rb +6 -0
- data/test/dummy/db/seeds.rb +10 -0
- data/test/dummy/lib/assets/.keep +0 -0
- data/test/dummy/log/.keep +0 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +1 -0
- data/test/fixtures/label.png +0 -0
- data/test/fixtures/tax_rates.csv +3 -0
- data/test/generators/workarea/content_block_type_generator_test.rb +48 -0
- data/test/generators/workarea/decorator_generator_test.rb +36 -0
- data/test/generators/workarea/discount_generator_test.rb +64 -0
- data/test/generators/workarea/docker_generator_test.rb +156 -0
- data/test/generators/workarea/install_generator_test.rb +92 -0
- data/test/generators/workarea/js_adapter_generator_test.rb +15 -0
- data/test/generators/workarea/override_generator_test.rb +16 -0
- data/test/generators/workarea/pricing_calculator_generator_test.rb +26 -0
- data/test/generators/workarea/product_template_generator_test.rb +36 -0
- data/test/generators/workarea/seeds_generator_test.rb +29 -0
- data/test/helpers/workarea/addresses_helper_test.rb +42 -0
- data/test/helpers/workarea/application_helper_test.rb +67 -0
- data/test/helpers/workarea/conditional_url_helper_test.rb +29 -0
- data/test/helpers/workarea/content_assets_helper_test.rb +23 -0
- data/test/helpers/workarea/facets_helper_test.rb +31 -0
- data/test/helpers/workarea/i18n_helper_test.rb +18 -0
- data/test/helpers/workarea/style_guides_helper_test.rb +63 -0
- data/test/integration/workarea/authentication_test.rb +166 -0
- data/test/integration/workarea/authorization_test.rb +88 -0
- data/test/integration/workarea/cache_varies_integration_test.rb +80 -0
- data/test/integration/workarea/monitoring_integration_test.rb +30 -0
- data/test/integration/workarea/rack_attack_integration_test.rb +168 -0
- data/test/javascripts/cookie_spec.js +37 -0
- data/test/javascripts/date_spec.js +102 -0
- data/test/javascripts/deletion_forms_spec.js +27 -0
- data/test/javascripts/duplicate_id_spec.js +15 -0
- data/test/javascripts/fixtures/deletion_forms.html.haml +3 -0
- data/test/javascripts/fixtures/duplicate_id.html.haml +6 -0
- data/test/javascripts/fixtures/form_submitting_controls.html.haml +4 -0
- data/test/javascripts/fixtures/reveal_password.html.haml +5 -0
- data/test/javascripts/fixtures/workarea_scope.html.haml +5 -0
- data/test/javascripts/form_submitting_controls_spec.js +36 -0
- data/test/javascripts/reveal_password_spec.js +22 -0
- data/test/javascripts/spec_helper.js +26 -0
- data/test/javascripts/string_spec.js +41 -0
- data/test/javascripts/url_spec.js +74 -0
- data/test/javascripts/workarea_spec.js +66 -0
- data/test/lib/workarea/asset_endpoints/favicons_test.rb +39 -0
- data/test/lib/workarea/autoexpire_cache_redis_test.rb +37 -0
- data/test/lib/workarea/constants_test.rb +26 -0
- data/test/lib/workarea/elasticsearch/document_test.rb +125 -0
- data/test/lib/workarea/elasticsearch/query_cache_test.rb +93 -0
- data/test/lib/workarea/ext/freedom_patches/country_test.rb +23 -0
- data/test/lib/workarea/ext/freedom_patches/dragonfly_callable_url_host_test.rb +20 -0
- data/test/lib/workarea/ext/freedom_patches/global_id_test.rb +16 -0
- data/test/lib/workarea/ext/mongoid/audit_log_entry_test.rb +68 -0
- data/test/lib/workarea/ext/mongoid/each_by_test.rb +49 -0
- data/test/lib/workarea/ext/mongoid/except_test.rb +18 -0
- data/test/lib/workarea/ext/mongoid/find_ordered_test.rb +17 -0
- data/test/lib/workarea/ext/mongoid/list_field_test.rb +27 -0
- data/test/lib/workarea/geolocation_test.rb +86 -0
- data/test/lib/workarea/lint/inconsistent_details_test.rb +46 -0
- data/test/lib/workarea/lint/products_missing_images_test.rb +18 -0
- data/test/lib/workarea/lint/products_missing_variants_test.rb +18 -0
- data/test/lib/workarea/lint/skus_missing_inventory_test.rb +30 -0
- data/test/lib/workarea/lint/skus_missing_pricing_test.rb +30 -0
- data/test/lib/workarea/lint/skus_missing_variants_test.rb +34 -0
- data/test/lib/workarea/mail_interceptor_test.rb +69 -0
- data/test/lib/workarea/paged_array_test.rb +11 -0
- data/test/lib/workarea/ping_home_base/request_test.rb +23 -0
- data/test/lib/workarea/plugin_test.rb +100 -0
- data/test/lib/workarea/scheduled_jobs_test.rb +26 -0
- data/test/lib/workarea/scheduler_test.rb +46 -0
- data/test/lib/workarea/string_id_test.rb +43 -0
- data/test/lib/workarea/svg_asset_finder_test.rb +29 -0
- data/test/lib/workarea/swappable_list_test.rb +45 -0
- data/test/lib/workarea/url_token_test.rb +21 -0
- data/test/lib/workarea/validators/email_validator_test.rb +25 -0
- data/test/lib/workarea/validators/parameter_validator_test.rb +19 -0
- data/test/lib/workarea/validators/password_validator_test.rb +60 -0
- data/test/mailers/workarea/application_mailer_test.rb +25 -0
- data/test/middleware/workarea/audit_log_middleware_test.rb +19 -0
- data/test/middleware/workarea/release_server_middleware_test.rb +13 -0
- data/test/models/workarea/address_equality_test.rb +62 -0
- data/test/models/workarea/address_test.rb +112 -0
- data/test/models/workarea/address_validation_test.rb +94 -0
- data/test/models/workarea/application_document_test.rb +39 -0
- data/test/models/workarea/bulk_action/product_edit_test.rb +138 -0
- data/test/models/workarea/bulk_action/sequential_product_edit_test.rb +40 -0
- data/test/models/workarea/bulk_action_test.rb +84 -0
- data/test/models/workarea/catalog/category_test.rb +41 -0
- data/test/models/workarea/catalog/customizations_test.rb +27 -0
- data/test/models/workarea/catalog/product_image_test.rb +39 -0
- data/test/models/workarea/catalog/product_placeholder_image_test.rb +17 -0
- data/test/models/workarea/catalog/product_positions_test.rb +43 -0
- data/test/models/workarea/catalog/product_test.rb +83 -0
- data/test/models/workarea/catalog/variant_test.rb +14 -0
- data/test/models/workarea/checkout/collect_payment_test.rb +51 -0
- data/test/models/workarea/checkout/shipping_options_test.rb +71 -0
- data/test/models/workarea/checkout/steps/addresses_test.rb +127 -0
- data/test/models/workarea/checkout/steps/payment_test.rb +108 -0
- data/test/models/workarea/checkout/steps/shipping_test.rb +106 -0
- data/test/models/workarea/checkout_test.rb +262 -0
- data/test/models/workarea/comment_test.rb +15 -0
- data/test/models/workarea/commentable_test.rb +29 -0
- data/test/models/workarea/content/asset_test.rb +32 -0
- data/test/models/workarea/content/asset_validation_test.rb +68 -0
- data/test/models/workarea/content/block_name_test.rb +25 -0
- data/test/models/workarea/content/block_test.rb +157 -0
- data/test/models/workarea/content/block_type_definition_test.rb +152 -0
- data/test/models/workarea/content/block_type_test.rb +95 -0
- data/test/models/workarea/content/email_test.rb +20 -0
- data/test/models/workarea/content/field_test.rb +15 -0
- data/test/models/workarea/content/fields/asset_test.rb +17 -0
- data/test/models/workarea/content/fields/products_test.rb +14 -0
- data/test/models/workarea/content/page_test.rb +13 -0
- data/test/models/workarea/content_test.rb +28 -0
- data/test/models/workarea/data_file/csv_test.rb +408 -0
- data/test/models/workarea/data_file/export_test.rb +24 -0
- data/test/models/workarea/data_file/format_test.rb +24 -0
- data/test/models/workarea/data_file/import_test.rb +106 -0
- data/test/models/workarea/data_file/json_test.rb +80 -0
- data/test/models/workarea/data_file/operation_test.rb +18 -0
- data/test/models/workarea/data_file/tax_test.rb +59 -0
- data/test/models/workarea/details_test.rb +63 -0
- data/test/models/workarea/discount_ids_test.rb +35 -0
- data/test/models/workarea/fulfillment/item_test.rb +34 -0
- data/test/models/workarea/fulfillment/package_test.rb +43 -0
- data/test/models/workarea/fulfillment_test.rb +217 -0
- data/test/models/workarea/help/article_test.rb +54 -0
- data/test/models/workarea/insights/base_test.rb +41 -0
- data/test/models/workarea/insights/best_customers_test.rb +51 -0
- data/test/models/workarea/insights/best_full_price_customers_test.rb +52 -0
- data/test/models/workarea/insights/cold_products_test.rb +124 -0
- data/test/models/workarea/insights/cold_searches_test.rb +124 -0
- data/test/models/workarea/insights/customer_acquisition_test.rb +44 -0
- data/test/models/workarea/insights/customers_at_risk_test.rb +26 -0
- data/test/models/workarea/insights/hot_products_test.rb +124 -0
- data/test/models/workarea/insights/hot_searches_test.rb +124 -0
- data/test/models/workarea/insights/low_aov_customers_test.rb +30 -0
- data/test/models/workarea/insights/most_discount_given.rb +70 -0
- data/test/models/workarea/insights/most_discounted_products_test.rb +47 -0
- data/test/models/workarea/insights/new_products_test.rb +33 -0
- data/test/models/workarea/insights/non_sellers_test.rb +39 -0
- data/test/models/workarea/insights/popular_searches_test.rb +45 -0
- data/test/models/workarea/insights/popular_searches_without_results_test.rb +28 -0
- data/test/models/workarea/insights/products_purchased_together_test.rb +63 -0
- data/test/models/workarea/insights/products_to_improve_test.rb +134 -0
- data/test/models/workarea/insights/promising_products_test.rb +137 -0
- data/test/models/workarea/insights/release_reminder_test.rb +25 -0
- data/test/models/workarea/insights/repeat_purchase_rate_test.rb +38 -0
- data/test/models/workarea/insights/sales_by_navigation_test.rb +94 -0
- data/test/models/workarea/insights/searches_to_improve_test.rb +134 -0
- data/test/models/workarea/insights/star_products_test.rb +67 -0
- data/test/models/workarea/insights/star_searches_test.rb +67 -0
- data/test/models/workarea/insights/top_categories_test.rb +94 -0
- data/test/models/workarea/insights/top_discounts_test.rb +91 -0
- data/test/models/workarea/insights/top_products_test.rb +94 -0
- data/test/models/workarea/insights/trending_products_test.rb +83 -0
- data/test/models/workarea/insights/trending_searches_test.rb +83 -0
- data/test/models/workarea/insights/upcoming_releases_test.rb +21 -0
- data/test/models/workarea/inventory/capture_test.rb +97 -0
- data/test/models/workarea/inventory/collection_test.rb +35 -0
- data/test/models/workarea/inventory/policies/allow_backorder_test.rb +70 -0
- data/test/models/workarea/inventory/policies/ignore_test.rb +21 -0
- data/test/models/workarea/inventory/policies/standard_test.rb +19 -0
- data/test/models/workarea/inventory/sku_test.rb +97 -0
- data/test/models/workarea/inventory/transaction_test.rb +169 -0
- data/test/models/workarea/inventory_test.rb +29 -0
- data/test/models/workarea/lock_test.rb +47 -0
- data/test/models/workarea/lockable_test.rb +73 -0
- data/test/models/workarea/metrics/by_day_test.rb +145 -0
- data/test/models/workarea/metrics/calculate_percentiles_test.rb +47 -0
- data/test/models/workarea/metrics/product_by_week_test.rb +141 -0
- data/test/models/workarea/metrics/product_for_last_week_test.rb +128 -0
- data/test/models/workarea/metrics/search_by_day_test.rb +40 -0
- data/test/models/workarea/metrics/search_by_week_test.rb +141 -0
- data/test/models/workarea/metrics/search_for_last_week_test.rb +134 -0
- data/test/models/workarea/metrics/user_test.rb +79 -0
- data/test/models/workarea/navigation/breadcrumbs_test.rb +52 -0
- data/test/models/workarea/navigation/menu_test.rb +23 -0
- data/test/models/workarea/navigation/redirect_test.rb +51 -0
- data/test/models/workarea/navigation/search_results_test.rb +32 -0
- data/test/models/workarea/navigation/taxon_test.rb +118 -0
- data/test/models/workarea/normalize_email_test.rb +17 -0
- data/test/models/workarea/order/item_test.rb +60 -0
- data/test/models/workarea/order/queries_test.rb +187 -0
- data/test/models/workarea/order_test.rb +154 -0
- data/test/models/workarea/ordering_test.rb +41 -0
- data/test/models/workarea/payment/address_test.rb +139 -0
- data/test/models/workarea/payment/authorize/credit_card_test.rb +108 -0
- data/test/models/workarea/payment/authorize/store_credit_test.rb +73 -0
- data/test/models/workarea/payment/capture/credit_card_test.rb +66 -0
- data/test/models/workarea/payment/capture/store_credit_test.rb +50 -0
- data/test/models/workarea/payment/capture_test.rb +168 -0
- data/test/models/workarea/payment/credit_card_integration_test.rb +174 -0
- data/test/models/workarea/payment/credit_card_test.rb +111 -0
- data/test/models/workarea/payment/operation_test.rb +143 -0
- data/test/models/workarea/payment/profile_test.rb +48 -0
- data/test/models/workarea/payment/purchase/credit_card_test.rb +95 -0
- data/test/models/workarea/payment/purchase/store_credit_test.rb +72 -0
- data/test/models/workarea/payment/refund/credit_card_test.rb +66 -0
- data/test/models/workarea/payment/refund/store_credit_test.rb +63 -0
- data/test/models/workarea/payment/refund_test.rb +188 -0
- data/test/models/workarea/payment/saved_credit_card_test.rb +32 -0
- data/test/models/workarea/payment/store_credit_card_test.rb +42 -0
- data/test/models/workarea/payment/tender/credit_card_test.rb +52 -0
- data/test/models/workarea/payment/tender/store_credit_test.rb +18 -0
- data/test/models/workarea/payment/tender_test.rb +191 -0
- data/test/models/workarea/payment/transaction_test.rb +126 -0
- data/test/models/workarea/payment_reference_test.rb +17 -0
- data/test/models/workarea/payment_test.rb +172 -0
- data/test/models/workarea/price_adjustment_test.rb +26 -0
- data/test/models/workarea/pricing/cache_key_test.rb +67 -0
- data/test/models/workarea/pricing/calculators/customizations_calculator_test.rb +28 -0
- data/test/models/workarea/pricing/calculators/discount_calculator_test.rb +152 -0
- data/test/models/workarea/pricing/calculators/item_calculator_test.rb +76 -0
- data/test/models/workarea/pricing/calculators/overrides_calculator_test.rb +130 -0
- data/test/models/workarea/pricing/calculators/tax_calculator_test.rb +118 -0
- data/test/models/workarea/pricing/collection_test.rb +101 -0
- data/test/models/workarea/pricing/discount/amount_calculator_test.rb +31 -0
- data/test/models/workarea/pricing/discount/application_group_test.rb +174 -0
- data/test/models/workarea/pricing/discount/buy_some_get_some/order_items_by_product_test.rb +28 -0
- data/test/models/workarea/pricing/discount/buy_some_get_some_test.rb +200 -0
- data/test/models/workarea/pricing/discount/category_test.rb +68 -0
- data/test/models/workarea/pricing/discount/code_list_test.rb +23 -0
- data/test/models/workarea/pricing/discount/collection_test.rb +44 -0
- data/test/models/workarea/pricing/discount/conditions/user_tags_test.rb +43 -0
- data/test/models/workarea/pricing/discount/free_gift_test.rb +65 -0
- data/test/models/workarea/pricing/discount/generated_promo_code_test.rb +14 -0
- data/test/models/workarea/pricing/discount/order_test.rb +60 -0
- data/test/models/workarea/pricing/discount/order_total_test.rb +60 -0
- data/test/models/workarea/pricing/discount/product_attribute_test.rb +81 -0
- data/test/models/workarea/pricing/discount/product_test.rb +63 -0
- data/test/models/workarea/pricing/discount/quantity_fixed_price_test.rb +292 -0
- data/test/models/workarea/pricing/discount/shipping_test.rb +67 -0
- data/test/models/workarea/pricing/discount_test.rb +95 -0
- data/test/models/workarea/pricing/override_test.rb +59 -0
- data/test/models/workarea/pricing/price_distributor_test.rb +40 -0
- data/test/models/workarea/pricing/price_test.rb +58 -0
- data/test/models/workarea/pricing/request_test.rb +86 -0
- data/test/models/workarea/pricing/sku_test.rb +47 -0
- data/test/models/workarea/pricing/tax_applier_test.rb +125 -0
- data/test/models/workarea/pricing_test.rb +1398 -0
- data/test/models/workarea/product_rule_test.rb +55 -0
- data/test/models/workarea/query_string_test.rb +90 -0
- data/test/models/workarea/recommendation/user_activity_test.rb +96 -0
- data/test/models/workarea/releasable_test.rb +479 -0
- data/test/models/workarea/release_test.rb +287 -0
- data/test/models/workarea/reports/export_test.rb +33 -0
- data/test/models/workarea/search/admin/catalog_category_test.rb +44 -0
- data/test/models/workarea/search/admin/catalog_product_test.rb +126 -0
- data/test/models/workarea/search/admin/content_asset_test.rb +54 -0
- data/test/models/workarea/search/admin/content_page_test.rb +18 -0
- data/test/models/workarea/search/admin/content_test.rb +17 -0
- data/test/models/workarea/search/admin/order_test.rb +105 -0
- data/test/models/workarea/search/admin/pricing_discount_test.rb +31 -0
- data/test/models/workarea/search/admin/releasable_test.rb +36 -0
- data/test/models/workarea/search/admin/user_test.rb +53 -0
- data/test/models/workarea/search/admin_test.rb +18 -0
- data/test/models/workarea/search/customization_test.rb +69 -0
- data/test/models/workarea/search/settings_test.rb +18 -0
- data/test/models/workarea/search/storefront/product/categories_test.rb +95 -0
- data/test/models/workarea/search/storefront/product/facets_test.rb +35 -0
- data/test/models/workarea/search/storefront/product/inventory_test.rb +23 -0
- data/test/models/workarea/search/storefront/product/pricing_test.rb +41 -0
- data/test/models/workarea/search/storefront/product/text_test.rb +69 -0
- data/test/models/workarea/search/storefront/product_test.rb +108 -0
- data/test/models/workarea/search/storefront_test.rb +27 -0
- data/test/models/workarea/shipping/address_test.rb +139 -0
- data/test/models/workarea/shipping/location_query_test.rb +60 -0
- data/test/models/workarea/shipping/rate_lookup_test.rb +76 -0
- data/test/models/workarea/shipping/rate_test.rb +19 -0
- data/test/models/workarea/shipping/service_test.rb +40 -0
- data/test/models/workarea/shipping/sku_test.rb +31 -0
- data/test/models/workarea/shipping_option_test.rb +50 -0
- data/test/models/workarea/shipping_test.rb +106 -0
- data/test/models/workarea/tax/category_test.rb +57 -0
- data/test/models/workarea/tax/rate_lookup_test.rb +217 -0
- data/test/models/workarea/tax_test.rb +34 -0
- data/test/models/workarea/user/admin_bookmark_test.rb +39 -0
- data/test/models/workarea/user/admin_visit_test.rb +23 -0
- data/test/models/workarea/user/password_reset_test.rb +30 -0
- data/test/models/workarea/user/recent_password_test.rb +50 -0
- data/test/models/workarea/user/system_users_test.rb +14 -0
- data/test/models/workarea/user_test.rb +312 -0
- data/test/queries/workarea/admin_query_operation_test.rb +67 -0
- data/test/queries/workarea/admin_search_query_wrapper_test.rb +90 -0
- data/test/queries/workarea/alerts_test.rb +131 -0
- data/test/queries/workarea/bulk_action_selections_test.rb +35 -0
- data/test/queries/workarea/categorization_test.rb +88 -0
- data/test/queries/workarea/extract_content_block_text_test.rb +60 -0
- data/test/queries/workarea/find_pipeline_asset_test.rb +21 -0
- data/test/queries/workarea/find_taxonomy_slug_test.rb +20 -0
- data/test/queries/workarea/find_unique_slug_test.rb +14 -0
- data/test/queries/workarea/metadata/catalog_category_test.rb +38 -0
- data/test/queries/workarea/metadata/content_page_test.rb +36 -0
- data/test/queries/workarea/metadata/home_page_test.rb +34 -0
- data/test/queries/workarea/order_item_details_test.rb +43 -0
- data/test/queries/workarea/order_metrics_test.rb +180 -0
- data/test/queries/workarea/pricing_override_params_test.rb +28 -0
- data/test/queries/workarea/product_primary_image_url_test.rb +22 -0
- data/test/queries/workarea/product_primary_navigation_test.rb +49 -0
- data/test/queries/workarea/recommendation/order_based_test.rb +51 -0
- data/test/queries/workarea/recommendation/product_based_test.rb +91 -0
- data/test/queries/workarea/recommendation/searches_test.rb +23 -0
- data/test/queries/workarea/recommendation/user_activity_based_test.rb +37 -0
- data/test/queries/workarea/reports/average_order_value_test.rb +336 -0
- data/test/queries/workarea/reports/customers_test.rb +106 -0
- data/test/queries/workarea/reports/first_time_vs_returning_sales_test.rb +274 -0
- data/test/queries/workarea/reports/low_inventory_test.rb +48 -0
- data/test/queries/workarea/reports/report_test.rb +100 -0
- data/test/queries/workarea/reports/sales_by_category_test.rb +137 -0
- data/test/queries/workarea/reports/sales_by_country_test.rb +130 -0
- data/test/queries/workarea/reports/sales_by_discount_test.rb +122 -0
- data/test/queries/workarea/reports/sales_by_menu_test.rb +130 -0
- data/test/queries/workarea/reports/sales_by_product_test.rb +130 -0
- data/test/queries/workarea/reports/sales_by_sku_test.rb +171 -0
- data/test/queries/workarea/reports/sales_by_traffic_referrer_test.rb +159 -0
- data/test/queries/workarea/reports/sales_over_time_test.rb +539 -0
- data/test/queries/workarea/reports/searches_over_time_test.rb +90 -0
- data/test/queries/workarea/reports/searches_test.rb +179 -0
- data/test/queries/workarea/reports/searches_without_results_over_time_test.rb +100 -0
- data/test/queries/workarea/search/admin_discounts_test.rb +26 -0
- data/test/queries/workarea/search/admin_orders_test.rb +63 -0
- data/test/queries/workarea/search/admin_payment_transactions_test.rb +13 -0
- data/test/queries/workarea/search/admin_releases_test.rb +67 -0
- data/test/queries/workarea/search/admin_search_test.rb +105 -0
- data/test/queries/workarea/search/admin_users_test.rb +20 -0
- data/test/queries/workarea/search/categorization_test.rb +31 -0
- data/test/queries/workarea/search/category_browse_test.rb +334 -0
- data/test/queries/workarea/search/date_filter_test.rb +39 -0
- data/test/queries/workarea/search/facet_matches_test.rb +55 -0
- data/test/queries/workarea/search/facet_sorting/size_test.rb +27 -0
- data/test/queries/workarea/search/facet_sorting_test.rb +127 -0
- data/test/queries/workarea/search/facet_test.rb +108 -0
- data/test/queries/workarea/search/filter_test.rb +68 -0
- data/test/queries/workarea/search/pagination_test.rb +66 -0
- data/test/queries/workarea/search/product_entries_test.rb +14 -0
- data/test/queries/workarea/search/product_facet_sorting_test.rb +90 -0
- data/test/queries/workarea/search/product_rules_test.rb +348 -0
- data/test/queries/workarea/search/product_search_test.rb +413 -0
- data/test/queries/workarea/search/query_test.rb +43 -0
- data/test/queries/workarea/search/range_facet_test.rb +15 -0
- data/test/queries/workarea/search/range_parameter_test.rb +30 -0
- data/test/queries/workarea/search/related_help_test.rb +101 -0
- data/test/queries/workarea/search/related_products_test.rb +81 -0
- data/test/queries/workarea/search/search_suggestions_test.rb +29 -0
- data/test/queries/workarea/search/storefront_search_test.rb +111 -0
- data/test/queries/workarea/search/terms_facet_test.rb +12 -0
- data/test/queries/workarea/taxonomy_sitemap_test.rb +34 -0
- data/test/services/workarea/add_multiple_cart_items/item_test.rb +56 -0
- data/test/services/workarea/add_multiple_cart_items_test.rb +100 -0
- data/test/services/workarea/cancel_order_test.rb +118 -0
- data/test/services/workarea/cart_cleaner_test.rb +66 -0
- data/test/services/workarea/clean_range_facets_test.rb +28 -0
- data/test/services/workarea/copy_order_test.rb +83 -0
- data/test/services/workarea/copy_product_test.rb +25 -0
- data/test/services/workarea/create_fulfillment_test.rb +23 -0
- data/test/services/workarea/direct_upload_test.rb +58 -0
- data/test/services/workarea/export_report_test.rb +66 -0
- data/test/services/workarea/hash_update_test.rb +24 -0
- data/test/services/workarea/inventory_adjustment_test.rb +41 -0
- data/test/services/workarea/login_test.rb +74 -0
- data/test/services/workarea/order_merge_test.rb +30 -0
- data/test/services/workarea/packaging_test.rb +91 -0
- data/test/services/workarea/save_publishing_test.rb +46 -0
- data/test/services/workarea/save_taxonomy_test.rb +72 -0
- data/test/services/workarea/set_navigable_test.rb +54 -0
- data/test/services/workarea/sort_navigation_menus_by_orders_test.rb +25 -0
- data/test/teaspoon_env.rb +6 -0
- data/test/test_helper.rb +10 -0
- data/test/vcr_cassettes/csv_image_upload.yml +49 -0
- data/test/view_models/workarea/shipping_carrier_view_model_test.rb +49 -0
- data/test/workarea_test.rb +9 -0
- data/test/workers/sidekiq/callbacks_test.rb +433 -0
- data/test/workers/workarea/bulk_index_admin_test.rb +30 -0
- data/test/workers/workarea/bulk_index_products_test.rb +18 -0
- data/test/workers/workarea/bulk_index_searches_test.rb +45 -0
- data/test/workers/workarea/clean_inventory_transactions_test.rb +19 -0
- data/test/workers/workarea/clean_orders_test.rb +22 -0
- data/test/workers/workarea/clean_product_recommendations_test.rb +15 -0
- data/test/workers/workarea/deactivate_stale_discounts_test.rb +82 -0
- data/test/workers/workarea/generate_content_metadata_test.rb +32 -0
- data/test/workers/workarea/generate_insights_test.rb +38 -0
- data/test/workers/workarea/index_admin_search_test.rb +10 -0
- data/test/workers/workarea/index_categorization_test.rb +26 -0
- data/test/workers/workarea/index_category_changes_test.rb +63 -0
- data/test/workers/workarea/index_fulfillment_changes_test.rb +14 -0
- data/test/workers/workarea/index_help_test.rb +18 -0
- data/test/workers/workarea/index_payment_transactions_test.rb +42 -0
- data/test/workers/workarea/index_product_rule_test.rb +20 -0
- data/test/workers/workarea/index_product_test.rb +17 -0
- data/test/workers/workarea/index_skus_test.rb +14 -0
- data/test/workers/workarea/keep_product_index_fresh_test.rb +46 -0
- data/test/workers/workarea/mark_discounts_as_redeemed_test.rb +51 -0
- data/test/workers/workarea/order_reminder_test.rb +45 -0
- data/test/workers/workarea/process_import_test.rb +57 -0
- data/test/workers/workarea/process_product_recommendations_test.rb +57 -0
- data/test/workers/workarea/process_search_recommendations_test.rb +27 -0
- data/test/workers/workarea/publish_bulk_action_test.rb +27 -0
- data/test/workers/workarea/publish_release_test.rb +20 -0
- data/test/workers/workarea/redirect_navigable_slugs_test.rb +28 -0
- data/test/workers/workarea/save_order_metrics_test.rb +14 -0
- data/test/workers/workarea/save_user_order_details_test.rb +130 -0
- data/test/workers/workarea/send_refund_email_test.rb +74 -0
- data/test/workers/workarea/status_reporter_test.rb +20 -0
- data/test/workers/workarea/undo_release_test.rb +23 -0
- data/test/workers/workarea/update_payment_profile_email_test.rb +27 -0
- data/test/workers/workarea/verify_scheduled_releases_test.rb +71 -0
- data/vendor/active_shipping/.gitignore +15 -0
- data/vendor/active_shipping/.travis.yml +31 -0
- data/vendor/active_shipping/.yardopts +13 -0
- data/vendor/active_shipping/CHANGELOG.md +218 -0
- data/vendor/active_shipping/CONTRIBUTING.md +23 -0
- data/vendor/active_shipping/Gemfile +3 -0
- data/vendor/active_shipping/MIT-LICENSE +20 -0
- data/vendor/active_shipping/README.md +163 -0
- data/vendor/active_shipping/Rakefile +35 -0
- data/vendor/active_shipping/active_shipping.gemspec +38 -0
- data/vendor/active_shipping/dev.yml +17 -0
- data/vendor/active_shipping/gemfiles/activesupport42.gemfile +5 -0
- data/vendor/active_shipping/gemfiles/activesupport50.gemfile +6 -0
- data/vendor/active_shipping/gemfiles/activesupport51.gemfile +5 -0
- data/vendor/active_shipping/gemfiles/activesupport52.gemfile +5 -0
- data/vendor/active_shipping/gemfiles/activesupport_master.gemfile +5 -0
- data/vendor/active_shipping/lib/active_shipping.rb +26 -0
- data/vendor/active_shipping/lib/active_shipping/address_validation_response.rb +29 -0
- data/vendor/active_shipping/lib/active_shipping/carrier.rb +183 -0
- data/vendor/active_shipping/lib/active_shipping/carriers.rb +34 -0
- data/vendor/active_shipping/lib/active_shipping/carriers/australia_post.rb +248 -0
- data/vendor/active_shipping/lib/active_shipping/carriers/benchmark_carrier.rb +31 -0
- data/vendor/active_shipping/lib/active_shipping/carriers/bogus_carrier.rb +12 -0
- data/vendor/active_shipping/lib/active_shipping/carriers/canada_post.rb +263 -0
- data/vendor/active_shipping/lib/active_shipping/carriers/canada_post_pws.rb +908 -0
- data/vendor/active_shipping/lib/active_shipping/carriers/fedex.rb +796 -0
- data/vendor/active_shipping/lib/active_shipping/carriers/kunaki.rb +155 -0
- data/vendor/active_shipping/lib/active_shipping/carriers/new_zealand_post.rb +260 -0
- data/vendor/active_shipping/lib/active_shipping/carriers/shipwire.rb +178 -0
- data/vendor/active_shipping/lib/active_shipping/carriers/stamps.rb +860 -0
- data/vendor/active_shipping/lib/active_shipping/carriers/ups.rb +1216 -0
- data/vendor/active_shipping/lib/active_shipping/carriers/usps.rb +708 -0
- data/vendor/active_shipping/lib/active_shipping/carriers/usps_returns.rb +85 -0
- data/vendor/active_shipping/lib/active_shipping/delivery_date_estimate.rb +20 -0
- data/vendor/active_shipping/lib/active_shipping/delivery_date_estimates_response.rb +11 -0
- data/vendor/active_shipping/lib/active_shipping/errors.rb +35 -0
- data/vendor/active_shipping/lib/active_shipping/external_return_label_request.rb +417 -0
- data/vendor/active_shipping/lib/active_shipping/external_return_label_response.rb +24 -0
- data/vendor/active_shipping/lib/active_shipping/label.rb +10 -0
- data/vendor/active_shipping/lib/active_shipping/label_response.rb +10 -0
- data/vendor/active_shipping/lib/active_shipping/location.rb +166 -0
- data/vendor/active_shipping/lib/active_shipping/package.rb +165 -0
- data/vendor/active_shipping/lib/active_shipping/package_item.rb +60 -0
- data/vendor/active_shipping/lib/active_shipping/rate_estimate.rb +196 -0
- data/vendor/active_shipping/lib/active_shipping/rate_response.rb +32 -0
- data/vendor/active_shipping/lib/active_shipping/response.rb +43 -0
- data/vendor/active_shipping/lib/active_shipping/shipment_event.rb +22 -0
- data/vendor/active_shipping/lib/active_shipping/shipment_packer.rb +108 -0
- data/vendor/active_shipping/lib/active_shipping/shipping_response.rb +33 -0
- data/vendor/active_shipping/lib/active_shipping/tracking_response.rb +119 -0
- data/vendor/active_shipping/lib/active_shipping/version.rb +3 -0
- data/vendor/active_shipping/lib/certs/eParcel.dtd +111 -0
- data/vendor/active_shipping/shipit.rubygems.yml +1 -0
- data/vendor/active_shipping/test/console.rb +39 -0
- data/vendor/active_shipping/test/credentials.yml +69 -0
- data/vendor/active_shipping/test/fixtures/files/label1.pdf +0 -0
- data/vendor/active_shipping/test/fixtures/json/australia_post/calculate_domestic.json +13 -0
- data/vendor/active_shipping/test/fixtures/json/australia_post/calculate_domestic_2.json +19 -0
- data/vendor/active_shipping/test/fixtures/json/australia_post/calculate_international.json +12 -0
- data/vendor/active_shipping/test/fixtures/json/australia_post/calculate_international_2.json +15 -0
- data/vendor/active_shipping/test/fixtures/json/australia_post/error_message.json +5 -0
- data/vendor/active_shipping/test/fixtures/json/australia_post/service_domestic.json +117 -0
- data/vendor/active_shipping/test/fixtures/json/australia_post/service_domestic_2.json +117 -0
- data/vendor/active_shipping/test/fixtures/json/australia_post/service_international.json +76 -0
- data/vendor/active_shipping/test/fixtures/json/australia_post/service_international_2.json +59 -0
- data/vendor/active_shipping/test/fixtures/json/newzealandpost/domestic_book.json +1 -0
- data/vendor/active_shipping/test/fixtures/json/newzealandpost/domestic_default.json +1 -0
- data/vendor/active_shipping/test/fixtures/json/newzealandpost/domestic_error.json +1 -0
- data/vendor/active_shipping/test/fixtures/json/newzealandpost/domestic_poster.json +1 -0
- data/vendor/active_shipping/test/fixtures/json/newzealandpost/domestic_small_half_pound.json +1 -0
- data/vendor/active_shipping/test/fixtures/json/newzealandpost/international_book.json +1 -0
- data/vendor/active_shipping/test/fixtures/json/newzealandpost/international_new_zealand_wii.json +1 -0
- data/vendor/active_shipping/test/fixtures/json/newzealandpost/international_small_half_pound.json +1 -0
- data/vendor/active_shipping/test/fixtures/json/newzealandpost/international_wii.json +1 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost/example_request.xml +25 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost/example_response.xml +130 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost/example_response_error.xml +16 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost/example_response_french.xml +122 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost/example_response_with_nil_value.xml +164 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost/example_response_with_postal_outlet.xml +155 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost/example_response_with_postal_outlet_french.xml +274 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost/example_response_with_strange_delivery_date.xml +130 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/dnc_tracking_details_en.xml +112 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/merchant_details_error.xml +7 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/merchant_details_response.xml +7 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/option_response.xml +13 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/option_response_no_conflicts.xml +7 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/rates_info.xml +190 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/rates_info_error.xml +7 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/receipt_response.xml +42 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/receipt_response_no_priced_options.xml +36 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/register_token_error.xml +7 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/register_token_response.xml +3 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/service_options_response.xml +42 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/services_error.xml +6 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/services_response.xml +32 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/shipment_domestic.xml +69 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/shipment_response.xml +20 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/shipment_us.xml +69 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/tracking_details_en.xml +152 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/tracking_details_en_error.xml +7 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/tracking_details_en_undelivered.xml +116 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/tracking_details_fr.xml +156 -0
- data/vendor/active_shipping/test/fixtures/xml/canadapost_pws/tracking_details_no_expected_delivery_date.xml +40 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/create_shipment_response.xml +2 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/freight_rate_request.xml +82 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/freight_rate_response.xml +506 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/invalid_fedex_reply.xml +27 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/ottawa_to_beverly_hills_commercial_rate_request.xml +79 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/ottawa_to_beverly_hills_no_saturday_rate_request.xml +79 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/ottawa_to_beverly_hills_rate_request.xml +80 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/ottawa_to_beverly_hills_rate_response.xml +214 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/raterequest_reply.xml +213 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/raterequest_response_with_ground_home_delivery.xml +206 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/reply_without_notifications.xml +185 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/tracking_request.xml +29 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/tracking_response_bad_tracking_number.xml +20 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/tracking_response_delivered_at_door.xml +254 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/tracking_response_delivered_at_facility.xml +403 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/tracking_response_delivered_with_signature.xml +269 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/tracking_response_empty_status_detail.xml +84 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/tracking_response_failure_code_9045.xml +52 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/tracking_response_failure_code_9080.xml +51 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/tracking_response_in_transit.xml +127 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/tracking_response_invalid_tracking_number.xml +52 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/tracking_response_missing_status_code.xml +89 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/tracking_response_multiple_results.xml +100 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/tracking_response_not_found.xml +52 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/tracking_response_shipment_exception.xml +209 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/tracking_response_unable_to_process.xml +32 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/tracking_response_with_blank_state.xml +107 -0
- data/vendor/active_shipping/test/fixtures/xml/fedex/unknown_fedex_document_reply.xml +3 -0
- data/vendor/active_shipping/test/fixtures/xml/kunaki/invalid_state_response.xml +3 -0
- data/vendor/active_shipping/test/fixtures/xml/kunaki/no_valid_items_response.xml +3 -0
- data/vendor/active_shipping/test/fixtures/xml/kunaki/successful_rates_response.xml +3 -0
- data/vendor/active_shipping/test/fixtures/xml/kunaki/unsuccessful_rates_response.xml +9 -0
- data/vendor/active_shipping/test/fixtures/xml/shipwire/international_rates_response.xml +17 -0
- data/vendor/active_shipping/test/fixtures/xml/shipwire/new_carrier_rate_response.xml +18 -0
- data/vendor/active_shipping/test/fixtures/xml/shipwire/no_rates_response.xml +7 -0
- data/vendor/active_shipping/test/fixtures/xml/shipwire/rates_response.xml +36 -0
- data/vendor/active_shipping/test/fixtures/xml/shipwire/rates_response_no_estimate.xml +14 -0
- data/vendor/active_shipping/test/fixtures/xml/stamps/authenticate_user_request.xml +15 -0
- data/vendor/active_shipping/test/fixtures/xml/stamps/authenticate_user_response.xml +10 -0
- data/vendor/active_shipping/test/fixtures/xml/stamps/cleanse_address_request.xml +19 -0
- data/vendor/active_shipping/test/fixtures/xml/stamps/cleanse_address_response.xml +27 -0
- data/vendor/active_shipping/test/fixtures/xml/stamps/create_indicium_request.xml +69 -0
- data/vendor/active_shipping/test/fixtures/xml/stamps/create_indicium_response.xml +40 -0
- data/vendor/active_shipping/test/fixtures/xml/stamps/expired_authenticator_response.xml +15 -0
- data/vendor/active_shipping/test/fixtures/xml/stamps/get_account_info_request.xml +11 -0
- data/vendor/active_shipping/test/fixtures/xml/stamps/get_account_info_response.xml +36 -0
- data/vendor/active_shipping/test/fixtures/xml/stamps/get_purchase_status_request.xml +12 -0
- data/vendor/active_shipping/test/fixtures/xml/stamps/get_purchase_status_response.xml +16 -0
- data/vendor/active_shipping/test/fixtures/xml/stamps/get_rates_request.xml +19 -0
- data/vendor/active_shipping/test/fixtures/xml/stamps/get_rates_response.xml +351 -0
- data/vendor/active_shipping/test/fixtures/xml/stamps/purchase_postage_request.xml +13 -0
- data/vendor/active_shipping/test/fixtures/xml/stamps/purchase_postage_response.xml +17 -0
- data/vendor/active_shipping/test/fixtures/xml/stamps/track_shipment_request.xml +12 -0
- data/vendor/active_shipping/test/fixtures/xml/stamps/track_shipment_response.xml +45 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/api_error_rate_response.xml +53 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/beverly_hills_to_new_york_book_commercial_base_rate_response.xml +2 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/beverly_hills_to_new_york_book_commercial_plus_rate_response.xml +258 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/beverly_hills_to_new_york_book_rate_response.xml +108 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/beverly_hills_to_ottawa_american_wii_commercial_base_rate_response.xml +84 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/beverly_hills_to_ottawa_american_wii_commercial_plus_rate_response.xml +212 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/beverly_hills_to_ottawa_american_wii_rate_response.xml +230 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/first_class_packages_with_invalid_mail_type_response.xml +12 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/first_class_packages_with_mail_type_response.xml +16 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/first_class_packages_without_mail_type_response.xml +12 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/invalid_xml_response.xml +10 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/invalid_xml_tracking_response_error.xml +2 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/tracking_request.xml +10 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/tracking_request_batch.xml +12 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/tracking_response.xml +162 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/tracking_response_alt.xml +53 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/tracking_response_batch.xml +231 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/tracking_response_failure.xml +11 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/tracking_response_not_available.xml +12 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/tracking_response_test_error.xml +8 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/us_rate_request.xml +18 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/us_rate_request_large.xml +18 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/world_rate_request_only_country.xml +22 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/world_rate_request_with_value.xml +24 -0
- data/vendor/active_shipping/test/fixtures/xml/usps/world_rate_request_without_value.xml +24 -0
- data/vendor/active_shipping/test/fixtures/xml/usps_returns/external_return_label_response.xml +2 -0
- data/vendor/active_shipping/test/fixtures/xml/usps_returns/external_return_label_response_failure.xml +10 -0
- data/vendor/active_shipping/test/remote/australia_post_test.rb +140 -0
- data/vendor/active_shipping/test/remote/canada_post_pws_platform_test.rb +259 -0
- data/vendor/active_shipping/test/remote/canada_post_pws_test.rb +169 -0
- data/vendor/active_shipping/test/remote/canada_post_test.rb +55 -0
- data/vendor/active_shipping/test/remote/fedex_test.rb +400 -0
- data/vendor/active_shipping/test/remote/kunaki_test.rb +37 -0
- data/vendor/active_shipping/test/remote/new_zealand_post_test.rb +149 -0
- data/vendor/active_shipping/test/remote/shipwire_test.rb +84 -0
- data/vendor/active_shipping/test/remote/stamps_test.rb +396 -0
- data/vendor/active_shipping/test/remote/usps_returns_test.rb +72 -0
- data/vendor/active_shipping/test/remote/usps_test.rb +243 -0
- data/vendor/active_shipping/test/test_helper.rb +295 -0
- data/vendor/active_shipping/test/unit/carrier_test.rb +130 -0
- data/vendor/active_shipping/test/unit/carriers/australia_post_test.rb +181 -0
- data/vendor/active_shipping/test/unit/carriers/benchmark_test.rb +18 -0
- data/vendor/active_shipping/test/unit/carriers/canada_post_pws_rating_test.rb +379 -0
- data/vendor/active_shipping/test/unit/carriers/canada_post_pws_register_test.rb +76 -0
- data/vendor/active_shipping/test/unit/carriers/canada_post_pws_shipping_test.rb +258 -0
- data/vendor/active_shipping/test/unit/carriers/canada_post_pws_test.rb +59 -0
- data/vendor/active_shipping/test/unit/carriers/canada_post_pws_tracking_test.rb +154 -0
- data/vendor/active_shipping/test/unit/carriers/canada_post_test.rb +148 -0
- data/vendor/active_shipping/test/unit/carriers/fedex_test.rb +693 -0
- data/vendor/active_shipping/test/unit/carriers/kunaki_test.rb +56 -0
- data/vendor/active_shipping/test/unit/carriers/new_zealand_post_test.rb +177 -0
- data/vendor/active_shipping/test/unit/carriers/shipwire_test.rb +188 -0
- data/vendor/active_shipping/test/unit/carriers/stamps_test.rb +245 -0
- data/vendor/active_shipping/test/unit/carriers/usps_returns_test.rb +45 -0
- data/vendor/active_shipping/test/unit/carriers/usps_test.rb +633 -0
- data/vendor/active_shipping/test/unit/carriers_test.rb +16 -0
- data/vendor/active_shipping/test/unit/external_return_label_request_test.rb +258 -0
- data/vendor/active_shipping/test/unit/location_test.rb +234 -0
- data/vendor/active_shipping/test/unit/package_item_test.rb +232 -0
- data/vendor/active_shipping/test/unit/package_test.rb +404 -0
- data/vendor/active_shipping/test/unit/rate_estimate_test.rb +93 -0
- data/vendor/active_shipping/test/unit/response_test.rb +38 -0
- data/vendor/active_shipping/test/unit/shipment_event_test.rb +20 -0
- data/vendor/active_shipping/test/unit/shipment_packer_test.rb +212 -0
- data/vendor/active_shipping/test/unit/tracking_response_test.rb +41 -0
- data/workarea-core.gemspec +98 -0
- metadata +2585 -0
@@ -0,0 +1,125 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
module Pricing
|
5
|
+
class TaxApplierTest < TestCase
|
6
|
+
setup :set_models
|
7
|
+
|
8
|
+
def set_models
|
9
|
+
@shipping = create_shipping(
|
10
|
+
address: {
|
11
|
+
first_name: 'Ben',
|
12
|
+
last_name: 'Crouse',
|
13
|
+
street: '22 S. 3rd St.',
|
14
|
+
street_2: 'Second Floor',
|
15
|
+
city: 'Philadelphia',
|
16
|
+
region: 'PA',
|
17
|
+
postal_code: '19106',
|
18
|
+
country: 'US',
|
19
|
+
phone_number: '2159251800'
|
20
|
+
}
|
21
|
+
)
|
22
|
+
|
23
|
+
@item = Order::Item.new
|
24
|
+
|
25
|
+
@adjustments_to_tax = PriceAdjustmentSet.new(
|
26
|
+
[
|
27
|
+
@item.price_adjustments.build(
|
28
|
+
price: 'item',
|
29
|
+
amount: 5.to_m,
|
30
|
+
data: { 'tax_code' => 101 }
|
31
|
+
)
|
32
|
+
]
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_adds_a_tax_price_adjustment_to_a_shipping_item
|
37
|
+
create_tax_category(code: '101')
|
38
|
+
|
39
|
+
applier = TaxApplier.new(@shipping, @adjustments_to_tax)
|
40
|
+
applier.apply
|
41
|
+
@shipping.save!
|
42
|
+
|
43
|
+
@shipping.reload
|
44
|
+
price_adjustment = @shipping.price_adjustments.last
|
45
|
+
assert_equal('tax', price_adjustment.price)
|
46
|
+
assert_equal(0.3.to_m, price_adjustment.amount)
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_guards_against_negative_tax_amounts
|
50
|
+
create_tax_category(
|
51
|
+
code: '101',
|
52
|
+
rates: [{ percentage: -0.06, country: 'US', region: 'PA' }]
|
53
|
+
)
|
54
|
+
|
55
|
+
applier = TaxApplier.new(@shipping, @adjustments_to_tax)
|
56
|
+
applier.apply
|
57
|
+
@shipping.save!
|
58
|
+
|
59
|
+
@shipping.reload
|
60
|
+
assert(@shipping.price_adjustments.empty?)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_with_multiple_tax_codes_and_discount
|
64
|
+
create_tax_category(
|
65
|
+
code: '101',
|
66
|
+
rates: [{ percentage: 0.07, country: 'US', region: 'PA' }]
|
67
|
+
)
|
68
|
+
|
69
|
+
create_tax_category(
|
70
|
+
code: '102',
|
71
|
+
rates: [{ percentage: 0.05, country: 'US', region: 'PA' }]
|
72
|
+
)
|
73
|
+
|
74
|
+
item_2 = Order::Item.new
|
75
|
+
@adjustments_to_tax.concat([
|
76
|
+
@item.price_adjustments.build(
|
77
|
+
price: 'item',
|
78
|
+
amount: -1.to_m,
|
79
|
+
data: { 'discount_value' => 1.to_m }
|
80
|
+
),
|
81
|
+
item_2.price_adjustments.build(
|
82
|
+
price: 'item',
|
83
|
+
amount: 10.to_m,
|
84
|
+
data: { 'tax_code' => 102 }
|
85
|
+
)
|
86
|
+
])
|
87
|
+
|
88
|
+
applier = TaxApplier.new(@shipping, @adjustments_to_tax)
|
89
|
+
applier.apply
|
90
|
+
@shipping.save!
|
91
|
+
|
92
|
+
@shipping.reload
|
93
|
+
|
94
|
+
assert_equal(2, @shipping.price_adjustments.count)
|
95
|
+
assert_equal([0.28.to_m, 0.50.to_m], @shipping.price_adjustments.map(&:amount))
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_partial_shipping_quantity_tax_calculation
|
99
|
+
create_tax_category(code: '101')
|
100
|
+
@item.quantity = 2
|
101
|
+
|
102
|
+
item_two = Order::Item.new
|
103
|
+
@adjustments_to_tax.concat([
|
104
|
+
item_two.price_adjustments.build(
|
105
|
+
price: 'item',
|
106
|
+
amount: 3.to_m,
|
107
|
+
data: { 'tax_code' => 101 }
|
108
|
+
)
|
109
|
+
])
|
110
|
+
|
111
|
+
@shipping.update_attributes!(quantities: { @item.id => 1 })
|
112
|
+
|
113
|
+
applier = TaxApplier.new(@shipping, @adjustments_to_tax)
|
114
|
+
applier.apply
|
115
|
+
@shipping.save!
|
116
|
+
|
117
|
+
@shipping.reload
|
118
|
+
assert_equal(1, @shipping.price_adjustments.count)
|
119
|
+
price_adjustment = @shipping.price_adjustments.last
|
120
|
+
assert_equal('tax', price_adjustment.price)
|
121
|
+
assert_equal(0.15.to_m, price_adjustment.amount)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
@@ -0,0 +1,1398 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
class PricingTest < TestCase
|
5
|
+
def test_properly_rounds_percent_based_discount
|
6
|
+
product = create_product
|
7
|
+
category = create_category(product_ids: [product.id])
|
8
|
+
|
9
|
+
sku = product.skus.first
|
10
|
+
|
11
|
+
pricing_sku = Workarea::Pricing::Sku.find(sku)
|
12
|
+
pricing_sku.prices.first.regular = 1.55.to_m
|
13
|
+
pricing_sku.save!
|
14
|
+
|
15
|
+
create_category_discount(
|
16
|
+
category_ids: [category.id],
|
17
|
+
amount_type: 'percent',
|
18
|
+
amount: 15,
|
19
|
+
order_total: 250.to_m
|
20
|
+
)
|
21
|
+
|
22
|
+
order = Workarea::Order.new
|
23
|
+
order.add_item(product_id: product.id, sku: sku, quantity: 500)
|
24
|
+
item = order.items.first
|
25
|
+
item.category_ids = [category.id]
|
26
|
+
order.save!
|
27
|
+
|
28
|
+
Workarea::Pricing.perform(order)
|
29
|
+
|
30
|
+
assert_equal(2, order.items.first.price_adjustments.length)
|
31
|
+
assert_equal(-116.25.to_m, order.items.first.price_adjustments.last.amount)
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_calculates_item_pricing
|
35
|
+
create_pricing_sku(id: 'SKU', prices: [{ regular: 5.to_m }])
|
36
|
+
|
37
|
+
order = Order.new
|
38
|
+
order.add_item(product_id: 'PRODUCT', sku: 'SKU', quantity: 2)
|
39
|
+
|
40
|
+
Pricing.perform(order)
|
41
|
+
|
42
|
+
assert_equal(1, order.items.first.price_adjustments.length)
|
43
|
+
assert_equal(10.to_m, order.items.first.total_value)
|
44
|
+
assert_equal(10.to_m, order.items.first.total_price)
|
45
|
+
assert_equal(10.to_m, order.subtotal_price)
|
46
|
+
assert_equal(10.to_m, order.total_value)
|
47
|
+
assert_equal(10.to_m, order.total_price)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_adds_product_discounts
|
51
|
+
create_pricing_sku(id: 'SKU', prices: [{ regular: 5.to_m }])
|
52
|
+
|
53
|
+
create_product_discount(
|
54
|
+
amount_type: 'flat',
|
55
|
+
amount: 1,
|
56
|
+
product_ids: ['PRODUCT']
|
57
|
+
)
|
58
|
+
|
59
|
+
order = Order.new
|
60
|
+
order.add_item(product_id: 'PRODUCT', sku: 'SKU')
|
61
|
+
|
62
|
+
Pricing.perform(order)
|
63
|
+
|
64
|
+
assert_equal(2, order.items.first.price_adjustments.length)
|
65
|
+
assert_equal(4.to_m, order.items.first.total_value)
|
66
|
+
assert_equal(4.to_m, order.items.first.total_price)
|
67
|
+
assert_equal(4.to_m, order.subtotal_price)
|
68
|
+
assert_equal(4.to_m, order.total_value)
|
69
|
+
assert_equal(4.to_m, order.total_price)
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_adds_free_items_from_discounts
|
73
|
+
create_product(
|
74
|
+
name: "Test Product",
|
75
|
+
id: "TESTPRODUCT",
|
76
|
+
variants: [
|
77
|
+
{ sku: "FREESKU" }
|
78
|
+
]
|
79
|
+
)
|
80
|
+
|
81
|
+
create_pricing_sku(id: 'SKU1', prices: [{ regular: 5.to_m }])
|
82
|
+
|
83
|
+
create_free_gift_discount(
|
84
|
+
name: 'Test Discount',
|
85
|
+
sku: 'FREESKU'
|
86
|
+
)
|
87
|
+
|
88
|
+
order = Order.new
|
89
|
+
order.add_item(product_id: 'PRODUCT', sku: 'SKU1')
|
90
|
+
|
91
|
+
Pricing.perform(order)
|
92
|
+
|
93
|
+
assert_equal(1, order.items.first.price_adjustments.length)
|
94
|
+
assert_equal(5.to_m, order.items.first.total_value)
|
95
|
+
assert_equal(5.to_m, order.items.first.total_price)
|
96
|
+
assert_equal('TESTPRODUCT', order.items.second.product_id)
|
97
|
+
assert_equal('FREESKU', order.items.second.sku)
|
98
|
+
assert_equal({ 'en' => 'Test Product' }, order.items.second.product_attributes['name'])
|
99
|
+
assert_equal(1, order.items.second.price_adjustments.length)
|
100
|
+
assert_equal(0.to_m, order.items.second.total_price)
|
101
|
+
assert_equal(5.to_m, order.subtotal_price)
|
102
|
+
assert_equal(5.to_m, order.total_value)
|
103
|
+
assert_equal(5.to_m, order.total_price)
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_removes_free_gifts_if_no_other_items_are_present
|
107
|
+
create_product(id: 'PRODUCT', variants: [{ sku: 'SKU2', regular: 3.to_m }])
|
108
|
+
create_pricing_sku(id: 'SKU1', prices: [{ regular: 5.to_m }])
|
109
|
+
|
110
|
+
create_free_gift_discount(
|
111
|
+
sku: 'SKU2',
|
112
|
+
promo_codes: ['FOO']
|
113
|
+
)
|
114
|
+
|
115
|
+
order = Order.new
|
116
|
+
order.add_item(product_id: 'PRODUCT', sku: 'SKU1')
|
117
|
+
order.add_promo_code('foo')
|
118
|
+
|
119
|
+
Pricing.perform(order)
|
120
|
+
|
121
|
+
order.remove_item(order.items.first.id)
|
122
|
+
|
123
|
+
Pricing.perform(order)
|
124
|
+
|
125
|
+
assert(order.items.empty?)
|
126
|
+
end
|
127
|
+
|
128
|
+
def test_fresh_requests_dont_remove_free_gifts
|
129
|
+
create_product(
|
130
|
+
name: "Test Product",
|
131
|
+
id: "TESTPRODUCT",
|
132
|
+
variants: [
|
133
|
+
{ sku: "FREESKU" }
|
134
|
+
]
|
135
|
+
)
|
136
|
+
|
137
|
+
create_pricing_sku(id: 'SKU1', prices: [{ regular: 5.to_m }])
|
138
|
+
|
139
|
+
create_free_gift_discount(
|
140
|
+
name: 'Test Discount',
|
141
|
+
sku: 'FREESKU'
|
142
|
+
)
|
143
|
+
|
144
|
+
order = Order.new
|
145
|
+
order.add_item(product_id: 'PRODUCT', sku: 'SKU1')
|
146
|
+
|
147
|
+
Pricing.perform(order)
|
148
|
+
Pricing.perform(order)
|
149
|
+
|
150
|
+
assert_equal(1, order.items.first.price_adjustments.length)
|
151
|
+
assert_equal(5.to_m, order.items.first.total_value)
|
152
|
+
assert_equal(5.to_m, order.items.first.total_price)
|
153
|
+
assert_equal('TESTPRODUCT', order.items.second.product_id)
|
154
|
+
assert_equal('FREESKU', order.items.second.sku)
|
155
|
+
assert_equal({ 'en' => 'Test Product' }, order.items.second.product_attributes['name'])
|
156
|
+
assert_equal(1, order.items.second.price_adjustments.length)
|
157
|
+
assert_equal(0.to_m, order.items.second.total_price)
|
158
|
+
assert_equal(5.to_m, order.subtotal_price)
|
159
|
+
assert_equal(5.to_m, order.total_value)
|
160
|
+
assert_equal(5.to_m, order.total_price)
|
161
|
+
end
|
162
|
+
|
163
|
+
def test_adds_customizations_cost
|
164
|
+
create_pricing_sku(id: 'SKU', prices: [{ regular: 5.to_m }])
|
165
|
+
create_pricing_sku(id: 'CUST', prices: [{ regular: 1.to_m }])
|
166
|
+
|
167
|
+
order = Order.new
|
168
|
+
order.add_item(
|
169
|
+
product_id: 'PRODUCT',
|
170
|
+
sku: 'SKU',
|
171
|
+
quantity: 2,
|
172
|
+
customizations: { 'pricing_sku' => 'CUST' }
|
173
|
+
)
|
174
|
+
|
175
|
+
Pricing.perform(order)
|
176
|
+
|
177
|
+
assert_equal(12.to_m, order.items.first.total_value)
|
178
|
+
assert_equal(12.to_m, order.items.first.total_price)
|
179
|
+
assert_equal(12.to_m, order.subtotal_price)
|
180
|
+
assert_equal(12.to_m, order.total_value)
|
181
|
+
assert_equal(12.to_m, order.total_price)
|
182
|
+
end
|
183
|
+
|
184
|
+
def test_adds_item_tax
|
185
|
+
create_pricing_sku(id: 'SKU', tax_code: '001', prices: [{ regular: 5.to_m }])
|
186
|
+
create_tax_category(
|
187
|
+
code: '001',
|
188
|
+
rates: [{ percentage: 0.06, region: 'PA', country: 'US' }]
|
189
|
+
)
|
190
|
+
|
191
|
+
order = Order.new
|
192
|
+
order.add_item(product_id: 'PRODUCT', sku: 'SKU')
|
193
|
+
|
194
|
+
shipping = Shipping.new
|
195
|
+
shipping.set_address(
|
196
|
+
first_name: 'Ben',
|
197
|
+
last_name: 'Crouse',
|
198
|
+
street: '22 S. 3rd St.',
|
199
|
+
street_2: 'Second Floor',
|
200
|
+
city: 'Philadelphia',
|
201
|
+
region: 'PA',
|
202
|
+
postal_code: '19106',
|
203
|
+
country: 'US',
|
204
|
+
phone_number: '2159251800'
|
205
|
+
)
|
206
|
+
|
207
|
+
Pricing.perform(order, shipping)
|
208
|
+
|
209
|
+
assert_equal(5.to_m, order.items.first.total_value)
|
210
|
+
assert_equal(5.to_m, order.items.first.total_price)
|
211
|
+
assert_equal(5.to_m, order.subtotal_price)
|
212
|
+
assert_equal(0.30.to_m, order.tax_total)
|
213
|
+
assert_equal(5.to_m, order.total_value)
|
214
|
+
assert_equal(5.30.to_m, order.total_price)
|
215
|
+
end
|
216
|
+
|
217
|
+
def test_adds_shipping_cost
|
218
|
+
order = Order.new
|
219
|
+
|
220
|
+
shipping = Shipping.new
|
221
|
+
shipping.set_shipping_service(
|
222
|
+
id: 'GROUND',
|
223
|
+
name: 'Ground',
|
224
|
+
tax_code: '001',
|
225
|
+
base_price: 3.to_m
|
226
|
+
)
|
227
|
+
shipping.set_address(
|
228
|
+
first_name: 'Ben',
|
229
|
+
last_name: 'Crouse',
|
230
|
+
street: '22 S. 3rd St.',
|
231
|
+
street_2: 'Second Floor',
|
232
|
+
city: 'Philadelphia',
|
233
|
+
region: 'PA',
|
234
|
+
postal_code: '19106',
|
235
|
+
country: 'US',
|
236
|
+
phone_number: '2159251800'
|
237
|
+
)
|
238
|
+
|
239
|
+
Pricing.perform(order, shipping)
|
240
|
+
|
241
|
+
assert_equal(3.to_m, order.shipping_total)
|
242
|
+
assert_equal(0.to_m, order.total_value)
|
243
|
+
assert_equal(3.to_m, order.total_price)
|
244
|
+
end
|
245
|
+
|
246
|
+
def test_adds_shipping_tax
|
247
|
+
create_pricing_sku(
|
248
|
+
id: 'SKU',
|
249
|
+
tax_code: '001',
|
250
|
+
prices: [{ regular: 5.to_m }]
|
251
|
+
)
|
252
|
+
|
253
|
+
create_tax_category(
|
254
|
+
code: '001',
|
255
|
+
rates: [{
|
256
|
+
percentage: 0.06,
|
257
|
+
region: 'PA',
|
258
|
+
country: 'US',
|
259
|
+
charge_on_shipping: true
|
260
|
+
}]
|
261
|
+
)
|
262
|
+
|
263
|
+
order = Order.new
|
264
|
+
order.add_item(product_id: 'PRODUCT', sku: 'SKU')
|
265
|
+
|
266
|
+
shipping = Shipping.new
|
267
|
+
shipping.set_shipping_service(
|
268
|
+
id: 'GROUND',
|
269
|
+
name: 'Ground',
|
270
|
+
tax_code: '001',
|
271
|
+
base_price: 3.to_m
|
272
|
+
)
|
273
|
+
shipping.set_address(
|
274
|
+
first_name: 'Ben',
|
275
|
+
last_name: 'Crouse',
|
276
|
+
street: '22 S. 3rd St.',
|
277
|
+
street_2: 'Second Floor',
|
278
|
+
city: 'Philadelphia',
|
279
|
+
region: 'PA',
|
280
|
+
postal_code: '19106',
|
281
|
+
country: 'US',
|
282
|
+
phone_number: '2159251800'
|
283
|
+
)
|
284
|
+
|
285
|
+
Pricing.perform(order, shipping)
|
286
|
+
|
287
|
+
assert_equal(5.to_m, order.items.first.total_value)
|
288
|
+
assert_equal(5.to_m, order.items.first.total_price)
|
289
|
+
assert_equal(5.to_m, order.subtotal_price)
|
290
|
+
assert_equal(0.48.to_m, order.tax_total)
|
291
|
+
assert_equal(5.to_m, order.total_value)
|
292
|
+
assert_equal(8.48.to_m, order.total_price)
|
293
|
+
end
|
294
|
+
|
295
|
+
def test_adds_shipping_discounts
|
296
|
+
create_pricing_sku(id: 'SKU', prices: [{ regular: 5.to_m }])
|
297
|
+
|
298
|
+
create_shipping_discount(
|
299
|
+
name: 'Second Discount',
|
300
|
+
amount: 0,
|
301
|
+
shipping_service: 'Ground'
|
302
|
+
)
|
303
|
+
|
304
|
+
order = Order.new
|
305
|
+
order.add_item(product_id: 'PRODUCT', sku: 'SKU')
|
306
|
+
|
307
|
+
shipping = Shipping.new
|
308
|
+
shipping.set_shipping_service(
|
309
|
+
name: 'Ground',
|
310
|
+
tax_code: '001',
|
311
|
+
base_price: 3.to_m
|
312
|
+
)
|
313
|
+
shipping.set_address(
|
314
|
+
first_name: 'Ben',
|
315
|
+
last_name: 'Crouse',
|
316
|
+
street: '22 S. 3rd St.',
|
317
|
+
street_2: 'Second Floor',
|
318
|
+
city: 'Philadelphia',
|
319
|
+
region: 'PA',
|
320
|
+
postal_code: '19106',
|
321
|
+
country: 'US',
|
322
|
+
phone_number: '2159251800'
|
323
|
+
)
|
324
|
+
|
325
|
+
Pricing.perform(order, shipping)
|
326
|
+
|
327
|
+
assert_equal(0.to_m, order.shipping_total)
|
328
|
+
assert_equal(5.to_m, order.total_value)
|
329
|
+
assert_equal(5.to_m, order.total_price)
|
330
|
+
end
|
331
|
+
|
332
|
+
def test_handles_multiple_shippings
|
333
|
+
order = Order.new
|
334
|
+
|
335
|
+
shipping_one = Shipping.new
|
336
|
+
shipping_one.set_shipping_service(
|
337
|
+
id: 'GROUND',
|
338
|
+
name: 'Ground',
|
339
|
+
tax_code: '001',
|
340
|
+
base_price: 3.to_m
|
341
|
+
)
|
342
|
+
shipping_one.set_address(
|
343
|
+
first_name: 'Ben',
|
344
|
+
last_name: 'Crouse',
|
345
|
+
street: '22 S. 3rd St.',
|
346
|
+
street_2: 'Second Floor',
|
347
|
+
city: 'Philadelphia',
|
348
|
+
region: 'PA',
|
349
|
+
postal_code: '19106',
|
350
|
+
country: 'US',
|
351
|
+
phone_number: '2159251800'
|
352
|
+
)
|
353
|
+
|
354
|
+
shipping_two = Shipping.new
|
355
|
+
shipping_two.set_shipping_service(
|
356
|
+
id: '2DAY',
|
357
|
+
name: 'Second Day',
|
358
|
+
tax_code: '001',
|
359
|
+
base_price: 10.to_m
|
360
|
+
)
|
361
|
+
shipping_one.set_address(
|
362
|
+
first_name: 'Ben',
|
363
|
+
last_name: 'Crouse',
|
364
|
+
street: '22 S. 3rd St.',
|
365
|
+
street_2: 'Second Floor',
|
366
|
+
city: 'Philadelphia',
|
367
|
+
region: 'PA',
|
368
|
+
postal_code: '19106',
|
369
|
+
country: 'US',
|
370
|
+
phone_number: '2159251800'
|
371
|
+
)
|
372
|
+
|
373
|
+
|
374
|
+
Pricing.perform(order, [shipping_one, shipping_two])
|
375
|
+
|
376
|
+
assert_equal(13.to_m, order.shipping_total)
|
377
|
+
assert_equal(13.to_m, order.total_price)
|
378
|
+
end
|
379
|
+
|
380
|
+
def test_adds_order_total_discounts
|
381
|
+
create_pricing_sku(id: 'SKU', prices: [{ regular: 5.to_m }])
|
382
|
+
|
383
|
+
create_order_total_discount(
|
384
|
+
name: 'Discount',
|
385
|
+
amount_type: 'flat',
|
386
|
+
amount: 2
|
387
|
+
)
|
388
|
+
|
389
|
+
order = Order.new
|
390
|
+
order.add_item(product_id: 'PRODUCT', sku: 'SKU')
|
391
|
+
|
392
|
+
Pricing.perform(order)
|
393
|
+
|
394
|
+
assert_equal(3.to_m, order.items.first.total_value)
|
395
|
+
assert_equal(5.to_m, order.subtotal_price)
|
396
|
+
assert_equal(3.to_m, order.total_value)
|
397
|
+
assert_equal(3.to_m, order.total_price)
|
398
|
+
end
|
399
|
+
|
400
|
+
def test_adds_bogo_discounts
|
401
|
+
create_pricing_sku(id: 'SKU', prices: [{ regular: 5.to_m }])
|
402
|
+
|
403
|
+
create_buy_some_get_some_discount(
|
404
|
+
name: 'Test Discount',
|
405
|
+
purchase_quantity: 1,
|
406
|
+
apply_quantity: 1,
|
407
|
+
percent_off: 100,
|
408
|
+
product_ids: ['PRODUCT']
|
409
|
+
)
|
410
|
+
|
411
|
+
order = Order.new
|
412
|
+
order.add_item(product_id: 'PRODUCT', sku: 'SKU', quantity: 2)
|
413
|
+
|
414
|
+
Pricing.perform(order)
|
415
|
+
|
416
|
+
assert_equal(5.to_m, order.items.first.total_value)
|
417
|
+
assert_equal(5.to_m, order.subtotal_price)
|
418
|
+
assert_equal(5.to_m, order.total_value)
|
419
|
+
assert_equal(5.to_m, order.total_price)
|
420
|
+
end
|
421
|
+
|
422
|
+
def test_finds_complete_pricing_for_an_order
|
423
|
+
create_pricing_sku(id: 'SKU1', tax_code: '001', prices: [{ regular: 5.to_m }])
|
424
|
+
create_pricing_sku(id: 'SKU2', tax_code: '001', prices: [{ regular: 7.to_m }])
|
425
|
+
|
426
|
+
create_order_total_discount(
|
427
|
+
name: 'Test Discount',
|
428
|
+
amount_type: 'flat',
|
429
|
+
amount: 1
|
430
|
+
)
|
431
|
+
|
432
|
+
create_tax_category(
|
433
|
+
code: '001',
|
434
|
+
rates: [{ percentage: 0.06, region: 'PA', country: 'US' }]
|
435
|
+
)
|
436
|
+
|
437
|
+
order = Order.new
|
438
|
+
order.add_item(product_id: 'PRODUCT1', sku: 'SKU1')
|
439
|
+
order.add_item(product_id: 'PRODUCT2', sku: 'SKU2')
|
440
|
+
|
441
|
+
shipping = Shipping.new
|
442
|
+
|
443
|
+
shipping.set_address(
|
444
|
+
first_name: 'Ben',
|
445
|
+
last_name: 'Crouse',
|
446
|
+
street: '22 S. 3rd St.',
|
447
|
+
street_2: 'Second Floor',
|
448
|
+
city: 'Philadelphia',
|
449
|
+
region: 'PA',
|
450
|
+
postal_code: '19106',
|
451
|
+
country: 'US',
|
452
|
+
phone_number: '2159251800'
|
453
|
+
)
|
454
|
+
|
455
|
+
shipping.set_shipping_service(
|
456
|
+
id: 'GROUND',
|
457
|
+
name: 'Ground',
|
458
|
+
base_price: 3.to_m,
|
459
|
+
tax_code: '001'
|
460
|
+
)
|
461
|
+
|
462
|
+
Pricing.perform(order, shipping)
|
463
|
+
|
464
|
+
assert_equal(12.to_m, order.subtotal_price)
|
465
|
+
assert_equal(3.to_m, order.shipping_total)
|
466
|
+
assert_equal(0.84.to_m, order.tax_total)
|
467
|
+
assert_equal(11.to_m, order.total_value)
|
468
|
+
assert_equal(14.84.to_m, order.total_price)
|
469
|
+
end
|
470
|
+
|
471
|
+
def test_does_not_allow_negative_priced_orders_from_too_many_discounts
|
472
|
+
create_pricing_sku(id: 'SKU1', tax_code: '001', prices: [{ regular: 5.to_m }])
|
473
|
+
create_pricing_sku(id: 'SKU2', tax_code: '001', prices: [{ regular: 7.to_m }])
|
474
|
+
|
475
|
+
fixed_price_discount = create_quantity_fixed_price_discount(
|
476
|
+
name: 'Test 1 Discount',
|
477
|
+
quantity: 2,
|
478
|
+
price: 1,
|
479
|
+
product_ids: %w(PRODUCT1 PRODUCT2)
|
480
|
+
)
|
481
|
+
|
482
|
+
create_order_total_discount(
|
483
|
+
name: 'Test 2 Discount',
|
484
|
+
amount_type: 'flat',
|
485
|
+
amount: 10,
|
486
|
+
compatible_discount_ids: [fixed_price_discount.id.to_s]
|
487
|
+
)
|
488
|
+
|
489
|
+
create_tax_category(
|
490
|
+
code: '001',
|
491
|
+
rates: [{ percentage: 0.06, region: 'PA', country: 'US' }]
|
492
|
+
)
|
493
|
+
|
494
|
+
order = Order.new
|
495
|
+
order.add_item(product_id: 'PRODUCT1', sku: 'SKU1')
|
496
|
+
order.add_item(product_id: 'PRODUCT2', sku: 'SKU2')
|
497
|
+
|
498
|
+
shipping = Shipping.new
|
499
|
+
|
500
|
+
shipping.set_address(
|
501
|
+
first_name: 'Ben',
|
502
|
+
last_name: 'Crouse',
|
503
|
+
street: '22 S. 3rd St.',
|
504
|
+
street_2: 'Second Floor',
|
505
|
+
city: 'Philadelphia',
|
506
|
+
region: 'PA',
|
507
|
+
postal_code: '19106',
|
508
|
+
country: 'US',
|
509
|
+
phone_number: '2159251800'
|
510
|
+
)
|
511
|
+
|
512
|
+
shipping.set_shipping_service(
|
513
|
+
id: 'GROUND',
|
514
|
+
name: 'Ground',
|
515
|
+
base_price: 3.to_m,
|
516
|
+
tax_code: '001'
|
517
|
+
)
|
518
|
+
|
519
|
+
Pricing.perform(order, shipping)
|
520
|
+
|
521
|
+
assert_equal(12.to_m, order.subtotal_price)
|
522
|
+
assert_equal(3.to_m, order.shipping_total)
|
523
|
+
assert_equal(0.18.to_m, order.tax_total)
|
524
|
+
assert_equal(3.18.to_m, order.total_price)
|
525
|
+
end
|
526
|
+
|
527
|
+
def test_combines_a_category_and_buy_some_get_some_discount_that_are_compatible
|
528
|
+
create_pricing_sku(id: 'SKU', prices: [{ regular: 5.to_m }])
|
529
|
+
|
530
|
+
buy_some_get_some = create_buy_some_get_some_discount(
|
531
|
+
purchase_quantity: 2,
|
532
|
+
apply_quantity: 1,
|
533
|
+
percent_off: 100,
|
534
|
+
product_ids: ['PRODUCT']
|
535
|
+
)
|
536
|
+
|
537
|
+
create_product_discount(
|
538
|
+
amount_type: 'percent',
|
539
|
+
amount: 10,
|
540
|
+
product_ids: ['PRODUCT'],
|
541
|
+
compatible_discount_ids: [buy_some_get_some.id]
|
542
|
+
)
|
543
|
+
|
544
|
+
order = Order.new
|
545
|
+
order.add_item(product_id: 'PRODUCT', sku: 'SKU', quantity: 3)
|
546
|
+
|
547
|
+
Pricing.perform(order)
|
548
|
+
|
549
|
+
assert_equal(9.to_m, order.items.first.total_value)
|
550
|
+
assert_equal(-1.5.to_m, order.items.first.price_adjustments.second.amount)
|
551
|
+
assert_equal(-4.5.to_m, order.items.first.price_adjustments.third.amount)
|
552
|
+
|
553
|
+
assert_equal(9.to_m, order.subtotal_price)
|
554
|
+
assert_equal(9.to_m, order.total_price)
|
555
|
+
end
|
556
|
+
|
557
|
+
def test_combines_a_category_and_buy_some_get_some_discount_that_are_incompatible
|
558
|
+
create_pricing_sku(id: 'SKU', prices: [{ regular: 5.to_m }])
|
559
|
+
|
560
|
+
create_buy_some_get_some_discount(
|
561
|
+
purchase_quantity: 2,
|
562
|
+
apply_quantity: 1,
|
563
|
+
percent_off: 100,
|
564
|
+
product_ids: ['PRODUCT']
|
565
|
+
)
|
566
|
+
|
567
|
+
create_product_discount(
|
568
|
+
amount_type: 'percent',
|
569
|
+
amount: 10,
|
570
|
+
product_ids: ['PRODUCT']
|
571
|
+
)
|
572
|
+
|
573
|
+
order = Order.new
|
574
|
+
order.add_item(product_id: 'PRODUCT', sku: 'SKU', quantity: 3)
|
575
|
+
|
576
|
+
Pricing.perform(order)
|
577
|
+
|
578
|
+
assert_equal(10.to_m, order.items.first.total_value)
|
579
|
+
assert_equal(-5.to_m, order.items.first.price_adjustments.second.amount)
|
580
|
+
|
581
|
+
assert_equal(10.to_m, order.subtotal_price)
|
582
|
+
assert_equal(10.to_m, order.total_price)
|
583
|
+
end
|
584
|
+
|
585
|
+
def test_combines_a_quantity_fixed_price_and_order_total_discount
|
586
|
+
create_pricing_sku(id: 'SKU', prices: [{ regular: 5.to_m }])
|
587
|
+
|
588
|
+
quantity_fixed_price = create_quantity_fixed_price_discount(
|
589
|
+
quantity: 3,
|
590
|
+
price: 12,
|
591
|
+
product_ids: ['PRODUCT']
|
592
|
+
)
|
593
|
+
|
594
|
+
create_order_total_discount(
|
595
|
+
amount_type: 'percent',
|
596
|
+
amount: 10,
|
597
|
+
compatible_discount_ids: [quantity_fixed_price.id]
|
598
|
+
)
|
599
|
+
|
600
|
+
order = Order.new
|
601
|
+
order.add_item(product_id: 'PRODUCT', sku: 'SKU', quantity: 3)
|
602
|
+
|
603
|
+
Pricing.perform(order)
|
604
|
+
|
605
|
+
assert_equal(15.to_m, order.items.first.total_price)
|
606
|
+
assert_equal(-3.to_m, order.items.first.price_adjustments.second.amount)
|
607
|
+
assert_equal(-1.2.to_m, order.items.first.price_adjustments.third.amount)
|
608
|
+
|
609
|
+
assert_equal(15.to_m, order.subtotal_price)
|
610
|
+
assert_equal(10.8.to_m, order.total_price)
|
611
|
+
end
|
612
|
+
|
613
|
+
def test_combines_a_shipping_discount_and_an_order_total_discount
|
614
|
+
create_pricing_sku(id: 'SKU', prices: [{ regular: 5.to_m }])
|
615
|
+
|
616
|
+
shipping_discount = create_shipping_discount(
|
617
|
+
name: 'Second Discount',
|
618
|
+
amount: 0,
|
619
|
+
shipping_service: 'Ground'
|
620
|
+
)
|
621
|
+
|
622
|
+
create_order_total_discount(
|
623
|
+
amount_type: 'percent',
|
624
|
+
amount: 10,
|
625
|
+
compatible_discount_ids: [shipping_discount.id]
|
626
|
+
)
|
627
|
+
|
628
|
+
order = Order.new
|
629
|
+
order.add_item(product_id: 'PRODUCT', sku: 'SKU')
|
630
|
+
|
631
|
+
shipping = Shipping.new
|
632
|
+
shipping.set_shipping_service(
|
633
|
+
name: 'Ground',
|
634
|
+
tax_code: '001',
|
635
|
+
base_price: 3.to_m
|
636
|
+
)
|
637
|
+
shipping.set_address(
|
638
|
+
first_name: 'Ben',
|
639
|
+
last_name: 'Crouse',
|
640
|
+
street: '22 S. 3rd St.',
|
641
|
+
street_2: 'Second Floor',
|
642
|
+
city: 'Philadelphia',
|
643
|
+
region: 'PA',
|
644
|
+
postal_code: '19106',
|
645
|
+
country: 'US',
|
646
|
+
phone_number: '2159251800'
|
647
|
+
)
|
648
|
+
|
649
|
+
Pricing.perform(order, shipping)
|
650
|
+
|
651
|
+
assert_equal(0.to_m, order.shipping_total)
|
652
|
+
assert_equal(4.5.to_m, order.total_price)
|
653
|
+
end
|
654
|
+
|
655
|
+
def test_ignores_disqualified_item_discount
|
656
|
+
create_pricing_sku(id: 'SKU', prices: [{ regular: 5.to_m }])
|
657
|
+
|
658
|
+
first = create_product_discount(
|
659
|
+
name: 'Test Discount',
|
660
|
+
amount_type: 'flat',
|
661
|
+
amount: 2,
|
662
|
+
product_ids: ['PRODUCT']
|
663
|
+
)
|
664
|
+
|
665
|
+
create_product_discount(
|
666
|
+
name: 'Test Discount',
|
667
|
+
amount_type: 'flat',
|
668
|
+
amount: 1,
|
669
|
+
product_ids: ['PRODUCT']
|
670
|
+
)
|
671
|
+
|
672
|
+
order = Order.new
|
673
|
+
order.add_item(product_id: 'PRODUCT', sku: 'SKU')
|
674
|
+
|
675
|
+
Pricing.perform(order)
|
676
|
+
|
677
|
+
assert_equal(2, order.items.first.price_adjustments.length)
|
678
|
+
assert_equal(-2.to_m, order.items.first.price_adjustments.last.amount)
|
679
|
+
assert_equal(first.id.to_s, order.items.first.price_adjustments.last.data['discount_id'])
|
680
|
+
end
|
681
|
+
|
682
|
+
def test_respecting_compatible_item_discounts
|
683
|
+
create_pricing_sku(id: 'SKU', prices: [{ regular: 5.to_m }])
|
684
|
+
|
685
|
+
first = create_product_discount(
|
686
|
+
name: 'Test Discount',
|
687
|
+
amount_type: 'flat',
|
688
|
+
amount: 2,
|
689
|
+
product_ids: ['PRODUCT']
|
690
|
+
)
|
691
|
+
|
692
|
+
second = create_product_discount(
|
693
|
+
name: 'Test Discount',
|
694
|
+
amount_type: 'flat',
|
695
|
+
amount: 1,
|
696
|
+
product_ids: ['PRODUCT'],
|
697
|
+
compatible_discount_ids: [first.id.to_s]
|
698
|
+
)
|
699
|
+
|
700
|
+
first.compatible_discount_ids = [second.id.to_s]
|
701
|
+
first.save!
|
702
|
+
|
703
|
+
order = Order.new
|
704
|
+
order.add_item(product_id: 'PRODUCT', sku: 'SKU')
|
705
|
+
|
706
|
+
Pricing.perform(order)
|
707
|
+
|
708
|
+
assert_equal(3, order.items.first.price_adjustments.length)
|
709
|
+
|
710
|
+
discount_1_adjustment = order
|
711
|
+
.items
|
712
|
+
.first
|
713
|
+
.price_adjustments
|
714
|
+
.detect { |a| a.data['discount_id'] == first.id.to_s }
|
715
|
+
|
716
|
+
discount_2_adjustment = order
|
717
|
+
.items
|
718
|
+
.first
|
719
|
+
.price_adjustments
|
720
|
+
.detect { |a| a.data['discount_id'] == second.id.to_s }
|
721
|
+
|
722
|
+
assert_equal(-2.to_m, discount_1_adjustment.amount)
|
723
|
+
assert_equal(-1.to_m, discount_2_adjustment.amount)
|
724
|
+
end
|
725
|
+
|
726
|
+
def test_respects_compatible_item_discount
|
727
|
+
create_pricing_sku(id: 'SKU', prices: [{ regular: 5.to_m }])
|
728
|
+
|
729
|
+
first = create_product_discount(
|
730
|
+
name: 'Test Discount',
|
731
|
+
amount_type: 'flat',
|
732
|
+
amount: 2,
|
733
|
+
product_ids: ['PRODUCT']
|
734
|
+
)
|
735
|
+
|
736
|
+
second = create_product_discount(
|
737
|
+
name: 'Test Discount',
|
738
|
+
amount_type: 'flat',
|
739
|
+
amount: 1,
|
740
|
+
product_ids: ['PRODUCT'],
|
741
|
+
compatible_discount_ids: [first.id.to_s]
|
742
|
+
)
|
743
|
+
|
744
|
+
first.compatible_discount_ids = [second.id.to_s]
|
745
|
+
first.save!
|
746
|
+
|
747
|
+
order = Order.new
|
748
|
+
order.add_item(product_id: 'PRODUCT', sku: 'SKU')
|
749
|
+
|
750
|
+
Pricing.perform(order)
|
751
|
+
|
752
|
+
assert_equal(3, order.items.first.price_adjustments.length)
|
753
|
+
assert_equal(-2.to_m, order.items.first.price_adjustments.second.amount)
|
754
|
+
assert_equal(first.id.to_s, order.items.first.price_adjustments.second.data['discount_id'])
|
755
|
+
assert_equal(-1.to_m, order.items.first.price_adjustments.third.amount)
|
756
|
+
assert_equal(second.id.to_s, order.items.first.price_adjustments.third.data['discount_id'])
|
757
|
+
end
|
758
|
+
|
759
|
+
def test_uses_shipping_discounts_when_higher_value
|
760
|
+
create_pricing_sku(id: 'SKU', prices: [{ regular: 10.to_m }])
|
761
|
+
|
762
|
+
create_product_discount(
|
763
|
+
name: 'First Discount',
|
764
|
+
amount_type: 'flat',
|
765
|
+
amount: 1,
|
766
|
+
product_ids: ['PRODUCT']
|
767
|
+
)
|
768
|
+
|
769
|
+
shipping_discount = create_shipping_discount(
|
770
|
+
name: 'Second Discount',
|
771
|
+
amount: 0,
|
772
|
+
shipping_service: 'Ground'
|
773
|
+
)
|
774
|
+
|
775
|
+
order = Order.new
|
776
|
+
order.add_item(product_id: 'PRODUCT', sku: 'SKU')
|
777
|
+
|
778
|
+
shipping = Shipping.new
|
779
|
+
shipping.set_shipping_service(
|
780
|
+
id: 'GROUND',
|
781
|
+
name: 'Ground',
|
782
|
+
base_price: 3.to_m
|
783
|
+
)
|
784
|
+
shipping.set_address(
|
785
|
+
first_name: 'Ben',
|
786
|
+
last_name: 'Crouse',
|
787
|
+
street: '22 S. 3rd St.',
|
788
|
+
street_2: 'Second Floor',
|
789
|
+
city: 'Philadelphia',
|
790
|
+
region: 'PA',
|
791
|
+
postal_code: '19106',
|
792
|
+
country: 'US',
|
793
|
+
phone_number: '2159251800'
|
794
|
+
)
|
795
|
+
|
796
|
+
Pricing.perform(order, shipping)
|
797
|
+
|
798
|
+
assert_equal(1, order.items.first.price_adjustments.length)
|
799
|
+
assert_equal('item', order.items.first.price_adjustments.first.price)
|
800
|
+
assert_equal(10.to_m, order.items.first.price_adjustments.first.amount)
|
801
|
+
|
802
|
+
assert_equal(2, shipping.price_adjustments.length)
|
803
|
+
assert_equal('shipping', shipping.price_adjustments.first.price)
|
804
|
+
assert_equal(3.to_m, shipping.price_adjustments.first.amount)
|
805
|
+
assert_equal('shipping', shipping.price_adjustments.second.price)
|
806
|
+
assert_equal(-3.to_m, shipping.price_adjustments.second.amount)
|
807
|
+
assert_equal(shipping_discount.id.to_s, shipping.price_adjustments.second.data['discount_id'])
|
808
|
+
end
|
809
|
+
|
810
|
+
def test_uses_a_product_discount_when_higher_value
|
811
|
+
create_pricing_sku(id: 'SKU', prices: [{ regular: 10.to_m }])
|
812
|
+
|
813
|
+
product_discount = create_product_discount(
|
814
|
+
name: 'First Discount',
|
815
|
+
amount_type: 'flat',
|
816
|
+
amount: 7,
|
817
|
+
product_ids: ['PRODUCT']
|
818
|
+
)
|
819
|
+
|
820
|
+
create_shipping_discount(
|
821
|
+
name: 'Second Discount',
|
822
|
+
amount: 0,
|
823
|
+
shipping_service: 'Ground'
|
824
|
+
)
|
825
|
+
|
826
|
+
order = Order.new
|
827
|
+
order.add_item(product_id: 'PRODUCT', sku: 'SKU')
|
828
|
+
|
829
|
+
shipping = Shipping.new
|
830
|
+
shipping.set_shipping_service(
|
831
|
+
id: 'GROUND',
|
832
|
+
name: 'Ground',
|
833
|
+
base_price: 3.to_m
|
834
|
+
)
|
835
|
+
shipping.set_address(
|
836
|
+
first_name: 'Ben',
|
837
|
+
last_name: 'Crouse',
|
838
|
+
street: '22 S. 3rd St.',
|
839
|
+
street_2: 'Second Floor',
|
840
|
+
city: 'Philadelphia',
|
841
|
+
region: 'PA',
|
842
|
+
postal_code: '19106',
|
843
|
+
country: 'US',
|
844
|
+
phone_number: '2159251800'
|
845
|
+
)
|
846
|
+
|
847
|
+
Pricing.perform(order, shipping)
|
848
|
+
|
849
|
+
assert_equal(2, order.items.first.price_adjustments.length)
|
850
|
+
assert_equal('item', order.items.first.price_adjustments.first.price)
|
851
|
+
assert_equal(10.to_m, order.items.first.price_adjustments.first.amount)
|
852
|
+
assert_equal('item', order.items.first.price_adjustments.second.price)
|
853
|
+
assert_equal(-7.to_m, order.items.first.price_adjustments.second.amount)
|
854
|
+
assert_equal(product_discount.id.to_s, order.items.first.price_adjustments.second.data['discount_id'])
|
855
|
+
|
856
|
+
assert_equal(1, shipping.price_adjustments.length)
|
857
|
+
assert_equal('shipping', shipping.price_adjustments.first.price)
|
858
|
+
assert_equal(3.to_m, shipping.price_adjustments.first.amount)
|
859
|
+
end
|
860
|
+
|
861
|
+
def test_uses_a_product_discount_and_shipping_discount_together
|
862
|
+
create_pricing_sku(id: 'SKU', prices: [{ regular: 10.to_m }])
|
863
|
+
|
864
|
+
product_discount = create_product_discount(
|
865
|
+
name: 'First Discount',
|
866
|
+
amount_type: 'flat',
|
867
|
+
amount: 1,
|
868
|
+
product_ids: ['PRODUCT']
|
869
|
+
)
|
870
|
+
|
871
|
+
shipping_discount = create_shipping_discount(
|
872
|
+
name: 'Second Discount',
|
873
|
+
amount: 0,
|
874
|
+
shipping_service: 'Ground'
|
875
|
+
)
|
876
|
+
|
877
|
+
product_discount.compatible_discount_ids = [shipping_discount.id.to_s]
|
878
|
+
product_discount.save!
|
879
|
+
|
880
|
+
shipping_discount.compatible_discount_ids = [product_discount.id.to_s]
|
881
|
+
shipping_discount.save!
|
882
|
+
|
883
|
+
order = Order.new
|
884
|
+
order.add_item(product_id: 'PRODUCT', sku: 'SKU')
|
885
|
+
|
886
|
+
shipping = Shipping.new
|
887
|
+
shipping.set_shipping_service(
|
888
|
+
name: 'Ground',
|
889
|
+
base_price: 3.to_m
|
890
|
+
)
|
891
|
+
shipping.set_address(
|
892
|
+
first_name: 'Ben',
|
893
|
+
last_name: 'Crouse',
|
894
|
+
street: '22 S. 3rd St.',
|
895
|
+
street_2: 'Second Floor',
|
896
|
+
city: 'Philadelphia',
|
897
|
+
region: 'PA',
|
898
|
+
postal_code: '19106',
|
899
|
+
country: 'US',
|
900
|
+
phone_number: '2159251800'
|
901
|
+
)
|
902
|
+
|
903
|
+
Pricing.perform(order, shipping)
|
904
|
+
|
905
|
+
assert_equal(2, order.items.first.price_adjustments.length)
|
906
|
+
assert_equal('item', order.items.first.price_adjustments.first.price)
|
907
|
+
assert_equal(10.to_m, order.items.first.price_adjustments.first.amount)
|
908
|
+
assert_equal('item', order.items.first.price_adjustments.second.price)
|
909
|
+
assert_equal(-1.to_m, order.items.first.price_adjustments.second.amount)
|
910
|
+
assert_equal(product_discount.id.to_s, order.items.first.price_adjustments.second.data['discount_id'])
|
911
|
+
|
912
|
+
assert_equal(2, shipping.price_adjustments.length)
|
913
|
+
assert_equal('shipping', shipping.price_adjustments.first.price)
|
914
|
+
assert_equal(3.to_m, shipping.price_adjustments.first.amount)
|
915
|
+
assert_equal('shipping', shipping.price_adjustments.second.price)
|
916
|
+
assert_equal(-3.to_m, shipping.price_adjustments.second.amount)
|
917
|
+
assert_equal(shipping_discount.id.to_s, shipping.price_adjustments.second.data['discount_id'])
|
918
|
+
end
|
919
|
+
|
920
|
+
def test_uses_a_product_discount_and_shipping_discount_together_and_ignores_a_lower_value_product_discount
|
921
|
+
create_pricing_sku(id: 'SKU', prices: [{ regular: 10.to_m }])
|
922
|
+
|
923
|
+
create_product_discount(
|
924
|
+
name: 'Ignored Discount',
|
925
|
+
amount_type: 'flat',
|
926
|
+
amount: 0.99,
|
927
|
+
product_ids: ['PRODUCT']
|
928
|
+
)
|
929
|
+
|
930
|
+
product_discount = create_product_discount(
|
931
|
+
name: 'First Discount',
|
932
|
+
amount_type: 'flat',
|
933
|
+
amount: 1,
|
934
|
+
product_ids: ['PRODUCT']
|
935
|
+
)
|
936
|
+
|
937
|
+
shipping_discount = create_shipping_discount(
|
938
|
+
name: 'Second Discount',
|
939
|
+
amount: 0,
|
940
|
+
shipping_service: 'Ground'
|
941
|
+
)
|
942
|
+
|
943
|
+
product_discount.compatible_discount_ids = [shipping_discount.id.to_s]
|
944
|
+
product_discount.save!
|
945
|
+
|
946
|
+
shipping_discount.compatible_discount_ids = [product_discount.id.to_s]
|
947
|
+
shipping_discount.save!
|
948
|
+
|
949
|
+
order = Order.new
|
950
|
+
order.add_item(product_id: 'PRODUCT', sku: 'SKU')
|
951
|
+
|
952
|
+
shipping = Shipping.new
|
953
|
+
shipping.set_shipping_service(
|
954
|
+
name: 'Ground',
|
955
|
+
base_price: 3.to_m
|
956
|
+
)
|
957
|
+
shipping.set_address(
|
958
|
+
first_name: 'Ben',
|
959
|
+
last_name: 'Crouse',
|
960
|
+
street: '22 S. 3rd St.',
|
961
|
+
street_2: 'Second Floor',
|
962
|
+
city: 'Philadelphia',
|
963
|
+
region: 'PA',
|
964
|
+
postal_code: '19106',
|
965
|
+
country: 'US',
|
966
|
+
phone_number: '2159251800'
|
967
|
+
)
|
968
|
+
|
969
|
+
Pricing.perform(order, shipping)
|
970
|
+
|
971
|
+
assert_equal(2, order.items.first.price_adjustments.length)
|
972
|
+
assert_equal('item', order.items.first.price_adjustments.first.price)
|
973
|
+
assert_equal(10.to_m, order.items.first.price_adjustments.first.amount)
|
974
|
+
assert_equal('item', order.items.first.price_adjustments.second.price)
|
975
|
+
assert_equal(-1.to_m, order.items.first.price_adjustments.second.amount)
|
976
|
+
assert_equal(product_discount.id.to_s, order.items.first.price_adjustments.second.data['discount_id'])
|
977
|
+
|
978
|
+
assert_equal(2, shipping.price_adjustments.length)
|
979
|
+
assert_equal('shipping', shipping.price_adjustments.first.price)
|
980
|
+
assert_equal(3.to_m, shipping.price_adjustments.first.amount)
|
981
|
+
assert_equal('shipping', shipping.price_adjustments.second.price)
|
982
|
+
assert_equal(-3.to_m, shipping.price_adjustments.second.amount)
|
983
|
+
assert_equal(shipping_discount.id.to_s, shipping.price_adjustments.second.data['discount_id'])
|
984
|
+
end
|
985
|
+
|
986
|
+
def test_resolves_order_vs_shipping_discounts_by_value
|
987
|
+
create_pricing_sku(id: 'SKU', tax_code: '001', prices: [{ regular: 5.to_m }])
|
988
|
+
|
989
|
+
create_shipping_discount(
|
990
|
+
name: 'Second Discount',
|
991
|
+
amount: 1,
|
992
|
+
shipping_service: 'Ground'
|
993
|
+
)
|
994
|
+
|
995
|
+
order_discount = create_order_total_discount(
|
996
|
+
name: 'First Discount',
|
997
|
+
amount_type: 'flat',
|
998
|
+
amount: 3
|
999
|
+
)
|
1000
|
+
|
1001
|
+
order = Order.new
|
1002
|
+
order.add_item(product_id: 'PRODUCT', sku: 'SKU')
|
1003
|
+
|
1004
|
+
shipping = Shipping.new
|
1005
|
+
shipping.set_shipping_service(
|
1006
|
+
name: 'Ground',
|
1007
|
+
base_price: 3.to_m
|
1008
|
+
)
|
1009
|
+
shipping.set_address(
|
1010
|
+
first_name: 'Ben',
|
1011
|
+
last_name: 'Crouse',
|
1012
|
+
street: '22 S. 3rd St.',
|
1013
|
+
street_2: 'Second Floor',
|
1014
|
+
city: 'Philadelphia',
|
1015
|
+
region: 'PA',
|
1016
|
+
postal_code: '19106',
|
1017
|
+
country: 'US',
|
1018
|
+
phone_number: '2159251800'
|
1019
|
+
)
|
1020
|
+
|
1021
|
+
Pricing.perform(order, shipping)
|
1022
|
+
|
1023
|
+
assert_equal(2, order.items.first.price_adjustments.length)
|
1024
|
+
assert_equal('item', order.items.first.price_adjustments.first.price)
|
1025
|
+
assert_equal(5.to_m, order.items.first.price_adjustments.first.amount)
|
1026
|
+
assert_equal('order', order.items.first.price_adjustments.second.price)
|
1027
|
+
assert_equal(-3.to_m, order.items.first.price_adjustments.second.amount)
|
1028
|
+
assert_equal(order_discount.id.to_s, order.items.first.price_adjustments.second.data['discount_id'])
|
1029
|
+
|
1030
|
+
assert_equal(1, shipping.price_adjustments.length)
|
1031
|
+
assert_equal('shipping', shipping.price_adjustments.first.price)
|
1032
|
+
assert_equal(3.to_m, shipping.price_adjustments.first.amount)
|
1033
|
+
end
|
1034
|
+
|
1035
|
+
def test_allows_order_and_shipping_discounts_when_compatible
|
1036
|
+
create_pricing_sku(id: 'SKU', tax_code: '001', prices: [{ regular: 5.to_m }])
|
1037
|
+
|
1038
|
+
shipping_discount = create_shipping_discount(
|
1039
|
+
name: 'Second Discount',
|
1040
|
+
amount: 1,
|
1041
|
+
shipping_service: 'Ground'
|
1042
|
+
)
|
1043
|
+
|
1044
|
+
order_discount = create_order_total_discount(
|
1045
|
+
name: 'First Discount',
|
1046
|
+
amount_type: 'flat',
|
1047
|
+
amount: 3
|
1048
|
+
)
|
1049
|
+
|
1050
|
+
order = Order.new
|
1051
|
+
order.add_item(product_id: 'PRODUCT', sku: 'SKU')
|
1052
|
+
|
1053
|
+
shipping = Shipping.new
|
1054
|
+
shipping.set_shipping_service(
|
1055
|
+
name: 'Ground',
|
1056
|
+
base_price: 3.to_m
|
1057
|
+
)
|
1058
|
+
shipping.set_address(
|
1059
|
+
first_name: 'Ben',
|
1060
|
+
last_name: 'Crouse',
|
1061
|
+
street: '22 S. 3rd St.',
|
1062
|
+
street_2: 'Second Floor',
|
1063
|
+
city: 'Philadelphia',
|
1064
|
+
region: 'PA',
|
1065
|
+
postal_code: '19106',
|
1066
|
+
country: 'US',
|
1067
|
+
phone_number: '2159251800'
|
1068
|
+
)
|
1069
|
+
|
1070
|
+
order_discount.compatible_discount_ids = [shipping_discount.id.to_s]
|
1071
|
+
order_discount.save!
|
1072
|
+
|
1073
|
+
shipping_discount.compatible_discount_ids = [order_discount.id.to_s]
|
1074
|
+
shipping_discount.save!
|
1075
|
+
|
1076
|
+
Pricing.perform(order, shipping)
|
1077
|
+
|
1078
|
+
assert_equal(2, order.items.first.price_adjustments.length)
|
1079
|
+
assert_equal('item', order.items.first.price_adjustments.first.price)
|
1080
|
+
assert_equal(5.to_m, order.items.first.price_adjustments.first.amount)
|
1081
|
+
assert_equal('order', order.items.first.price_adjustments.second.price)
|
1082
|
+
assert_equal(-3.to_m, order.items.first.price_adjustments.second.amount)
|
1083
|
+
assert_equal(order_discount.id.to_s, order.items.first.price_adjustments.second.data['discount_id'])
|
1084
|
+
|
1085
|
+
assert_equal(2, shipping.price_adjustments.length)
|
1086
|
+
assert_equal('shipping', shipping.price_adjustments.first.price)
|
1087
|
+
assert_equal(3.to_m, shipping.price_adjustments.first.amount)
|
1088
|
+
assert_equal('Second Discount', shipping.price_adjustments.second.description)
|
1089
|
+
assert_equal(-2.to_m, shipping.price_adjustments.second.amount)
|
1090
|
+
end
|
1091
|
+
|
1092
|
+
def test_selects_the_higher_value_discount_when_one_is_a_free_item
|
1093
|
+
create_pricing_sku(id: 'SKU1', prices: [{ regular: 5.to_m }])
|
1094
|
+
create_pricing_sku(id: 'SKU2', prices: [{ regular: 3.to_m }])
|
1095
|
+
|
1096
|
+
order_discount = create_order_total_discount(
|
1097
|
+
name: 'First Discount',
|
1098
|
+
amount_type: 'flat',
|
1099
|
+
amount: 5
|
1100
|
+
)
|
1101
|
+
|
1102
|
+
create_free_gift_discount(
|
1103
|
+
name: 'Second Discount',
|
1104
|
+
sku: 'SKU2'
|
1105
|
+
)
|
1106
|
+
|
1107
|
+
order = Order.new
|
1108
|
+
order.add_item(product_id: 'PRODUCT', sku: 'SKU1')
|
1109
|
+
|
1110
|
+
Pricing.perform(order)
|
1111
|
+
|
1112
|
+
assert(order.items.select(&:free_gift?).empty?)
|
1113
|
+
|
1114
|
+
assert_equal(2, order.items.first.price_adjustments.length)
|
1115
|
+
assert_equal('order', order.items.first.price_adjustments.last.price)
|
1116
|
+
assert_equal(-5.to_m, order.items.first.price_adjustments.last.amount)
|
1117
|
+
assert_equal(order_discount.id.to_s, order.items.first.price_adjustments.last.data['discount_id'])
|
1118
|
+
end
|
1119
|
+
|
1120
|
+
def test_keeps_the_higher_value_item_when_both_are_free_items
|
1121
|
+
create_product(
|
1122
|
+
id: 'PRODUCT',
|
1123
|
+
variants: [
|
1124
|
+
{ sku: 'SKU2', regular: 20.to_m },
|
1125
|
+
{ sku: 'SKU3', regular: 30.to_m }
|
1126
|
+
]
|
1127
|
+
)
|
1128
|
+
create_pricing_sku(id: 'SKU1', prices: [{ regular: 180.to_m }])
|
1129
|
+
|
1130
|
+
create_free_gift_discount(
|
1131
|
+
name: 'First Discount',
|
1132
|
+
sku: 'SKU2',
|
1133
|
+
order_total_operator: 'greater_than',
|
1134
|
+
order_total: 150.to_m
|
1135
|
+
)
|
1136
|
+
|
1137
|
+
free_gift = create_free_gift_discount(
|
1138
|
+
name: 'Second Discount',
|
1139
|
+
sku: 'SKU3',
|
1140
|
+
order_total_operator: 'greater_than',
|
1141
|
+
order_total: 100.to_m
|
1142
|
+
)
|
1143
|
+
|
1144
|
+
order = Order.new
|
1145
|
+
order.add_item(product_id: 'PRODUCT', sku: 'SKU1')
|
1146
|
+
|
1147
|
+
Pricing.perform(order)
|
1148
|
+
order.reload
|
1149
|
+
|
1150
|
+
assert_equal(1, order.items.select(&:free_gift?).count)
|
1151
|
+
assert_equal(0.to_m, order.items.last.price_adjustments.last.amount)
|
1152
|
+
assert_equal(30, order.items.last.price_adjustments.last.data['discount_value'])
|
1153
|
+
assert_equal(free_gift.id.to_s, order.items.last.price_adjustments.last.data['discount_id'])
|
1154
|
+
end
|
1155
|
+
|
1156
|
+
def test_prevents_empty_orders_from_receiving_free_item_with_no_conditions
|
1157
|
+
create_free_gift_discount(sku: 'SKU2')
|
1158
|
+
|
1159
|
+
order = Order.new
|
1160
|
+
Pricing.perform(order)
|
1161
|
+
assert(order.no_items?)
|
1162
|
+
end
|
1163
|
+
|
1164
|
+
def test_prevents_non_discountable_items_form_contributing_to_free_item_subtotal_conditions
|
1165
|
+
create_pricing_sku(id: 'SKU1', discountable: false, prices: [{ regular: 5.to_m }])
|
1166
|
+
create_pricing_sku(id: 'SKU2', discountable: false, prices: [{ regular: 5.to_m }])
|
1167
|
+
create_pricing_sku(id: 'SKU3', discountable: false, prices: [{ regular: 5.to_m }])
|
1168
|
+
|
1169
|
+
create_free_gift_discount(
|
1170
|
+
sku: 'SKU3',
|
1171
|
+
order_total_operator: :greater_than,
|
1172
|
+
order_total: 5.to_m
|
1173
|
+
)
|
1174
|
+
|
1175
|
+
order = Order.new
|
1176
|
+
order.add_item(product_id: 'PRODUCT', sku: 'SKU1', discountable: false)
|
1177
|
+
order.add_item(product_id: 'PRODUCT', sku: 'SKU2', discountable: false)
|
1178
|
+
|
1179
|
+
Pricing.perform(order)
|
1180
|
+
|
1181
|
+
assert_equal(2, order.items.length)
|
1182
|
+
refute(order.items.first.free_gift)
|
1183
|
+
refute(order.items.second.free_gift)
|
1184
|
+
end
|
1185
|
+
|
1186
|
+
def test_prevents_non_discountable_items_from_contributing_to_buy_some_get_some_subtotal_conditions
|
1187
|
+
create_pricing_sku(id: 'SKU1', discountable: false, prices: [{ regular: 5.to_m }])
|
1188
|
+
create_pricing_sku(id: 'SKU2', prices: [{ regular: 4.to_m }])
|
1189
|
+
|
1190
|
+
create_buy_some_get_some_discount(
|
1191
|
+
purchase_quantity: 1,
|
1192
|
+
apply_quantity: 1,
|
1193
|
+
percent_off: 100,
|
1194
|
+
order_total_operator: :greater_than,
|
1195
|
+
order_total: 5.to_m
|
1196
|
+
)
|
1197
|
+
|
1198
|
+
order = Order.new
|
1199
|
+
order.add_item(product_id: 'PRODUCT', sku: 'SKU1')
|
1200
|
+
order.add_item(product_id: 'PRODUCT', sku: 'SKU2')
|
1201
|
+
|
1202
|
+
Pricing.perform(order)
|
1203
|
+
|
1204
|
+
assert_equal(2, order.items.length)
|
1205
|
+
assert_equal(1, order.items.first.price_adjustments.length)
|
1206
|
+
assert_equal(1, order.items.second.price_adjustments.length)
|
1207
|
+
end
|
1208
|
+
|
1209
|
+
def test_never_over_discounts_on_a_product_discount
|
1210
|
+
create_pricing_sku(id: 'SKU', prices: [{ regular: 5.to_m }])
|
1211
|
+
|
1212
|
+
discount = create_product_discount(
|
1213
|
+
amount_type: 'flat',
|
1214
|
+
amount: 10,
|
1215
|
+
product_ids: ['PRODUCT']
|
1216
|
+
)
|
1217
|
+
|
1218
|
+
order = Order.new
|
1219
|
+
order.items.build(product_id: 'PRODUCT', sku: 'SKU', quantity: 1)
|
1220
|
+
|
1221
|
+
Pricing.perform(order)
|
1222
|
+
|
1223
|
+
assert_equal(2, order.items.first.price_adjustments.length)
|
1224
|
+
assert_equal(-5.to_m, order.items.first.price_adjustments.last.amount)
|
1225
|
+
assert_equal(discount.id.to_s, order.items.first.price_adjustments.last.data['discount_id'])
|
1226
|
+
end
|
1227
|
+
|
1228
|
+
def test_prevents_non_discountable_items_from_contributing_to_product_subtotal_conditions
|
1229
|
+
create_pricing_sku(id: 'SKU1', prices: [{ regular: 5.to_m }])
|
1230
|
+
create_pricing_sku(id: 'SKU2', prices: [{ regular: 4.to_m }])
|
1231
|
+
|
1232
|
+
create_product_discount(
|
1233
|
+
amount_type: 'flat',
|
1234
|
+
amount: 2,
|
1235
|
+
product_ids: ['PRODUCT2'],
|
1236
|
+
order_total_operator: :greater_than,
|
1237
|
+
order_total: 5.to_m
|
1238
|
+
)
|
1239
|
+
|
1240
|
+
order = Order.new
|
1241
|
+
order.add_item(product_id: 'PRODUCT1', sku: 'SKU1', discountable: false)
|
1242
|
+
order.add_item(product_id: 'PRODUCT2', sku: 'SKU2')
|
1243
|
+
|
1244
|
+
Pricing.perform(order)
|
1245
|
+
|
1246
|
+
assert_equal(2, order.items.length)
|
1247
|
+
assert_equal(1, order.items.first.price_adjustments.length)
|
1248
|
+
assert_equal(1, order.items.second.price_adjustments.length)
|
1249
|
+
end
|
1250
|
+
|
1251
|
+
def test_prevents_a_negative_price_from_over_discounting_on_order_total_discount
|
1252
|
+
create_pricing_sku(id: 'SKU', prices: [{ regular: 5.to_m }])
|
1253
|
+
|
1254
|
+
order = Order.new
|
1255
|
+
order.add_item(product_id: 'PRODUCT', sku: 'SKU')
|
1256
|
+
|
1257
|
+
discount = create_order_total_discount(
|
1258
|
+
amount_type: 'flat',
|
1259
|
+
amount: 10
|
1260
|
+
)
|
1261
|
+
|
1262
|
+
Pricing.perform(order)
|
1263
|
+
|
1264
|
+
assert_equal(2, order.items.first.price_adjustments.length)
|
1265
|
+
assert_equal('order', order.items.first.price_adjustments.last.price)
|
1266
|
+
assert_equal(-5.to_m, order.items.first.price_adjustments.last.amount)
|
1267
|
+
assert_equal(discount.id.to_s, order.items.first.price_adjustments.last.data['discount_id'])
|
1268
|
+
end
|
1269
|
+
|
1270
|
+
def test_only_applies_discounts_with_matching_shipping_services
|
1271
|
+
create_shipping_discount(
|
1272
|
+
shipping_service: 'Next Day',
|
1273
|
+
amount: 10.to_m
|
1274
|
+
)
|
1275
|
+
|
1276
|
+
order = Order.new
|
1277
|
+
|
1278
|
+
shipping = Shipping.new
|
1279
|
+
shipping.set_shipping_service(
|
1280
|
+
name: 'Ground',
|
1281
|
+
tax_code: '001',
|
1282
|
+
base_price: 3.to_m
|
1283
|
+
)
|
1284
|
+
shipping.set_address(
|
1285
|
+
first_name: 'Ben',
|
1286
|
+
last_name: 'Crouse',
|
1287
|
+
street: '22 S. 3rd St.',
|
1288
|
+
street_2: 'Second Floor',
|
1289
|
+
city: 'Philadelphia',
|
1290
|
+
region: 'PA',
|
1291
|
+
postal_code: '19106',
|
1292
|
+
country: 'US',
|
1293
|
+
phone_number: '2159251800'
|
1294
|
+
)
|
1295
|
+
|
1296
|
+
Pricing.perform(order, shipping)
|
1297
|
+
|
1298
|
+
assert_equal(1, shipping.price_adjustments.length)
|
1299
|
+
assert_equal(3.to_m, shipping.price_adjustments.last.amount)
|
1300
|
+
end
|
1301
|
+
|
1302
|
+
def test_valid_promo_code_is_only_true_when_there_is_a_discount_with_this_promo_code
|
1303
|
+
refute(Pricing.valid_promo_code?('FOoBaR'))
|
1304
|
+
|
1305
|
+
create_product_discount(promo_codes: ['FOOBAR'])
|
1306
|
+
assert(Pricing.valid_promo_code?('FOoBaR'))
|
1307
|
+
end
|
1308
|
+
|
1309
|
+
def test_valid_promo_code_is_false_if_the_discount_is_not_active
|
1310
|
+
create_product_discount(active: false, promo_codes: ['FOOBAR'])
|
1311
|
+
refute(Pricing.valid_promo_code?('FOoBaR'))
|
1312
|
+
end
|
1313
|
+
|
1314
|
+
def test_valid_promo_code_is_false_if_the_user_already_used_the_single_use_promo_code
|
1315
|
+
discount = create_product_discount(
|
1316
|
+
single_use: true,
|
1317
|
+
promo_codes: ['FOOBAR']
|
1318
|
+
)
|
1319
|
+
|
1320
|
+
discount.redemptions.create!(email: 'bcrouse@workarea.com')
|
1321
|
+
|
1322
|
+
refute(Pricing.valid_promo_code?('FOOBAR', 'bcrouse@workarea.com'))
|
1323
|
+
end
|
1324
|
+
|
1325
|
+
def test_valid_promo_code_is_true_if_there_is_a_generated_promo_code_with_this_promo_code
|
1326
|
+
refute(Pricing.valid_promo_code?('FOoBaR'))
|
1327
|
+
|
1328
|
+
code_list = create_code_list(count: 5)
|
1329
|
+
code_list.promo_codes.create!(code: 'FOoBaR', expires_at: Time.current + 1.day)
|
1330
|
+
create_product_discount(generated_codes_id: code_list.id)
|
1331
|
+
|
1332
|
+
assert(Pricing.valid_promo_code?('FOoBaR'))
|
1333
|
+
end
|
1334
|
+
|
1335
|
+
def test_exluding_items_that_are_excluded_from_the_discount
|
1336
|
+
create_pricing_sku(id: 'SKU1', tax_code: '001', prices: [{ regular: 5.to_m }])
|
1337
|
+
create_pricing_sku(id: 'SKU2', tax_code: '001', prices: [{ regular: 7.to_m }])
|
1338
|
+
create_pricing_sku(id: 'SKU3', tax_code: '001', prices: [{ regular: 9.to_m }])
|
1339
|
+
|
1340
|
+
discount = create_order_total_discount(
|
1341
|
+
name: 'Test Discount',
|
1342
|
+
amount_type: 'percent',
|
1343
|
+
amount: 10,
|
1344
|
+
excluded_product_ids: %w(PRODUCT1),
|
1345
|
+
excluded_category_ids: %w(CATEGORY1)
|
1346
|
+
)
|
1347
|
+
|
1348
|
+
create_tax_category(
|
1349
|
+
code: '001',
|
1350
|
+
rates: [{ percentage: 0.06, region: 'PA', country: 'US' }]
|
1351
|
+
)
|
1352
|
+
|
1353
|
+
order = Order.new
|
1354
|
+
order.add_item(product_id: 'PRODUCT1', sku: 'SKU1')
|
1355
|
+
order.add_item(product_id: 'PRODUCT2', sku: 'SKU2')
|
1356
|
+
order.add_item(product_id: 'PRODUCT2', sku: 'SKU3', category_ids: %w(CATEGORY1))
|
1357
|
+
|
1358
|
+
shipping = Shipping.new
|
1359
|
+
|
1360
|
+
shipping.set_address(
|
1361
|
+
first_name: 'Ben',
|
1362
|
+
last_name: 'Crouse',
|
1363
|
+
street: '22 S. 3rd St.',
|
1364
|
+
street_2: 'Second Floor',
|
1365
|
+
city: 'Philadelphia',
|
1366
|
+
region: 'PA',
|
1367
|
+
postal_code: '19106',
|
1368
|
+
country: 'US',
|
1369
|
+
phone_number: '2159251800'
|
1370
|
+
)
|
1371
|
+
|
1372
|
+
shipping.set_shipping_service(
|
1373
|
+
id: 'GROUND',
|
1374
|
+
name: 'Ground',
|
1375
|
+
base_price: 3.to_m,
|
1376
|
+
tax_code: '001'
|
1377
|
+
)
|
1378
|
+
|
1379
|
+
Pricing.perform(order, shipping)
|
1380
|
+
|
1381
|
+
assert_equal(21.to_m, order.subtotal_price)
|
1382
|
+
assert_equal(3.to_m, order.shipping_total)
|
1383
|
+
assert_equal(1.40.to_m, order.tax_total)
|
1384
|
+
assert_equal(20.30.to_m, order.total_value)
|
1385
|
+
assert_equal(24.70.to_m, order.total_price)
|
1386
|
+
|
1387
|
+
discount.update(order_total: 10.to_m)
|
1388
|
+
|
1389
|
+
Pricing.perform(order, shipping)
|
1390
|
+
|
1391
|
+
assert_equal(21.to_m, order.subtotal_price)
|
1392
|
+
assert_equal(3.to_m, order.shipping_total)
|
1393
|
+
assert_equal(1.44.to_m, order.tax_total)
|
1394
|
+
assert_equal(21.to_m, order.total_value)
|
1395
|
+
assert_equal(25.44.to_m, order.total_price)
|
1396
|
+
end
|
1397
|
+
end
|
1398
|
+
end
|