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
@@ -1,10 +0,0 @@
|
|
1
|
-
<%
|
2
|
-
throw new Error(
|
3
|
-
'workarea/core/templates/ui_menu_item.jst.ejs: this template has ' +
|
4
|
-
'moved from core into both the admin and storefront, respectively. ' +
|
5
|
-
'Please adjust your overridden admin and/or storefront manifests to \n\n' +
|
6
|
-
'Find: "workarea/core/templates/ui_menu_item"\n' +
|
7
|
-
'Replace with either: "workarea/admin/templates/ui_menu_item" or\n' +
|
8
|
-
' "workarea/storefront/templates/ui_menu_item"'
|
9
|
-
);
|
10
|
-
%>
|
@@ -1,54 +0,0 @@
|
|
1
|
-
module Workarea
|
2
|
-
module AdminGuestBrowsing
|
3
|
-
extend ActiveSupport::Concern
|
4
|
-
include Authentication
|
5
|
-
|
6
|
-
included do
|
7
|
-
helper_method :admin_browsing_as_guest?
|
8
|
-
end
|
9
|
-
|
10
|
-
def admin_browse_as_guest
|
11
|
-
session[:admin_id] = current_user.id
|
12
|
-
touch_admin_guest_browsing
|
13
|
-
logout
|
14
|
-
end
|
15
|
-
|
16
|
-
def admin_browsing_as_guest?
|
17
|
-
session[:admin_id].present? && cookies.signed[:guest_browsing]
|
18
|
-
end
|
19
|
-
|
20
|
-
def stop_admin_guest_browsing
|
21
|
-
cookies.signed[:user_id] = {
|
22
|
-
value: current_admin.id,
|
23
|
-
expires: Workarea.config.admin_session_timeout.from_now
|
24
|
-
}
|
25
|
-
|
26
|
-
session.delete(:admin_id)
|
27
|
-
cookies.delete(:guest_browsing)
|
28
|
-
end
|
29
|
-
|
30
|
-
def touch_admin_guest_browsing
|
31
|
-
cookies.signed[:guest_browsing] = {
|
32
|
-
value: true,
|
33
|
-
expires: Workarea.config.admin_session_timeout.from_now
|
34
|
-
}
|
35
|
-
end
|
36
|
-
|
37
|
-
def current_admin
|
38
|
-
@current_admin ||=
|
39
|
-
if admin_browsing_as_guest?
|
40
|
-
User.find(session[:admin_id])
|
41
|
-
elsif current_user.try(:admin?)
|
42
|
-
current_user
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def keep_auth_alive
|
47
|
-
if admin_browsing_as_guest?
|
48
|
-
touch_admin_guest_browsing
|
49
|
-
else
|
50
|
-
super
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module Workarea
|
2
|
-
class RackCacheConfigMiddleware
|
3
|
-
def initialize(app)
|
4
|
-
@app = app
|
5
|
-
end
|
6
|
-
|
7
|
-
def call(env)
|
8
|
-
request = Rack::Request.new(env)
|
9
|
-
env['rack-cache.cache_key'] = Cache::RackCacheKey
|
10
|
-
|
11
|
-
if request.path !~ /(jpe?g|png|ico|gif|css|js)$/
|
12
|
-
env['rack-cache.force-pass'] = request.cookies['cache'] == 'false'
|
13
|
-
env['workarea.cache_varies'] = Cache::Varies.new(env).to_s
|
14
|
-
end
|
15
|
-
|
16
|
-
@app.call(env)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
module Workarea
|
2
|
-
module Search
|
3
|
-
class SearchSuggestions
|
4
|
-
include Query
|
5
|
-
|
6
|
-
document Search::Storefront
|
7
|
-
|
8
|
-
def results
|
9
|
-
response['hits']['hits']
|
10
|
-
end
|
11
|
-
|
12
|
-
def sanitized_string
|
13
|
-
@sanitized_query ||= QueryString.new(params[:q]).sanitized
|
14
|
-
end
|
15
|
-
|
16
|
-
def query
|
17
|
-
{
|
18
|
-
bool: {
|
19
|
-
must: [
|
20
|
-
{
|
21
|
-
match_phrase_prefix: {
|
22
|
-
'content.name': {
|
23
|
-
query: sanitized_string,
|
24
|
-
max_expansions: 10
|
25
|
-
}
|
26
|
-
}
|
27
|
-
},
|
28
|
-
{ term: { 'active.now' => true } }
|
29
|
-
]
|
30
|
-
}
|
31
|
-
}
|
32
|
-
end
|
33
|
-
|
34
|
-
def sort
|
35
|
-
{ type: :desc }
|
36
|
-
end
|
37
|
-
|
38
|
-
def size
|
39
|
-
Workarea.config.search_suggestions
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module Workarea
|
2
|
-
class BustDiscountCache
|
3
|
-
include Sidekiq::Worker
|
4
|
-
include Sidekiq::CallbacksWorker
|
5
|
-
|
6
|
-
sidekiq_options(
|
7
|
-
enqueue_on: { Pricing::Discount => [:save, :destroy] },
|
8
|
-
queue: 'low',
|
9
|
-
retry: false
|
10
|
-
)
|
11
|
-
|
12
|
-
def perform(*)
|
13
|
-
Pricing::Discount::ApplicationGroup.expire_cache
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module Workarea
|
2
|
-
class UndoRelease
|
3
|
-
include Sidekiq::Worker
|
4
|
-
|
5
|
-
def perform(release_id)
|
6
|
-
release = Release.find(release_id)
|
7
|
-
system_user = User.find_system_user!(release.name, 'Release')
|
8
|
-
|
9
|
-
Mongoid::AuditLog.record(system_user) { release.undo! }
|
10
|
-
|
11
|
-
rescue Mongoid::Errors::DocumentNotFound
|
12
|
-
# Doesn't matter, release has been removed
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
module Workarea
|
2
|
-
class UpdateEmail
|
3
|
-
include Sidekiq::Worker
|
4
|
-
include Sidekiq::CallbacksWorker
|
5
|
-
|
6
|
-
sidekiq_options(
|
7
|
-
enqueue_on: { User => :update, with: -> { [id, changes] } }
|
8
|
-
)
|
9
|
-
|
10
|
-
def perform(id, changes)
|
11
|
-
return unless changes['email'].present? && changes['email'].first.present?
|
12
|
-
|
13
|
-
old_email, new_email = changes['email']
|
14
|
-
update_payment_profile(id, old_email, new_email)
|
15
|
-
update_metrics(old_email, new_email)
|
16
|
-
end
|
17
|
-
|
18
|
-
def update_payment_profile(id, old_email, new_email)
|
19
|
-
user = User.find(id)
|
20
|
-
user.email = old_email # set old email so we lookup by old email value
|
21
|
-
|
22
|
-
Payment::Profile.update_email(PaymentReference.new(user), new_email)
|
23
|
-
end
|
24
|
-
|
25
|
-
def update_metrics(old_email, new_email)
|
26
|
-
old_metrics = Metrics::User.find(old_email) rescue nil
|
27
|
-
return if old_metrics.blank?
|
28
|
-
|
29
|
-
new_metrics = Metrics::User.find_or_initialize_by(id: new_email)
|
30
|
-
new_metrics.merge!(old_metrics)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
Description:
|
2
|
-
Creates files necessary to run your application in a docker environment.
|
3
|
-
|
4
|
-
Example:
|
5
|
-
rails generate workarea:docker --webpack --sync
|
6
|
-
|
7
|
-
creates:
|
8
|
-
config/initializers/z_docker.rb
|
9
|
-
.env
|
10
|
-
Dockerfile
|
11
|
-
docker-entrypoint.sh
|
12
|
-
docker-compose.yml
|
13
|
-
docker-sync.yml
|
14
|
-
docker.env
|
15
|
-
modifies:
|
16
|
-
.gitignore
|
@@ -1,61 +0,0 @@
|
|
1
|
-
module Workarea
|
2
|
-
class DockerGenerator < Rails::Generators::Base
|
3
|
-
source_root File.expand_path('../templates', __FILE__)
|
4
|
-
desc File.read(File.expand_path('../USAGE', __FILE__))
|
5
|
-
|
6
|
-
class_option 'webpack',
|
7
|
-
type: :boolean,
|
8
|
-
aliases: '-W',
|
9
|
-
desc: 'include configuration for webpack/yarn'
|
10
|
-
class_option 'sync',
|
11
|
-
type: :boolean,
|
12
|
-
aliases: '-S',
|
13
|
-
desc: 'include configuration for docker-sync'
|
14
|
-
|
15
|
-
def create_dockerfile
|
16
|
-
template('Dockerfile.erb', 'Dockerfile')
|
17
|
-
template('docker-entrypoint.sh.erb', 'docker-entrypoint.sh')
|
18
|
-
template('docker-wait.sh', 'docker-wait.sh')
|
19
|
-
end
|
20
|
-
|
21
|
-
def create_docker_compose
|
22
|
-
template('docker-compose.yml.erb', 'docker-compose.yml')
|
23
|
-
end
|
24
|
-
|
25
|
-
def create_docker_environment_files
|
26
|
-
template('docker.env', 'docker.env')
|
27
|
-
template('.env.erb', '.env')
|
28
|
-
end
|
29
|
-
|
30
|
-
def create_docker_initializer
|
31
|
-
template('docker_init.rb.erb', 'config/initializers/z_docker.rb')
|
32
|
-
end
|
33
|
-
|
34
|
-
def create_docker_sync
|
35
|
-
return unless include_docker_sync?
|
36
|
-
template('docker-sync.yml.erb', 'docker-sync.yml')
|
37
|
-
end
|
38
|
-
|
39
|
-
def update_gitignore
|
40
|
-
append_file '.gitignore', "\n\n# Ignore docker caches\ndocker"
|
41
|
-
|
42
|
-
if include_docker_sync?
|
43
|
-
append_file '.gitignore', "\n.docker-sync"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
private
|
48
|
-
|
49
|
-
def app_name
|
50
|
-
@app_name ||= Rails.root.to_s.split('/').last
|
51
|
-
end
|
52
|
-
|
53
|
-
def include_webpack?
|
54
|
-
!!options['webpack']
|
55
|
-
end
|
56
|
-
|
57
|
-
def include_docker_sync?
|
58
|
-
!!options['sync']
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
FROM ruby:2.4.4-slim
|
2
|
-
|
3
|
-
ARG APP_PATH
|
4
|
-
ARG APP_BUNDLE_BIN
|
5
|
-
|
6
|
-
RUN apt-get update \
|
7
|
-
&& apt-get install -yqq curl gnupg \
|
8
|
-
&& curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
|
9
|
-
&& echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list \
|
10
|
-
&& curl -sL https://deb.nodesource.com/setup_8.x | bash - \
|
11
|
-
&& apt-get update \
|
12
|
-
&& apt-get install -yqq --no-install-recommends \
|
13
|
-
git \
|
14
|
-
ssh \
|
15
|
-
tzdata \
|
16
|
-
build-essential \
|
17
|
-
nodejs \
|
18
|
-
libssl-dev \
|
19
|
-
libyaml-dev \
|
20
|
-
libreadline6-dev \
|
21
|
-
zlib1g-dev \
|
22
|
-
libncurses5-dev \
|
23
|
-
libffi-dev \
|
24
|
-
libgdbm3 \
|
25
|
-
libgdbm-dev \
|
26
|
-
autoconf \
|
27
|
-
bison \
|
28
|
-
xvfb \
|
29
|
-
imagemagick \
|
30
|
-
jpegoptim \
|
31
|
-
google-chrome-stable \
|
32
|
-
&& apt-get clean \
|
33
|
-
&& rm -rf /var/lib/apt/lists/*
|
34
|
-
|
35
|
-
<% if include_webpack? %>
|
36
|
-
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
|
37
|
-
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" >> /etc/apt/sources.list.d/yarn.list \
|
38
|
-
&& apt-get update && apt-get install -yqq --no-install-recommends yarn
|
39
|
-
|
40
|
-
EXPOSE 3035
|
41
|
-
<% end %>
|
42
|
-
EXPOSE 3000
|
43
|
-
|
44
|
-
ENV PATH /usr/local/bundle/bin:$APP_PATH/bin:$APP_BUNDLE_BIN:$PATH
|
45
|
-
|
46
|
-
WORKDIR $APP_PATH
|
47
|
-
|
48
|
-
CMD ["sh", "docker-entrypoint.sh"]
|
@@ -1,72 +0,0 @@
|
|
1
|
-
version: '3'
|
2
|
-
services:
|
3
|
-
mongo:
|
4
|
-
image: "mongo:4.0"
|
5
|
-
volumes:
|
6
|
-
- mongo:/data/db
|
7
|
-
|
8
|
-
redis:
|
9
|
-
image: "redis"
|
10
|
-
volumes:
|
11
|
-
- redis:/data
|
12
|
-
|
13
|
-
elasticsearch:
|
14
|
-
image: "elasticsearch:5.6"
|
15
|
-
ports:
|
16
|
-
- '9201:9200'
|
17
|
-
- '9301:9300'
|
18
|
-
volumes:
|
19
|
-
- elasticsearch:/usr/share/elasticsearch/data
|
20
|
-
|
21
|
-
# Uncomment this is you want to use mailcatcher
|
22
|
-
# mailcatcher:
|
23
|
-
# image: schickling/mailcatcher
|
24
|
-
# ports:
|
25
|
-
# - 1080:1080
|
26
|
-
|
27
|
-
web: &web
|
28
|
-
build:
|
29
|
-
context: .
|
30
|
-
args:
|
31
|
-
- APP_PATH=${APP_PATH}
|
32
|
-
- APP_BUNDLE_BIN=${BUNDLE_BIN}
|
33
|
-
ports:
|
34
|
-
- "${RAILS_PORT}:3000"
|
35
|
-
volumes:
|
36
|
-
- <%= include_docker_sync? ? "#{app_name}-sync:${APP_PATH}:nocopy" : ".:${APP_PATH}" %>
|
37
|
-
<%= '- gem_cache:/gems' unless include_docker_sync? %>
|
38
|
-
depends_on:
|
39
|
-
- redis
|
40
|
-
- mongo
|
41
|
-
- elasticsearch
|
42
|
-
env_file:
|
43
|
-
- docker.env
|
44
|
-
stdin_open: true
|
45
|
-
tty: true
|
46
|
-
<% if include_webpack? %>
|
47
|
-
webpack_server:
|
48
|
-
<<: *web
|
49
|
-
command: ['sh', './docker-wait.sh', 'bin/webpack-dev-server']
|
50
|
-
depends_on:
|
51
|
-
- web
|
52
|
-
ports:
|
53
|
-
- '3035:3035'
|
54
|
-
<% end %>
|
55
|
-
# Uncomment this if you want to run sidekiq
|
56
|
-
# sidekiq:
|
57
|
-
# <<: *web
|
58
|
-
# command: ['sh', './docker-wait.sh', 'sidekiq']
|
59
|
-
# depends_on:
|
60
|
-
# - web
|
61
|
-
# ports: []
|
62
|
-
|
63
|
-
volumes:
|
64
|
-
mongo:
|
65
|
-
redis:
|
66
|
-
elasticsearch:
|
67
|
-
<% if include_docker_sync? %>
|
68
|
-
<%= app_name %>-sync:
|
69
|
-
external: true
|
70
|
-
<% else %>
|
71
|
-
gem_cache:
|
72
|
-
<% end%>
|
@@ -1,11 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
# Pass a command to run only after bundle is updated.
|
3
|
-
# This is used to allow only the web service to update bundle
|
4
|
-
# but have other services that need bundle to be updated to wait
|
5
|
-
# until the web service has finished updating before running the
|
6
|
-
# desired command to start the container's process.
|
7
|
-
# example: sh docker-wait.sh sidekiq
|
8
|
-
|
9
|
-
set -e
|
10
|
-
until bundle check > /dev/null 2>&1; do sleep 5; done
|
11
|
-
exec $@
|
@@ -1,16 +0,0 @@
|
|
1
|
-
DOCKER=true
|
2
|
-
|
3
|
-
# Passed from env
|
4
|
-
APP_PATH
|
5
|
-
GEM_HOME
|
6
|
-
BUNDLE_PATH
|
7
|
-
BUNDLE_BIN
|
8
|
-
BUNDLE_GEMS__WEBLINC__COM
|
9
|
-
|
10
|
-
# Set autoconfig service connections
|
11
|
-
WORKAREA_MONGOID_HOST_0=mongo:27017
|
12
|
-
WORKAREA_REDIS_HOST=redis
|
13
|
-
WORKAREA_REDIS_PORT=6379
|
14
|
-
WORKAREA_REDIS_CACHE_HOST=redis
|
15
|
-
WORKAREA_REDIS_CACHE_PORT=6379
|
16
|
-
WORKAREA_ELASTICSEARCH_URL=elasticsearch:9200
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# Do things here that you only want to apply to your docker environment
|
2
|
-
#
|
3
|
-
if ENV['DOCKER'].to_s =~ /true/
|
4
|
-
#
|
5
|
-
# Modify workarea configuration
|
6
|
-
#
|
7
|
-
Workarea.configure do |config|
|
8
|
-
config.headless_chrome_options << 'no-sandbox'
|
9
|
-
end
|
10
|
-
|
11
|
-
#
|
12
|
-
# Modify application configuration
|
13
|
-
#
|
14
|
-
Rails.application.configure do
|
15
|
-
<%= 'config.file_watcher = ActiveSupport::FileUpdateChecker' unless include_docker_sync? %>
|
16
|
-
|
17
|
-
# Uncomment if you want to use mailcatcher
|
18
|
-
# config.action_mailer.delivery_method = :smtp
|
19
|
-
# config.action_mailer.smtp_settings = { :address => 'mailcatcher', :port => 1025 }
|
20
|
-
|
21
|
-
# Allow web console in Docker
|
22
|
-
if Rails.env.development?
|
23
|
-
config.web_console.whitelisted_ips = Socket.ip_address_list.reduce([]) do |res, addrinfo|
|
24
|
-
addrinfo.ipv4? ? res << IPAddr.new(addrinfo.ip_address).mask(24) : res
|
25
|
-
end
|
26
|
-
WebConsole::Request.whitelisted_ips = WebConsole::Whitelist.new(config.web_console.whitelisted_ips)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
module Workarea
|
2
|
-
module Configuration
|
3
|
-
module HeadlessChrome
|
4
|
-
extend self
|
5
|
-
|
6
|
-
# TODO v3.5
|
7
|
-
#
|
8
|
-
# Allow apps to configure both Chrome options and arguments separately, as
|
9
|
-
# any given release to Chrome may require changing these separately.
|
10
|
-
#
|
11
|
-
def load
|
12
|
-
Workarea.config.headless_chrome_args = Workarea.config.headless_chrome_options
|
13
|
-
end
|
14
|
-
|
15
|
-
def options
|
16
|
-
default_options.merge(env_options)
|
17
|
-
end
|
18
|
-
|
19
|
-
def default_options
|
20
|
-
{ args: args, w3c: false }
|
21
|
-
end
|
22
|
-
|
23
|
-
def env_options
|
24
|
-
parsed = if ENV['WORKAREA_HEADLESS_CHROME_OPTIONS'].blank?
|
25
|
-
{}
|
26
|
-
else
|
27
|
-
JSON.parse(ENV['WORKAREA_HEADLESS_CHROME_OPTIONS'])
|
28
|
-
end
|
29
|
-
|
30
|
-
parsed.symbolize_keys
|
31
|
-
end
|
32
|
-
|
33
|
-
def args
|
34
|
-
(Workarea.config.headless_chrome_args + env_args).uniq
|
35
|
-
end
|
36
|
-
|
37
|
-
def env_args
|
38
|
-
ENV['WORKAREA_HEADLESS_CHROME_ARGS'].to_s.split
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
module Workarea
|
2
|
-
module Configuration
|
3
|
-
module Puma
|
4
|
-
extend self
|
5
|
-
|
6
|
-
def load(puma)
|
7
|
-
puma.port(port)
|
8
|
-
puma.threads(threads, threads)
|
9
|
-
puma.environment(environment)
|
10
|
-
|
11
|
-
if workers.present?
|
12
|
-
puma.workers(workers)
|
13
|
-
puma.preload_app!
|
14
|
-
end
|
15
|
-
|
16
|
-
puma.plugin(:tmp_restart)
|
17
|
-
puma.set_remote_address(header: 'X-Real-IP') # For hosted environments
|
18
|
-
end
|
19
|
-
|
20
|
-
def port
|
21
|
-
ENV.fetch('PORT') { 3000 }
|
22
|
-
end
|
23
|
-
|
24
|
-
def threads
|
25
|
-
ENV.fetch('RAILS_MAX_THREADS') { 5 }
|
26
|
-
end
|
27
|
-
|
28
|
-
def environment
|
29
|
-
ENV.fetch('RAILS_ENV') { 'development' }
|
30
|
-
end
|
31
|
-
|
32
|
-
def workers
|
33
|
-
ENV.fetch('WEB_CONCURRENCY') { nil }
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module I18n
|
2
|
-
module JS
|
3
|
-
class FallbackLocales
|
4
|
-
# i18n-js uses just the second part of this check out-of-the-box. This
|
5
|
-
# causes the I18n fallbacks to get autoloaded without the developer
|
6
|
-
# knowing.
|
7
|
-
#
|
8
|
-
# This surfaces in tests. System or integration tests will do this check
|
9
|
-
# for compiling assets, then I18n fallbacks get autoloaded. So this shows
|
10
|
-
# as some tests not having fallbacks if they run before one of those tests
|
11
|
-
# or magically having fallbacks if they run after one of those types of
|
12
|
-
# tests.
|
13
|
-
#
|
14
|
-
# Adding the `respond_to?` check doesn't cause autoload, but will return
|
15
|
-
# `true` if fallbacks are enabled. Retain the original check because we
|
16
|
-
# want the current I18n::JS backend to be checked, once fallbacks are
|
17
|
-
# `require`d `I18n.respond_to?(:fallbacks)` will always return `true`.
|
18
|
-
#
|
19
|
-
# See also: https://github.com/fnando/i18n-js/blob/master/lib/i18n/js/fallback_locales.rb#L49-L58
|
20
|
-
#
|
21
|
-
def using_i18n_fallbacks_module?
|
22
|
-
I18n.respond_to?(:fallbacks) &&
|
23
|
-
I18n::JS.backend.class.included_modules.include?(I18n::Backend::Fallbacks)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Mongoid
|
2
|
-
module Fields
|
3
|
-
module LocalizedDefaults
|
4
|
-
def create_accessors(name, meth, options = {})
|
5
|
-
super
|
6
|
-
|
7
|
-
if options[:localize]
|
8
|
-
field = fields[name]
|
9
|
-
|
10
|
-
define_method meth do |*args|
|
11
|
-
result = super(*args)
|
12
|
-
return result unless result.nil?
|
13
|
-
|
14
|
-
default_name = field.send(:default_name)
|
15
|
-
return send(default_name) if respond_to?(default_name)
|
16
|
-
|
17
|
-
field.default_val
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
ClassMethods.prepend(LocalizedDefaults)
|
24
|
-
end
|
25
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
decorate JbuilderTemplate, with: :workarea do
|
2
|
-
def _cache_fragment_for(*)
|
3
|
-
return yield if workarea_admin?
|
4
|
-
|
5
|
-
super
|
6
|
-
end
|
7
|
-
|
8
|
-
def _cache_key(*)
|
9
|
-
super.tap do |result|
|
10
|
-
result << workarea_cache_varies if workarea_cache_varies.present?
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def workarea_admin?
|
17
|
-
@context&.controller&.current_user&.admin?
|
18
|
-
rescue ::RuntimeError
|
19
|
-
false
|
20
|
-
end
|
21
|
-
|
22
|
-
def workarea_cache_varies
|
23
|
-
workarea_request_env['workarea.cache_varies']
|
24
|
-
end
|
25
|
-
|
26
|
-
def workarea_request_env
|
27
|
-
@context.controller.request.env || {}
|
28
|
-
end
|
29
|
-
end
|