workarea-core 3.4.45 → 3.5.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +52 -0
- data/app/assets/javascripts/workarea/core/modules/duplicate_id.js +1 -5
- data/app/assets/javascripts/workarea/core/modules/style_guide_autocomplete_fields.js +9 -42
- data/app/assets/javascripts/workarea/core/modules/url.js +14 -0
- data/app/controllers/workarea/application_controller.rb +5 -1
- data/app/controllers/workarea/authentication.rb +15 -26
- data/app/controllers/workarea/authorization.rb +3 -3
- data/app/controllers/workarea/current_referrer.rb +1 -2
- data/app/controllers/workarea/current_release.rb +1 -1
- data/app/controllers/workarea/current_segments.rb +52 -0
- data/app/controllers/workarea/current_tracking.rb +45 -0
- data/app/controllers/workarea/http_caching.rb +30 -0
- data/app/controllers/workarea/impersonation.rb +18 -44
- data/app/helpers/workarea/schema_org_helper.rb +21 -0
- data/app/mailers/workarea/application_mailer.rb +2 -4
- data/app/middleware/workarea/application_middleware.rb +44 -0
- data/app/middleware/workarea/query_cache_middleware.rb +55 -0
- data/app/middleware/workarea/release_server_middleware.rb +1 -1
- data/app/models/workarea/application_document.rb +1 -1
- data/app/models/workarea/bulk_action/product_edit.rb +6 -6
- data/app/models/workarea/calculate_percent_change.rb +1 -1
- data/app/models/workarea/catalog/category.rb +0 -2
- data/app/models/workarea/catalog/product.rb +19 -2
- data/app/models/workarea/checkout/collect_payment.rb +10 -1
- data/app/models/workarea/checkout/fraud/analyzer.rb +44 -0
- data/app/models/workarea/checkout/fraud/no_decision_analyzer.rb +14 -0
- data/app/models/workarea/checkout/fraud/test_analyzer.rb +26 -0
- data/app/models/workarea/checkout.rb +18 -6
- data/app/models/workarea/configuration/admin.rb +25 -0
- data/app/models/workarea/configuration/params.rb +45 -0
- data/app/models/workarea/content/asset.rb +5 -18
- data/app/models/workarea/content/block.rb +8 -2
- data/app/models/workarea/content/block_draft.rb +7 -2
- data/app/models/workarea/content/block_type.rb +2 -2
- data/app/models/workarea/content/block_type_definition.rb +4 -0
- data/app/models/workarea/content/preset.rb +1 -1
- data/app/models/workarea/content.rb +12 -82
- data/app/models/workarea/data_file/csv.rb +6 -8
- data/app/models/workarea/data_file/import.rb +9 -1
- data/app/models/workarea/data_file/json.rb +1 -20
- data/app/models/workarea/data_file/operation.rb +0 -4
- data/app/models/workarea/data_file/tax_rates.rb +3 -0
- data/app/models/workarea/featured_products.rb +8 -0
- data/app/models/workarea/fulfillment/policies/base.rb +21 -0
- data/app/models/workarea/fulfillment/policies/download.rb +21 -0
- data/app/models/workarea/fulfillment/policies/ignore.rb +11 -0
- data/app/models/workarea/fulfillment/policies/ship.rb +15 -0
- data/app/models/workarea/fulfillment/sku.rb +72 -0
- data/app/models/workarea/fulfillment/token.rb +36 -0
- data/app/models/workarea/inquiry.rb +1 -2
- data/app/models/workarea/insights/customer_acquisition.rb +5 -9
- data/app/models/workarea/insights/trending_products.rb +2 -2
- data/app/models/workarea/insights/trending_searches.rb +2 -2
- data/app/models/workarea/inventory/collection.rb +30 -0
- data/app/models/workarea/inventory/collection_status.rb +40 -0
- data/app/models/workarea/metrics/affinity.rb +33 -0
- data/app/models/workarea/metrics/country_by_day.rb +4 -0
- data/app/models/workarea/metrics/product_by_day.rb +3 -0
- data/app/models/workarea/metrics/product_by_week.rb +2 -0
- data/app/models/workarea/metrics/product_for_last_week.rb +8 -12
- data/app/models/workarea/metrics/sales_by_day.rb +5 -0
- data/app/models/workarea/metrics/search_by_day.rb +1 -3
- data/app/models/workarea/metrics/search_for_last_week.rb +5 -11
- data/app/models/workarea/metrics/segment_by_day.rb +31 -0
- data/app/models/workarea/metrics/sku_by_day.rb +3 -0
- data/app/models/workarea/metrics/tender_by_day.rb +11 -0
- data/app/models/workarea/metrics/update_user_aggregations.rb +77 -0
- data/app/models/workarea/metrics/user.rb +73 -87
- data/app/models/workarea/navigation/breadcrumbs.rb +10 -1
- data/app/models/workarea/order/fraud_decision.rb +18 -0
- data/app/models/workarea/order/item.rb +5 -0
- data/app/models/workarea/order/queries.rb +1 -0
- data/app/models/workarea/order/status.rb +10 -1
- data/app/models/workarea/order.rb +47 -4
- data/app/models/workarea/payment/credit_card.rb +12 -0
- data/app/models/workarea/payment.rb +7 -2
- data/app/models/workarea/pricing/cache_key.rb +9 -3
- data/app/models/workarea/pricing/calculator.rb +5 -1
- data/app/models/workarea/pricing/calculators/tax_calculator.rb +32 -5
- data/app/models/workarea/pricing/discount/application_group.rb +8 -3
- data/app/models/workarea/pricing/discount/free_gift.rb +2 -1
- data/app/models/workarea/pricing/discount/redemption.rb +1 -1
- data/app/models/workarea/pricing/discount.rb +2 -3
- data/app/models/workarea/pricing/item_tax_applier.rb +41 -0
- data/app/models/workarea/pricing/price.rb +1 -0
- data/app/models/workarea/pricing/request.rb +11 -0
- data/app/models/workarea/pricing/sku.rb +1 -0
- data/app/models/workarea/pricing/tax_application.rb +21 -0
- data/app/models/workarea/pricing/tax_applier.rb +12 -15
- data/app/models/workarea/pricing/unsupported_segmentation.rb +22 -0
- data/app/models/workarea/product_rule.rb +5 -0
- data/app/models/workarea/releasable.rb +83 -89
- data/app/models/workarea/release/activation.rb +45 -0
- data/app/models/workarea/release/changes.rb +45 -0
- data/app/models/workarea/release/changeset.rb +42 -52
- data/app/models/workarea/release/preview.rb +28 -0
- data/app/models/workarea/release/status.rb +2 -24
- data/app/models/workarea/release.rb +72 -99
- data/app/models/workarea/release_session.rb +11 -11
- data/app/models/workarea/search/admin/catalog_product.rb +1 -2
- data/app/models/workarea/search/admin/fulfillment_sku.rb +27 -0
- data/app/models/workarea/search/admin/order.rb +1 -1
- data/app/models/workarea/search/admin/pricing_discount.rb +1 -1
- data/app/models/workarea/search/admin/release.rb +1 -4
- data/app/models/workarea/search/admin/segment.rb +19 -0
- data/app/models/workarea/search/admin.rb +17 -39
- data/app/models/workarea/search/order_text.rb +23 -6
- data/app/models/workarea/search/storefront/category_query.rb +152 -0
- data/app/models/workarea/search/storefront/product/categories.rb +11 -45
- data/app/models/workarea/search/storefront.rb +33 -29
- data/app/models/workarea/segment/first_time_customer.rb +8 -0
- data/app/models/workarea/segment/first_time_visitor.rb +12 -0
- data/app/models/workarea/segment/life_cycle.rb +44 -0
- data/app/models/workarea/segment/loyal_customer.rb +12 -0
- data/app/models/workarea/segment/returning_customer.rb +14 -0
- data/app/models/workarea/segment/returning_visitor.rb +12 -0
- data/app/models/workarea/segment/rules/base.rb +16 -0
- data/app/models/workarea/segment/rules/browser_info.rb +29 -0
- data/app/models/workarea/segment/rules/geolocation.rb +29 -0
- data/app/models/workarea/segment/rules/geolocation_option.rb +53 -0
- data/app/models/workarea/segment/rules/last_order.rb +14 -0
- data/app/models/workarea/segment/rules/logged_in.rb +13 -0
- data/app/models/workarea/segment/rules/orders.rb +17 -0
- data/app/models/workarea/segment/rules/revenue.rb +17 -0
- data/app/models/workarea/segment/rules/sessions.rb +17 -0
- data/app/models/workarea/segment/rules/tags.rb +14 -0
- data/app/models/workarea/segment/rules/traffic_referrer.rb +18 -0
- data/app/models/workarea/segment.rb +54 -0
- data/app/models/workarea/segmentable.rb +66 -0
- data/app/models/workarea/sort.rb +14 -2
- data/app/models/workarea/tax/rate.rb +35 -1
- data/app/models/workarea/user/authorization.rb +19 -13
- data/app/models/workarea/user/login.rb +4 -0
- data/app/models/workarea/user/password_reset.rb +1 -3
- data/app/queries/workarea/categorization.rb +3 -3
- data/app/queries/workarea/featured_categorization.rb +53 -0
- data/app/queries/workarea/order_cancellation_metrics.rb +155 -0
- data/app/queries/workarea/order_item_details.rb +16 -3
- data/app/queries/workarea/order_metrics.rb +32 -3
- data/app/queries/workarea/product_primary_navigation.rb +13 -2
- data/app/queries/workarea/product_releases.rb +38 -0
- data/app/queries/workarea/recommendation/user_activity_based.rb +14 -6
- data/app/queries/workarea/reports/average_order_value.rb +1 -1
- data/app/queries/workarea/reports/customers.rb +14 -11
- data/app/queries/workarea/reports/first_time_vs_returning_sales.rb +1 -1
- data/app/queries/workarea/reports/group_by_time.rb +13 -17
- data/app/queries/workarea/reports/sales_by_category.rb +1 -1
- data/app/queries/workarea/reports/sales_by_country.rb +10 -3
- data/app/queries/workarea/reports/sales_by_discount.rb +1 -1
- data/app/queries/workarea/reports/sales_by_menu.rb +1 -1
- data/app/queries/workarea/reports/sales_by_product.rb +39 -4
- data/app/queries/workarea/reports/sales_by_sku.rb +39 -4
- data/app/queries/workarea/reports/sales_by_tender.rb +42 -0
- data/app/queries/workarea/reports/sales_by_traffic_referrer.rb +1 -1
- data/app/queries/workarea/reports/sales_over_time.rb +10 -3
- data/app/queries/workarea/reports/searches.rb +1 -1
- data/app/queries/workarea/reports/searches_over_time.rb +1 -1
- data/app/queries/workarea/reports/searches_without_results_over_time.rb +1 -1
- data/app/queries/workarea/search/admin_fulfillment_skus.rb +20 -0
- data/app/queries/workarea/search/admin_releases.rb +1 -4
- data/app/queries/workarea/search/admin_search.rb +0 -4
- data/app/queries/workarea/search/admin_segments.rb +16 -0
- data/app/queries/workarea/search/admin_sorting.rb +1 -1
- data/app/queries/workarea/search/pagination.rb +1 -4
- data/app/queries/workarea/search/product_display_rules.rb +40 -8
- data/app/queries/workarea/search/product_entries.rb +15 -1
- data/app/queries/workarea/search/product_search.rb +4 -1
- data/app/queries/workarea/search/storefront_search/exact_matches.rb +1 -1
- data/app/queries/workarea/search/storefront_search/response.rb +6 -4
- data/app/queries/workarea/search/storefront_search.rb +5 -4
- data/app/seeds/workarea/assets_seeds.rb +2 -1
- data/app/seeds/workarea/insights_seeds.rb +0 -23
- data/app/seeds/workarea/orders_seeds.rb +7 -6
- data/app/seeds/workarea/products_seeds.rb +2 -0
- data/app/seeds/workarea/segments_seeds.rb +8 -0
- data/app/seeds/workarea/tax_seeds.rb +3 -3
- data/app/services/workarea/cancel_order.rb +8 -3
- data/app/services/workarea/copy_order.rb +6 -0
- data/app/services/workarea/create_fulfillment.rb +5 -3
- data/app/services/workarea/direct_upload.rb +11 -19
- data/app/services/workarea/hash_update.rb +1 -18
- data/app/services/workarea/packaging.rb +1 -1
- data/app/services/workarea/save_publishing.rb +5 -1
- data/app/workers/sidekiq/callbacks.rb +4 -52
- data/app/workers/sidekiq/callbacks_worker.rb +4 -6
- data/app/workers/workarea/bulk_index_admin.rb +2 -2
- data/app/workers/workarea/bulk_index_products.rb +6 -5
- data/app/workers/workarea/bulk_index_searches.rb +5 -5
- data/app/workers/workarea/deactivate_stale_discounts.rb +3 -3
- data/app/workers/workarea/generate_insights.rb +1 -1
- data/app/workers/workarea/index_admin_search.rb +1 -0
- data/app/workers/workarea/index_categorization.rb +4 -7
- data/app/workers/workarea/index_category.rb +2 -1
- data/app/workers/workarea/index_category_changes.rb +11 -6
- data/app/workers/workarea/index_fulfillment_changes.rb +2 -1
- data/app/workers/workarea/index_help.rb +2 -1
- data/app/workers/workarea/index_page.rb +2 -1
- data/app/workers/workarea/index_payment_transactions.rb +2 -1
- data/app/workers/workarea/index_product.rb +4 -4
- data/app/workers/workarea/index_product_children.rb +4 -3
- data/app/workers/workarea/index_product_rule.rb +3 -2
- data/app/workers/workarea/index_search_customizations.rb +3 -2
- data/app/workers/workarea/index_skus.rb +5 -6
- data/app/workers/workarea/keep_product_index_fresh.rb +3 -5
- data/app/workers/workarea/process_import.rb +3 -3
- data/app/workers/workarea/process_search_recommendations.rb +5 -9
- data/app/workers/workarea/publish_release.rb +1 -0
- data/app/workers/workarea/save_metrics.rb +116 -0
- data/app/workers/workarea/save_order_cancellation_metrics.rb +35 -0
- data/app/workers/workarea/save_order_metrics.rb +10 -74
- data/app/workers/workarea/status_reporter.rb +2 -4
- data/app/workers/workarea/synchronize_user_metrics.rb +17 -0
- data/app/workers/workarea/update_payment_profile_email.rb +22 -0
- data/app/workers/workarea/verify_scheduled_releases.rb +4 -11
- data/config/initializers/00_configuration.rb +185 -0
- data/config/initializers/02_assets.rb +1 -0
- data/config/initializers/05_scheduled_jobs.rb +0 -7
- data/config/initializers/10_rack_middleware.rb +2 -5
- data/config/initializers/11_payment.rb +4 -0
- data/config/initializers/13_rack_attack.rb +2 -4
- data/config/initializers/14_content_block_types.rb +16 -16
- data/config/initializers/15_endpoint_monitoring.rb +3 -6
- data/config/initializers/{21_premailer.rb → 24_premailer.rb} +1 -0
- data/config/initializers/{20_i18n_js.rb → 25_i18n_js.rb} +0 -0
- data/config/locales/en.yml +13 -24
- data/lib/generators/workarea/content_block_type/templates/initializer.rb +1 -1
- data/lib/generators/workarea/install/USAGE +0 -1
- data/lib/generators/workarea/install/install_generator.rb +0 -21
- data/lib/generators/workarea/install/templates/initializer.rb.erb +1 -1
- data/lib/tasks/insights.rake +1 -0
- data/lib/tasks/migrate.rake +106 -0
- data/lib/tasks/search.rake +17 -19
- data/lib/tasks/tests.rake +1 -1
- data/lib/workarea/cache.rb +6 -35
- data/lib/workarea/changelog.rake +2 -2
- data/lib/workarea/configuration/administrable/definition.rb +42 -0
- data/lib/workarea/configuration/administrable/field.rb +79 -0
- data/lib/workarea/configuration/administrable/fieldset.rb +44 -0
- data/lib/workarea/configuration/administrable_options.rb +24 -0
- data/lib/workarea/configuration/cache_store.rb +3 -1
- data/lib/workarea/configuration/content_blocks.rb +17 -0
- data/lib/workarea/configuration/mongoid.rb +1 -4
- data/lib/workarea/configuration/session.rb +36 -0
- data/lib/workarea/configuration/sidekiq.rb +3 -1
- data/lib/workarea/configuration.rb +121 -148
- data/lib/workarea/core/engine.rb +3 -58
- data/lib/workarea/core.rb +15 -11
- data/lib/workarea/elasticsearch/document.rb +8 -15
- data/lib/workarea/ext/freedom_patches/action_view_cache_helper.rb +4 -6
- data/lib/workarea/ext/freedom_patches/active_support_duration.rb +14 -0
- data/lib/workarea/ext/freedom_patches/money.rb +11 -0
- data/lib/workarea/ext/freedom_patches/premailer.rb +6 -0
- data/lib/workarea/ext/freedom_patches/string.rb +19 -4
- data/lib/workarea/ext/mongoid/find_ordered.rb +2 -2
- data/lib/workarea/ext/mongoid/lookup_hash.rb +30 -0
- data/lib/workarea/geolocation.rb +24 -6
- data/lib/workarea/routes_constraints/super_admin.rb +1 -1
- data/lib/workarea/version.rb +3 -4
- data/lib/workarea/visit.rb +92 -0
- data/lib/workarea/warnings.rb +95 -0
- data/lib/workarea.rb +102 -3
- data/test/dummy/config/initializers/session_store.rb +1 -1
- data/test/fixtures/tax_rates.csv +3 -3
- data/test/generators/workarea/content_block_type_generator_test.rb +1 -1
- data/test/generators/workarea/install_generator_test.rb +0 -13
- data/test/integration/workarea/authentication_test.rb +27 -4
- data/test/integration/workarea/authorization_test.rb +5 -0
- data/test/integration/workarea/cache_varies_integration_test.rb +21 -23
- data/test/integration/workarea/monitoring_integration_test.rb +5 -10
- data/test/javascripts/duplicate_id_spec.js +1 -7
- data/test/javascripts/fixtures/{duplicate_id_fail.html.haml → duplicate_id.html.haml} +0 -1
- data/test/javascripts/form_submitting_controls_spec.js +0 -1
- data/test/lib/workarea/asset_endpoints/favicons_test.rb +11 -13
- data/test/lib/workarea/configuration/administrable/definition_test.rb +71 -0
- data/test/lib/workarea/configuration/administrable/field_test.rb +128 -0
- data/test/lib/workarea/configuration/administrable/fieldset_test.rb +78 -0
- data/test/lib/workarea/configuration/configuration_test.rb +20 -0
- data/test/lib/workarea/elasticsearch/document_test.rb +0 -20
- data/test/lib/workarea/elasticsearch/query_cache_test.rb +7 -7
- data/test/lib/workarea/ext/freedom_patches/money_test.rb +11 -0
- data/test/lib/workarea/ext/mongoid/lookup_hash_test.rb +86 -0
- data/test/lib/workarea/geolocation_test.rb +20 -0
- data/test/mailers/workarea/application_mailer_test.rb +1 -11
- data/test/middleware/workarea/query_cache_middleware_test.rb +55 -0
- data/test/models/workarea/checkout/collect_payment_test.rb +14 -6
- data/test/models/workarea/checkout_test.rb +31 -57
- data/test/models/workarea/configuration/params_test.rb +37 -0
- data/test/models/workarea/data_file/csv_test.rb +8 -73
- data/test/models/workarea/data_file/import_test.rb +31 -0
- data/test/models/workarea/data_file/json_test.rb +6 -48
- data/test/models/workarea/data_file/tax_test.rb +3 -0
- data/test/models/workarea/fulfillment/policies/download_test.rb +39 -0
- data/test/models/workarea/fulfillment/sku_test.rb +54 -0
- data/test/models/workarea/insights/best_customers_test.rb +5 -2
- data/test/models/workarea/insights/best_full_price_customers_test.rb +5 -2
- data/test/models/workarea/insights/customer_acquisition_test.rb +1 -1
- data/test/models/workarea/insights/customers_at_risk_test.rb +1 -1
- data/test/models/workarea/insights/low_aov_customers_test.rb +1 -1
- data/test/models/workarea/inventory/collection_test.rb +75 -0
- data/test/models/workarea/metrics/affinity_test.rb +85 -0
- data/test/models/workarea/metrics/product_by_week_test.rb +27 -31
- data/test/models/workarea/metrics/search_by_day_test.rb +3 -0
- data/test/models/workarea/metrics/search_by_week_test.rb +27 -31
- data/test/models/workarea/metrics/update_user_aggregations_test.rb +62 -0
- data/test/models/workarea/metrics/user_test.rb +146 -63
- data/test/models/workarea/navigation/breadcrumbs_test.rb +12 -2
- data/test/models/workarea/order/queries_test.rb +2 -0
- data/test/models/workarea/order_test.rb +44 -0
- data/test/models/workarea/payment/address_test.rb +109 -111
- data/test/models/workarea/payment/credit_card_integration_test.rb +0 -52
- data/test/models/workarea/payment/credit_card_test.rb +5 -0
- data/test/models/workarea/pricing/cache_key_test.rb +7 -1
- data/test/models/workarea/pricing/calculators/tax_calculator_test.rb +41 -1
- data/test/models/workarea/pricing/discount/collection_test.rb +27 -29
- data/test/models/workarea/pricing/discount_test.rb +22 -24
- data/test/models/workarea/pricing/item_tax_applier_test.rb +83 -0
- data/test/models/workarea/pricing/price_test.rb +9 -0
- data/test/models/workarea/pricing/request_test.rb +13 -0
- data/test/models/workarea/pricing/sku_test.rb +9 -0
- data/test/models/workarea/releasable_active_test.rb +113 -0
- data/test/models/workarea/releasable_test.rb +69 -120
- data/test/models/workarea/release/changeset_test.rb +41 -0
- data/test/models/workarea/release_jobs_test.rb +52 -0
- data/test/models/workarea/release_previewing_test.rb +43 -0
- data/test/models/workarea/release_test.rb +59 -153
- data/test/models/workarea/search/admin/content_asset_test.rb +26 -28
- data/test/models/workarea/search/order_text_test.rb +35 -0
- data/test/models/workarea/search/storefront/category_query_test.rb +81 -0
- data/test/models/workarea/search/storefront/product/categories_test.rb +10 -70
- data/test/models/workarea/search/storefront/product_test.rb +10 -11
- data/test/models/workarea/search/storefront_test.rb +1 -13
- data/test/models/workarea/segment/life_cycle_test.rb +24 -0
- data/test/models/workarea/segment/rules/browser_info_test.rb +33 -0
- data/test/models/workarea/segment/rules/geolocation_option_test.rb +16 -0
- data/test/models/workarea/segment/rules/geolocation_test.rb +49 -0
- data/test/models/workarea/segment/rules/last_order_test.rb +32 -0
- data/test/models/workarea/segment/rules/logged_in_test.rb +25 -0
- data/test/models/workarea/segment/rules/orders_test.rb +59 -0
- data/test/models/workarea/segment/rules/revenue_test.rb +59 -0
- data/test/models/workarea/segment/rules/sessions_test.rb +26 -0
- data/test/models/workarea/segment/rules/tags_test.rb +27 -0
- data/test/models/workarea/segment/rules/traffic_referrer_test.rb +31 -0
- data/test/models/workarea/segment_test.rb +80 -0
- data/test/models/workarea/segmentable_test.rb +74 -0
- data/test/models/workarea/shipping/address_test.rb +109 -111
- data/test/models/workarea/shipping/sku_test.rb +8 -12
- data/test/models/workarea/user/password_reset_test.rb +4 -12
- data/test/models/workarea/user_test.rb +13 -10
- data/test/queries/workarea/admin_search_query_wrapper_test.rb +21 -25
- data/test/queries/workarea/categorization_test.rb +49 -0
- data/test/queries/workarea/featured_categorization_test.rb +66 -0
- data/test/queries/workarea/order_cancellation_metrics_test.rb +203 -0
- data/test/queries/workarea/order_item_details_test.rb +17 -0
- data/test/queries/workarea/order_metrics_test.rb +12 -0
- data/test/queries/workarea/product_releases_test.rb +56 -0
- data/test/queries/workarea/recommendation/searches_test.rb +3 -3
- data/test/queries/workarea/recommendation/user_activity_based_test.rb +4 -4
- data/test/queries/workarea/reports/customers_test.rb +12 -8
- data/test/queries/workarea/reports/report_test.rb +4 -6
- data/test/queries/workarea/reports/sales_by_country_test.rb +18 -3
- data/test/queries/workarea/reports/sales_by_product_test.rb +28 -8
- data/test/queries/workarea/reports/sales_by_sku_test.rb +28 -8
- data/test/queries/workarea/reports/sales_by_tender_test.rb +100 -0
- data/test/queries/workarea/reports/sales_by_traffic_referrer_test.rb +6 -6
- data/test/queries/workarea/search/admin_releases_test.rb +1 -26
- data/test/queries/workarea/search/admin_search_test.rb +0 -10
- data/test/queries/workarea/search/admin_users_test.rb +2 -2
- data/test/queries/workarea/search/category_browse_test.rb +53 -0
- data/test/queries/workarea/search/facet_sorting/size_test.rb +11 -13
- data/test/queries/workarea/search/pagination_test.rb +9 -26
- data/test/queries/workarea/search/product_entries_test.rb +27 -0
- data/test/queries/workarea/search/product_search_test.rb +0 -16
- data/test/queries/workarea/search/storefront_search/response_test.rb +26 -0
- data/test/queries/workarea/search/storefront_search_test.rb +34 -36
- data/test/services/workarea/cancel_order_test.rb +27 -13
- data/test/services/workarea/copy_order_test.rb +17 -0
- data/test/services/workarea/direct_upload_test.rb +1 -46
- data/test/services/workarea/export_report_test.rb +41 -45
- data/test/services/workarea/hash_update_test.rb +12 -12
- data/test/services/workarea/packaging_test.rb +9 -11
- data/test/services/workarea/save_publishing_test.rb +23 -0
- data/test/workers/sidekiq/callbacks_test.rb +0 -22
- data/test/workers/workarea/deactivate_stale_discounts_test.rb +2 -2
- data/test/workers/workarea/index_category_changes_test.rb +5 -7
- data/test/workers/workarea/keep_product_index_fresh_test.rb +1 -1
- data/test/workers/workarea/process_import_test.rb +0 -6
- data/test/workers/workarea/process_search_recommendations_test.rb +4 -5
- data/test/workers/workarea/status_reporter_test.rb +2 -1
- data/test/workers/workarea/synchronize_user_metrics_test.rb +57 -0
- data/test/workers/workarea/update_payment_profile_email_test.rb +27 -0
- data/test/workers/workarea/verify_scheduled_releases_test.rb +0 -26
- data/workarea-core.gemspec +13 -11
- metadata +196 -92
- data/app/assets/javascripts/workarea/core/templates/ui_menu_item.jst.ejs +0 -10
- data/app/controllers/workarea/admin_guest_browsing.rb +0 -54
- data/app/middleware/workarea/rack_cache_config_middleware.rb +0 -19
- data/app/queries/workarea/search/search_suggestions.rb +0 -43
- data/app/workers/workarea/bust_discount_cache.rb +0 -16
- data/app/workers/workarea/clean_user_activity.rb +0 -11
- data/app/workers/workarea/undo_release.rb +0 -15
- data/app/workers/workarea/update_email.rb +0 -33
- data/lib/generators/workarea/docker/USAGE +0 -16
- data/lib/generators/workarea/docker/docker_generator.rb +0 -61
- data/lib/generators/workarea/docker/templates/.env.erb +0 -6
- data/lib/generators/workarea/docker/templates/Dockerfile.erb +0 -48
- data/lib/generators/workarea/docker/templates/docker-compose.yml.erb +0 -72
- data/lib/generators/workarea/docker/templates/docker-entrypoint.sh.erb +0 -6
- data/lib/generators/workarea/docker/templates/docker-sync.yml.erb +0 -8
- data/lib/generators/workarea/docker/templates/docker-wait.sh +0 -11
- data/lib/generators/workarea/docker/templates/docker.env +0 -16
- data/lib/generators/workarea/docker/templates/docker_init.rb.erb +0 -29
- data/lib/workarea/configuration/headless_chrome.rb +0 -42
- data/lib/workarea/configuration/puma.rb +0 -37
- data/lib/workarea/ext/freedom_patches/i18n_js.rb +0 -27
- data/lib/workarea/ext/freedom_patches/mongoid_localized_defaults.rb +0 -25
- data/lib/workarea/ext/jbuilder/jbuilder_cache.rb +0 -29
- data/lib/workarea/ext/referer_parser/parser.decorator +0 -43
- data/lib/workarea/queues_pauser.rb +0 -26
- data/lib/workarea/robots.rb +0 -9
- data/test/generators/workarea/docker_generator_test.rb +0 -156
- data/test/javascripts/fixtures/duplicate_id_pass.html.haml +0 -2
- data/test/lib/workarea/ext/freedom_patches/mongoid_localized_defaults_test.rb +0 -25
- data/test/lib/workarea/ext/referer_parser/parser_test.rb +0 -20
- data/test/queries/workarea/search/search_suggestions_test.rb +0 -29
- data/test/workers/workarea/undo_release_test.rb +0 -23
- data/test/workers/workarea/update_email_test.rb +0 -39
@@ -39,91 +39,174 @@ module Workarea
|
|
39
39
|
assert_equal(-2, user.discounts)
|
40
40
|
end
|
41
41
|
|
42
|
-
def
|
43
|
-
|
44
|
-
|
45
|
-
User.save_order(
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
42
|
+
def test_save_cancellation
|
43
|
+
first = Time.zone.local(2018, 11, 14)
|
44
|
+
|
45
|
+
User.save_order(
|
46
|
+
email: 'bcrouse@workarea.com',
|
47
|
+
revenue: 50.to_m,
|
48
|
+
at: first
|
49
|
+
)
|
50
|
+
|
51
|
+
User.save_cancellation(
|
52
|
+
email: 'bcrouse@workarea.com',
|
53
|
+
refund: -5.to_m,
|
54
|
+
at: first
|
55
|
+
)
|
56
|
+
|
57
|
+
assert_equal(1, User.count)
|
58
|
+
|
59
|
+
user = User.first
|
60
|
+
assert_equal(1, user.cancellations)
|
61
|
+
assert_equal(-5, user.refund)
|
62
|
+
assert_equal(45, user.revenue)
|
63
|
+
|
64
|
+
last = Time.zone.local(2018, 11, 15)
|
65
|
+
|
66
|
+
User.save_cancellation(
|
67
|
+
email: 'bcrouse@workarea.com',
|
68
|
+
refund: -3.to_m,
|
69
|
+
at: last
|
70
|
+
)
|
71
|
+
|
72
|
+
assert_equal(1, User.count)
|
73
|
+
|
74
|
+
user.reload
|
75
|
+
assert_equal(2, user.cancellations)
|
76
|
+
assert_equal(-8, user.refund)
|
77
|
+
assert_equal(42, user.revenue)
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_save_affinity
|
81
|
+
2.times do
|
82
|
+
User.save_affinity(
|
83
|
+
id: 'bcrouse@workarea.com',
|
84
|
+
action: 'viewed',
|
85
|
+
product_ids: %w(foo bar),
|
86
|
+
category_ids: 'baz',
|
87
|
+
search_ids: %(qoo)
|
88
|
+
)
|
89
|
+
end
|
90
|
+
|
91
|
+
assert_equal(1, User.count)
|
92
|
+
user = User.first
|
93
|
+
assert_equal('bcrouse@workarea.com', user.id)
|
94
|
+
assert_equal(%w(foo bar foo bar), user.viewed.product_ids)
|
95
|
+
assert_equal(%w(baz baz), user.viewed.category_ids)
|
96
|
+
assert_equal(%w(qoo qoo), user.viewed.search_ids)
|
97
|
+
|
98
|
+
assert_changes -> { user.reload.updated_at } do
|
99
|
+
User.save_affinity(
|
100
|
+
id: 'bcrouse@workarea.com',
|
101
|
+
action: 'purchased',
|
102
|
+
product_ids: %w(foo bar)
|
103
|
+
)
|
104
|
+
end
|
105
|
+
|
106
|
+
assert_equal(1, User.count)
|
107
|
+
user.reload
|
108
|
+
assert_equal('bcrouse@workarea.com', user.id)
|
109
|
+
assert_equal(%w(foo bar foo bar), user.viewed.product_ids)
|
110
|
+
assert_equal(%w(baz baz), user.viewed.category_ids)
|
111
|
+
assert_equal(%w(qoo qoo), user.viewed.search_ids)
|
112
|
+
assert_equal(%w(foo bar), user.purchased.product_ids)
|
56
113
|
end
|
57
114
|
|
58
|
-
def
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
assert_equal(
|
73
|
-
assert_equal(
|
74
|
-
assert_equal(
|
75
|
-
assert_equal(50, two.average_order_value_percentile)
|
115
|
+
def test_save_affinity_limits_storage
|
116
|
+
Workarea.config.max_affinity_items = 3
|
117
|
+
|
118
|
+
4.times do
|
119
|
+
User.save_affinity(
|
120
|
+
id: 'bcrouse@workarea.com',
|
121
|
+
action: 'viewed',
|
122
|
+
product_ids: %w(foo bar),
|
123
|
+
category_ids: 'baz',
|
124
|
+
search_ids: %(qoo)
|
125
|
+
)
|
126
|
+
end
|
127
|
+
|
128
|
+
user = User.first
|
129
|
+
assert_equal(%w(foo bar foo), user.viewed.product_ids)
|
130
|
+
assert_equal(%w(baz baz baz), user.viewed.category_ids)
|
131
|
+
assert_equal(%w(qoo qoo qoo), user.viewed.search_ids)
|
76
132
|
end
|
77
133
|
|
78
134
|
def test_merging_metrics
|
79
135
|
freeze_time
|
80
136
|
|
81
|
-
|
137
|
+
metrics = User.create!(
|
82
138
|
first_order_at: 2.weeks.ago,
|
83
139
|
last_order_at: 1.day.ago,
|
84
140
|
orders: 2,
|
85
141
|
revenue: 100,
|
86
142
|
discounts: -10,
|
87
143
|
average_order_value: 50,
|
144
|
+
cancellations: 1,
|
145
|
+
refund: -20,
|
146
|
+
viewed: { product_ids: ['foo'], category_ids: ['bar'], search_ids: ['baz'] },
|
147
|
+
purchased: { product_ids: ['qoo'], category_ids: ['quo'], search_ids: ['qux'] }
|
88
148
|
)
|
89
149
|
|
90
|
-
|
91
|
-
|
92
|
-
assert_equal(
|
93
|
-
assert_equal(
|
94
|
-
assert_equal(
|
95
|
-
assert_equal(
|
96
|
-
assert_equal(
|
97
|
-
assert_equal(
|
98
|
-
assert_equal(
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
assert_equal(
|
103
|
-
assert_equal(
|
104
|
-
assert_equal(
|
105
|
-
assert_equal(
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
150
|
+
metrics.merge!(User.new)
|
151
|
+
metrics.reload
|
152
|
+
assert_equal(2.weeks.ago, metrics.first_order_at)
|
153
|
+
assert_equal(1.day.ago, metrics.last_order_at)
|
154
|
+
assert_equal(2, metrics.orders)
|
155
|
+
assert_equal(100, metrics.revenue)
|
156
|
+
assert_equal(-10, metrics.discounts)
|
157
|
+
assert_equal(50, metrics.average_order_value)
|
158
|
+
assert_equal(1, metrics.cancellations)
|
159
|
+
assert_equal(-20, metrics.refund)
|
160
|
+
assert_equal(['foo'], metrics.viewed.product_ids)
|
161
|
+
assert_equal(['bar'], metrics.viewed.category_ids)
|
162
|
+
assert_equal(['baz'], metrics.viewed.search_ids)
|
163
|
+
assert_equal(['qoo'], metrics.purchased.product_ids)
|
164
|
+
assert_equal(['quo'], metrics.purchased.category_ids)
|
165
|
+
assert_equal(['qux'], metrics.purchased.search_ids)
|
166
|
+
|
167
|
+
blank = User.create!(id: 'foo').tap { |u| u.merge!(metrics) }
|
168
|
+
blank.reload
|
169
|
+
assert_equal(2.weeks.ago, blank.first_order_at)
|
170
|
+
assert_equal(1.day.ago, blank.last_order_at)
|
171
|
+
assert_equal(2, blank.orders)
|
172
|
+
assert_equal(100, blank.revenue)
|
173
|
+
assert_equal(-10, blank.discounts)
|
174
|
+
assert_equal(50, blank.average_order_value)
|
175
|
+
assert_equal(1, blank.cancellations)
|
176
|
+
assert_equal(-20, blank.refund)
|
177
|
+
assert_equal(['foo'], blank.viewed.product_ids)
|
178
|
+
assert_equal(['bar'], blank.viewed.category_ids)
|
179
|
+
assert_equal(['baz'], blank.viewed.search_ids)
|
180
|
+
assert_equal(['qoo'], blank.purchased.product_ids)
|
181
|
+
assert_equal(['quo'], blank.purchased.category_ids)
|
182
|
+
assert_equal(['qux'], blank.purchased.search_ids)
|
183
|
+
|
184
|
+
existing = User.create!(
|
111
185
|
first_order_at: 3.weeks.ago,
|
112
186
|
last_order_at: 3.weeks.ago,
|
113
187
|
orders: 2,
|
114
188
|
revenue: 120,
|
115
189
|
average_order_value: 60,
|
190
|
+
viewed: { product_ids: ['one'], category_ids: ['two'], search_ids: ['three'] },
|
191
|
+
purchased: { product_ids: ['four'], category_ids: ['five'], search_ids: ['six'] }
|
116
192
|
)
|
117
193
|
|
118
|
-
|
119
|
-
|
120
|
-
assert_equal(
|
121
|
-
assert_equal(
|
122
|
-
assert_equal(
|
123
|
-
assert_equal(
|
124
|
-
assert_equal(
|
125
|
-
assert_equal(
|
126
|
-
assert_equal(
|
194
|
+
existing.merge!(metrics)
|
195
|
+
existing.reload
|
196
|
+
assert_equal(3.weeks.ago, existing.first_order_at)
|
197
|
+
assert_equal(1.day.ago, existing.last_order_at)
|
198
|
+
assert_equal(4, existing.orders)
|
199
|
+
assert_equal(220, existing.revenue)
|
200
|
+
assert_equal(-10, existing.discounts)
|
201
|
+
assert_equal(55, existing.average_order_value)
|
202
|
+
assert_equal(1, existing.cancellations)
|
203
|
+
assert_equal(-20, existing.refund)
|
204
|
+
assert_equal(%w(one foo), existing.viewed.product_ids)
|
205
|
+
assert_equal(%w(two bar), existing.viewed.category_ids)
|
206
|
+
assert_equal(%w(three baz), existing.viewed.search_ids)
|
207
|
+
assert_equal(%w(four qoo), existing.purchased.product_ids)
|
208
|
+
assert_equal(%w(five quo), existing.purchased.category_ids)
|
209
|
+
assert_equal(%w(six qux), existing.purchased.search_ids)
|
127
210
|
end
|
128
211
|
end
|
129
212
|
end
|
@@ -23,10 +23,20 @@ module Workarea
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_last
|
26
|
-
|
26
|
+
model = create_product
|
27
|
+
breadcrumbs = Breadcrumbs.new(@navigable, last: model)
|
28
|
+
|
29
|
+
assert(breadcrumbs.last.is_a?(Navigation::Taxon))
|
30
|
+
assert_equal(4, breadcrumbs.length) # including home
|
31
|
+
assert_equal(model, breadcrumbs.last.navigable)
|
32
|
+
assert_equal(model.name, breadcrumbs.last.name)
|
33
|
+
|
34
|
+
model = create_inventory
|
35
|
+
breadcrumbs = Breadcrumbs.new(@navigable, last: model.id)
|
36
|
+
|
27
37
|
assert(breadcrumbs.last.is_a?(Navigation::Taxon))
|
28
38
|
assert_equal(4, breadcrumbs.length) # including home
|
29
|
-
assert_equal(
|
39
|
+
assert_equal(model.id, breadcrumbs.last.name)
|
30
40
|
end
|
31
41
|
|
32
42
|
def test_selected
|
@@ -118,6 +118,7 @@ module Workarea
|
|
118
118
|
def test_need_reminding
|
119
119
|
placed = Order.create!(placed_at: 1.hour.ago)
|
120
120
|
reminded = Order.create!(reminded_at: 1.hour.ago)
|
121
|
+
fraud = Order.create!(fraud_suspected_at: 1.hour.ago)
|
121
122
|
not_abandoned = Order.create!(email: email)
|
122
123
|
abandoned = Order.create!(email: email, checkout_started_at: 2.hours.ago, items: [{ product_id: '1', sku: 2 }])
|
123
124
|
empty = Order.create!(email: email, checkout_started_at: 2.hours.ago, items: [])
|
@@ -126,6 +127,7 @@ module Workarea
|
|
126
127
|
|
127
128
|
refute_includes(results, placed)
|
128
129
|
refute_includes(results, reminded)
|
130
|
+
refute_includes(results, fraud)
|
129
131
|
refute_includes(results, no_info)
|
130
132
|
refute_includes(results, not_abandoned)
|
131
133
|
refute_includes(results, empty)
|
@@ -56,6 +56,9 @@ module Workarea
|
|
56
56
|
order.checkout_started_at = Time.current
|
57
57
|
assert_equal(:checkout, order.status)
|
58
58
|
|
59
|
+
order.fraud_suspected_at = Time.current
|
60
|
+
assert_equal(:suspected_fraud, order.status)
|
61
|
+
|
59
62
|
order.place
|
60
63
|
assert_equal(:placed, order.status)
|
61
64
|
|
@@ -150,5 +153,46 @@ module Workarea
|
|
150
153
|
order = Order.new
|
151
154
|
assert_equal("Order #{order.id}", order.name)
|
152
155
|
end
|
156
|
+
|
157
|
+
def test_fraud_suspected?
|
158
|
+
order = Order.new
|
159
|
+
order.fraud_decision = create_fraud_decision
|
160
|
+
|
161
|
+
refute(order.fraud_suspected?)
|
162
|
+
|
163
|
+
order.fraud_decision = create_fraud_decision(decision: :declined)
|
164
|
+
order.fraud_suspected_at = Time.current
|
165
|
+
assert(order.fraud_suspected?)
|
166
|
+
end
|
167
|
+
|
168
|
+
def test_set_fraud_decision
|
169
|
+
order = Order.new
|
170
|
+
order.set_fraud_decision!(create_fraud_decision)
|
171
|
+
|
172
|
+
refute(order.fraud_suspected_at.present?)
|
173
|
+
assert(order.fraud_decided_at.present?)
|
174
|
+
|
175
|
+
order.set_fraud_decision!(create_fraud_decision(decision: :declined))
|
176
|
+
assert(order.fraud_suspected_at.present?)
|
177
|
+
end
|
178
|
+
|
179
|
+
def test_item_count_limit
|
180
|
+
Workarea.config.item_count_limit = 2
|
181
|
+
|
182
|
+
order = Order.new(email: 'test@workarea.com')
|
183
|
+
|
184
|
+
order.items.build(sku: 'SKU1', product_id: 'PROD')
|
185
|
+
assert(order.valid?)
|
186
|
+
|
187
|
+
order.items.build(sku: 'SKU2', product_id: 'PROD', quantity: 2)
|
188
|
+
assert(order.valid?)
|
189
|
+
|
190
|
+
order.items.build(sku: 'SKU3', product_id: 'PROD')
|
191
|
+
refute(order.valid?)
|
192
|
+
assert_equal(
|
193
|
+
t('workarea.order.errors.count_limit', size: 2),
|
194
|
+
order.errors.full_messages.first
|
195
|
+
)
|
196
|
+
end
|
153
197
|
end
|
154
198
|
end
|
@@ -4,117 +4,115 @@ module Workarea
|
|
4
4
|
class Payment
|
5
5
|
class AddressTest < TestCase
|
6
6
|
def test_po_box_addresses
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
refute(address.errors[:street_2].present?)
|
117
|
-
end
|
7
|
+
address = Payment::Address.new(
|
8
|
+
first_name: 'Ben',
|
9
|
+
last_name: 'Crouse',
|
10
|
+
street: '22 S. 3rd St.',
|
11
|
+
street_2: 'Second Floor',
|
12
|
+
city: 'Philadelphia',
|
13
|
+
region: 'PA',
|
14
|
+
postal_code: '19106',
|
15
|
+
country: 'US'
|
16
|
+
)
|
17
|
+
|
18
|
+
Workarea.config.allow_payment_address_po_box = false
|
19
|
+
|
20
|
+
po_boxes = [
|
21
|
+
'PO Box 123',
|
22
|
+
'P O box 123',
|
23
|
+
'P. O. Box 123',
|
24
|
+
'P.O.Box 123',
|
25
|
+
'post box 123',
|
26
|
+
'post office box 123',
|
27
|
+
'post office 123',
|
28
|
+
'P.O.B 123',
|
29
|
+
'P.O.B. 123',
|
30
|
+
'Post Office Bin 123',
|
31
|
+
'Postal Code 123',
|
32
|
+
'Post Box #123',
|
33
|
+
'Postal Box 123',
|
34
|
+
'P.O. Box 123',
|
35
|
+
'PO. Box 123',
|
36
|
+
'P.o box 123',
|
37
|
+
'Pobox 123',
|
38
|
+
'pob 123',
|
39
|
+
'pob123',
|
40
|
+
'pobox123',
|
41
|
+
'p.o. Box123',
|
42
|
+
'po-box123',
|
43
|
+
'p.o.-box 123',
|
44
|
+
'PO-Box 123',
|
45
|
+
'p-o-box 123',
|
46
|
+
'p-o box 123',
|
47
|
+
'box 123',
|
48
|
+
'Box123',
|
49
|
+
'Box-123'
|
50
|
+
]
|
51
|
+
|
52
|
+
non_po_boxes = [
|
53
|
+
'123 Box Turtle Circle',
|
54
|
+
'123 Boxing Pass',
|
55
|
+
'123 Poblano Lane',
|
56
|
+
'123 P O Davis Drive',
|
57
|
+
'123 Postal Circle'
|
58
|
+
]
|
59
|
+
|
60
|
+
po_boxes.each do |po_box|
|
61
|
+
address.street = po_box
|
62
|
+
refute(address.valid?)
|
63
|
+
refute(address.errors[:street].empty?)
|
64
|
+
end
|
65
|
+
|
66
|
+
address.street = '22 S. 3rd St'
|
67
|
+
po_boxes.each do |po_box|
|
68
|
+
address.street_2 = po_box
|
69
|
+
refute(address.valid?)
|
70
|
+
refute(address.errors[:street_2].empty?)
|
71
|
+
end
|
72
|
+
|
73
|
+
Workarea.config.allow_payment_address_po_box = true
|
74
|
+
address.street_2 = 'Second Floor'
|
75
|
+
|
76
|
+
po_boxes.each do |po_box|
|
77
|
+
address.street = po_box
|
78
|
+
assert(address.valid?)
|
79
|
+
refute(address.errors[:street].present?)
|
80
|
+
end
|
81
|
+
|
82
|
+
address.street = '22 S. 3rd St'
|
83
|
+
po_boxes.each do |po_box|
|
84
|
+
address.street_2 = po_box
|
85
|
+
assert(address.valid?)
|
86
|
+
refute(address.errors[:street_2].present?)
|
87
|
+
end
|
88
|
+
|
89
|
+
non_po_boxes.each do |non_po_box|
|
90
|
+
address.street = non_po_box
|
91
|
+
assert(address.valid?)
|
92
|
+
assert(address.errors[:street].empty?)
|
93
|
+
end
|
94
|
+
|
95
|
+
address.street = '22 S. 3rd St'
|
96
|
+
non_po_boxes.each do |non_po_box|
|
97
|
+
address.street_2 = non_po_box
|
98
|
+
assert(address.valid?)
|
99
|
+
assert(address.errors[:street_2].empty?)
|
100
|
+
end
|
101
|
+
|
102
|
+
Workarea.config.allow_payment_address_po_box = true
|
103
|
+
address.street_2 = 'Second Floor'
|
104
|
+
|
105
|
+
non_po_boxes.each do |non_po_box|
|
106
|
+
address.street = non_po_box
|
107
|
+
assert(address.valid?)
|
108
|
+
refute(address.errors[:street].present?)
|
109
|
+
end
|
110
|
+
|
111
|
+
address.street = '22 S. 3rd St'
|
112
|
+
non_po_boxes.each do |non_po_box|
|
113
|
+
address.street_2 = non_po_box
|
114
|
+
assert(address.valid?)
|
115
|
+
refute(address.errors[:street_2].present?)
|
118
116
|
end
|
119
117
|
end
|
120
118
|
|
@@ -76,58 +76,6 @@ module Workarea
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
-
def test_auth_capture_refund
|
80
|
-
pass && return unless Workarea.config.run_credit_card_refund_tests
|
81
|
-
|
82
|
-
VCR.use_cassette 'credit_card/auth_capture_refund' do
|
83
|
-
transaction = tender.build_transaction(action: 'authorize')
|
84
|
-
Payment::Authorize::CreditCard.new(tender, transaction).complete!
|
85
|
-
assert(transaction.success?, 'expected transaction to be successful')
|
86
|
-
transaction.save!
|
87
|
-
|
88
|
-
assert(tender.token.present?)
|
89
|
-
|
90
|
-
capture = Payment::Capture.new(payment: payment)
|
91
|
-
capture.allocate_amounts!(total: 5.to_m)
|
92
|
-
assert(capture.valid?)
|
93
|
-
capture.complete!
|
94
|
-
|
95
|
-
capture_transaction = payment.transactions.detect(&:captures)
|
96
|
-
assert(capture_transaction.valid?)
|
97
|
-
|
98
|
-
refund = Payment::Refund.new(payment: payment)
|
99
|
-
refund.allocate_amounts!(total: 5.to_m)
|
100
|
-
|
101
|
-
assert(refund.valid?)
|
102
|
-
refund.complete!
|
103
|
-
|
104
|
-
refund_transaction = payment.credit_card.transactions.refunds.first
|
105
|
-
assert(refund_transaction.valid?)
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
def test_purchase_refund
|
110
|
-
pass && return unless Workarea.config.run_credit_card_refund_tests
|
111
|
-
|
112
|
-
VCR.use_cassette 'credit_card/purchase_refund' do
|
113
|
-
transaction = tender.build_transaction(action: 'purchase')
|
114
|
-
Payment::Purchase::CreditCard.new(tender, transaction).complete!
|
115
|
-
assert(transaction.success?)
|
116
|
-
transaction.save!
|
117
|
-
|
118
|
-
assert(tender.token.present?)
|
119
|
-
|
120
|
-
refund = Payment::Refund.new(payment: payment)
|
121
|
-
refund.allocate_amounts!(total: 5.to_m)
|
122
|
-
|
123
|
-
assert(refund.valid?)
|
124
|
-
refund.complete!
|
125
|
-
|
126
|
-
refund_transaction = payment.credit_card.transactions.refunds.first
|
127
|
-
assert(refund_transaction.valid?)
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
79
|
private
|
132
80
|
|
133
81
|
def gateway
|
@@ -52,6 +52,11 @@ module Workarea
|
|
52
52
|
credit_card.valid?
|
53
53
|
assert(credit_card.display_number.present?)
|
54
54
|
assert(credit_card.issuer.present?)
|
55
|
+
|
56
|
+
Workarea.config.credit_card_issuers.delete('american_express')
|
57
|
+
credit_card.number = 378282246310005 # amex test number
|
58
|
+
refute(credit_card.valid?, 'valid')
|
59
|
+
assert(credit_card.errors[:base].present?, 'no errors')
|
55
60
|
end
|
56
61
|
|
57
62
|
def test_number=
|
@@ -10,12 +10,14 @@ module Workarea
|
|
10
10
|
:setup_order_item,
|
11
11
|
:setup_shipping,
|
12
12
|
:setup_pricing,
|
13
|
+
:setup_payment,
|
13
14
|
:setup_cache_key
|
14
15
|
|
15
16
|
def test_parts
|
16
17
|
parts = @cache_key.parts.flatten
|
17
18
|
|
18
19
|
assert_includes(parts, @pricing.cache_key)
|
20
|
+
assert_includes(parts, @payment.cache_key)
|
19
21
|
assert_includes(parts, @discount.reload.cache_key)
|
20
22
|
assert_includes(parts, @order.cache_key)
|
21
23
|
assert_includes(parts, @shipping.cache_key)
|
@@ -59,8 +61,12 @@ module Workarea
|
|
59
61
|
@request = Request.new(@order, @shipping)
|
60
62
|
end
|
61
63
|
|
64
|
+
def setup_payment
|
65
|
+
@payment = create_payment(id: @order.id)
|
66
|
+
end
|
67
|
+
|
62
68
|
def setup_cache_key
|
63
|
-
@cache_key = CacheKey.new(@order, [@shipping], @request)
|
69
|
+
@cache_key = CacheKey.new(@order, [@shipping], @payment, @request)
|
64
70
|
end
|
65
71
|
end
|
66
72
|
end
|