solidus_starter_frontend 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +57 -0
- data/.erb-lint.yml +22 -0
- data/.eslintrc +5 -0
- data/.gem_release.yml +5 -0
- data/.github/pull_request_template.md +28 -0
- data/.github/stale.yml +17 -0
- data/.gitignore +17 -0
- data/.hound.yml +16 -0
- data/.rspec +2 -0
- data/.rubocop.yml +19 -0
- data/.rubocop_todo.yml +229 -0
- data/.scss-lint.yml +4 -0
- data/Gemfile +34 -0
- data/LICENSE +26 -0
- data/README.md +69 -0
- data/Rakefile +6 -0
- data/app/assets/config/solidus_starter_frontend_manifest.js +2 -0
- data/app/assets/javascripts/spree/frontend.js +6 -0
- data/app/assets/javascripts/spree/frontend/cart.js +26 -0
- data/app/assets/javascripts/spree/frontend/checkout.js +34 -0
- data/app/assets/javascripts/spree/frontend/checkout/address.js +124 -0
- data/app/assets/javascripts/spree/frontend/checkout/payment.js +44 -0
- data/app/assets/javascripts/spree/frontend/locale_selector.js +9 -0
- data/app/assets/javascripts/spree/frontend/product.js +21 -0
- data/app/assets/javascripts/spree/frontend/solidus_starter_frontend.js +9 -0
- data/app/assets/javascripts/spree/frontend/utils.js.erb +18 -0
- data/app/assets/stylesheets/spree/frontend.css +8 -0
- data/app/assets/stylesheets/spree/frontend/base/_base.scss +29 -0
- data/app/assets/stylesheets/spree/frontend/base/_reset.scss +179 -0
- data/app/assets/stylesheets/spree/frontend/base/_responsive.scss +21 -0
- data/app/assets/stylesheets/spree/frontend/components/account/_account_order.scss +23 -0
- data/app/assets/stylesheets/spree/frontend/components/account/_account_summary.scss +17 -0
- data/app/assets/stylesheets/spree/frontend/components/auth/_auth_container.scss +11 -0
- data/app/assets/stylesheets/spree/frontend/components/auth/_auth_form.scss +5 -0
- data/app/assets/stylesheets/spree/frontend/components/brand/_logo.scss +4 -0
- data/app/assets/stylesheets/spree/frontend/components/buttons/_button_inline.scss +8 -0
- data/app/assets/stylesheets/spree/frontend/components/buttons/_button_primary.scss +26 -0
- data/app/assets/stylesheets/spree/frontend/components/cart/_cart_adjustments.scss +6 -0
- data/app/assets/stylesheets/spree/frontend/components/cart/_cart_amount_row.scss +11 -0
- data/app/assets/stylesheets/spree/frontend/components/cart/_cart_empty.scss +10 -0
- data/app/assets/stylesheets/spree/frontend/components/cart/_cart_footer.scss +20 -0
- data/app/assets/stylesheets/spree/frontend/components/cart/_cart_header.scss +12 -0
- data/app/assets/stylesheets/spree/frontend/components/cart/_cart_item.scss +86 -0
- data/app/assets/stylesheets/spree/frontend/components/cart/_cart_link.scss +22 -0
- data/app/assets/stylesheets/spree/frontend/components/cart/_cart_page.scss +15 -0
- data/app/assets/stylesheets/spree/frontend/components/cart/_cart_secondary_actions.scss +19 -0
- data/app/assets/stylesheets/spree/frontend/components/cart/_coupon_code.scss +8 -0
- data/app/assets/stylesheets/spree/frontend/components/cart/_item_info.scss +19 -0
- data/app/assets/stylesheets/spree/frontend/components/checkout/_checkout.scss +27 -0
- data/app/assets/stylesheets/spree/frontend/components/checkout/_checkout_header.scss +19 -0
- data/app/assets/stylesheets/spree/frontend/components/checkout/_checkout_summary.scss +31 -0
- data/app/assets/stylesheets/spree/frontend/components/checkout/_existing_cards.scss +27 -0
- data/app/assets/stylesheets/spree/frontend/components/checkout/_payment_method_controls.scss +5 -0
- data/app/assets/stylesheets/spree/frontend/components/checkout/_payment_method_selector.scss +14 -0
- data/app/assets/stylesheets/spree/frontend/components/checkout/_progress_steps.scss +38 -0
- data/app/assets/stylesheets/spree/frontend/components/checkout/_proposed_shipment.scss +18 -0
- data/app/assets/stylesheets/spree/frontend/components/checkout/_shipment_items.scss +50 -0
- data/app/assets/stylesheets/spree/frontend/components/checkout/_shipping_methods.scss +9 -0
- data/app/assets/stylesheets/spree/frontend/components/checkout/payments/_gateway_payment_method.scss +11 -0
- data/app/assets/stylesheets/spree/frontend/components/checkout/steps/_address_step.scss +20 -0
- data/app/assets/stylesheets/spree/frontend/components/checkout/steps/_confirm_step.scss +13 -0
- data/app/assets/stylesheets/spree/frontend/components/checkout/steps/_delivery_step.scss +13 -0
- data/app/assets/stylesheets/spree/frontend/components/checkout/steps/_payment_step.scss +13 -0
- data/app/assets/stylesheets/spree/frontend/components/forms/_address_inputs.scss +13 -0
- data/app/assets/stylesheets/spree/frontend/components/forms/inputs/_checkbox_input.scss +3 -0
- data/app/assets/stylesheets/spree/frontend/components/forms/inputs/_radio_input.scss +3 -0
- data/app/assets/stylesheets/spree/frontend/components/forms/inputs/_select_input.scss +27 -0
- data/app/assets/stylesheets/spree/frontend/components/forms/inputs/_text.scss +32 -0
- data/app/assets/stylesheets/spree/frontend/components/forms/inputs/_textarea_input.scss +25 -0
- data/app/assets/stylesheets/spree/frontend/components/general/_flash.scss +20 -0
- data/app/assets/stylesheets/spree/frontend/components/layout/_aside.scss +4 -0
- data/app/assets/stylesheets/spree/frontend/components/layout/_breadcrumbs.scss +16 -0
- data/app/assets/stylesheets/spree/frontend/components/layout/_category_navigation.scss +3 -0
- data/app/assets/stylesheets/spree/frontend/components/layout/_footer.scss +8 -0
- data/app/assets/stylesheets/spree/frontend/components/layout/_header.scss +12 -0
- data/app/assets/stylesheets/spree/frontend/components/layout/_horizontal_input_group.scss +7 -0
- data/app/assets/stylesheets/spree/frontend/components/layout/_top_bar.scss +44 -0
- data/app/assets/stylesheets/spree/frontend/components/navigation/_auth_link.scss +11 -0
- data/app/assets/stylesheets/spree/frontend/components/navigation/_categories.scss +29 -0
- data/app/assets/stylesheets/spree/frontend/components/navigation/_locale_selector.scss +21 -0
- data/app/assets/stylesheets/spree/frontend/components/navigation/_taxonomies.scss +7 -0
- data/app/assets/stylesheets/spree/frontend/components/navigation/_taxonomy.scss +28 -0
- data/app/assets/stylesheets/spree/frontend/components/orders/_address_overview.scss +27 -0
- data/app/assets/stylesheets/spree/frontend/components/orders/_coupon_codes.scss +4 -0
- data/app/assets/stylesheets/spree/frontend/components/orders/_line_items.scss +20 -0
- data/app/assets/stylesheets/spree/frontend/components/orders/_order_details.scss +18 -0
- data/app/assets/stylesheets/spree/frontend/components/orders/_order_item.scss +85 -0
- data/app/assets/stylesheets/spree/frontend/components/orders/_order_page.scss +41 -0
- data/app/assets/stylesheets/spree/frontend/components/orders/_order_shipments.scss +27 -0
- data/app/assets/stylesheets/spree/frontend/components/orders/_payment_info.scss +29 -0
- data/app/assets/stylesheets/spree/frontend/components/presentation/_hero.scss +18 -0
- data/app/assets/stylesheets/spree/frontend/components/products/_product_card.scss +35 -0
- data/app/assets/stylesheets/spree/frontend/components/products/_product_image.scss +7 -0
- data/app/assets/stylesheets/spree/frontend/components/products/_product_info.scss +14 -0
- data/app/assets/stylesheets/spree/frontend/components/products/_product_page.scss +31 -0
- data/app/assets/stylesheets/spree/frontend/components/products/_product_properties.scss +23 -0
- data/app/assets/stylesheets/spree/frontend/components/products/_product_submit.scss +9 -0
- data/app/assets/stylesheets/spree/frontend/components/products/_product_taxons.scss +27 -0
- data/app/assets/stylesheets/spree/frontend/components/products/_product_thumbnails.scss +7 -0
- data/app/assets/stylesheets/spree/frontend/components/products/_product_variants.scss +20 -0
- data/app/assets/stylesheets/spree/frontend/components/products/_products.scss +13 -0
- data/app/assets/stylesheets/spree/frontend/components/products/_products_by_taxon.scss +6 -0
- data/app/assets/stylesheets/spree/frontend/components/products/_products_grid.scss +18 -0
- data/app/assets/stylesheets/spree/frontend/components/search/_filter.scss +32 -0
- data/app/assets/stylesheets/spree/frontend/components/search/_search_bar.scss +34 -0
- data/app/assets/stylesheets/spree/frontend/components/typography/_hero_title.scss +6 -0
- data/app/assets/stylesheets/spree/frontend/components/typography/_subtitle.scss +7 -0
- data/app/assets/stylesheets/spree/frontend/placeholders/main.scss +5 -0
- data/app/assets/stylesheets/spree/frontend/screen.scss +89 -0
- data/app/assets/stylesheets/spree/frontend/solidus_starter_frontend.css +7 -0
- data/app/assets/stylesheets/spree/frontend/variables/_colors.scss +20 -0
- data/app/controllers/concerns/solidus_starter_frontend/auth_views.rb +16 -0
- data/app/controllers/concerns/solidus_starter_frontend/taxonomies.rb +16 -0
- data/app/controllers/spree/checkout_controller.rb +249 -0
- data/app/controllers/spree/coupon_codes_controller.rb +35 -0
- data/app/controllers/spree/home_controller.rb +13 -0
- data/app/controllers/spree/locale_controller.rb +20 -0
- data/app/controllers/spree/orders_controller.rb +126 -0
- data/app/controllers/spree/products_controller.rb +51 -0
- data/app/controllers/spree/store_controller.rb +31 -0
- data/app/controllers/spree/taxons_controller.rb +30 -0
- data/app/helpers/spree/orders_helper.rb +18 -0
- data/app/helpers/spree/taxon_filters_helper.rb +13 -0
- data/app/views/spree/address/_form_hidden.html.erb +12 -0
- data/app/views/spree/checkout/_terms_and_conditions.en.html.erb +1 -0
- data/app/views/spree/checkout/edit.html.erb +16 -0
- data/app/views/spree/checkout/existing_payment/_gateway.html.erb +9 -0
- data/app/views/spree/checkout/payment/_check.html.erb +0 -0
- data/app/views/spree/checkout/payment/_gateway.html.erb +43 -0
- data/app/views/spree/components/auth/_change_form.html.erb +40 -0
- data/app/views/spree/components/auth/_forgot_form.html.erb +28 -0
- data/app/views/spree/components/auth/_guest_form.html.erb +31 -0
- data/app/views/spree/components/auth/_login_form.html.erb +42 -0
- data/app/views/spree/components/auth/_signup_form.html.erb +48 -0
- data/app/views/spree/components/brand/_logo.html.erb +3 -0
- data/app/views/spree/components/buttons/_button_inline.html.erb +23 -0
- data/app/views/spree/components/buttons/_button_primary.html.erb +29 -0
- data/app/views/spree/components/cart/_cart_adjustment.html.erb +15 -0
- data/app/views/spree/components/cart/_cart_adjustments.html.erb +47 -0
- data/app/views/spree/components/cart/_cart_amount_row.html.erb +12 -0
- data/app/views/spree/components/cart/_cart_empty.html.erb +9 -0
- data/app/views/spree/components/cart/_cart_footer.html.erb +15 -0
- data/app/views/spree/components/cart/_cart_header.html.erb +17 -0
- data/app/views/spree/components/cart/_cart_item.html.erb +52 -0
- data/app/views/spree/components/cart/_cart_items.html.erb +23 -0
- data/app/views/spree/components/cart/_cart_link.html.erb +9 -0
- data/app/views/spree/components/cart/_cart_secondary_actions.html.erb +17 -0
- data/app/views/spree/components/cart/_item_info.html.erb +26 -0
- data/app/views/spree/components/checkout/_checkout_header.html.erb +8 -0
- data/app/views/spree/components/checkout/_checkout_step.html.erb +21 -0
- data/app/views/spree/components/checkout/_checkout_summary.html.erb +70 -0
- data/app/views/spree/components/checkout/_existing_cards.html.erb +39 -0
- data/app/views/spree/components/checkout/_payment_method_controls.html.erb +10 -0
- data/app/views/spree/components/checkout/_payment_method_selector.html.erb +14 -0
- data/app/views/spree/components/checkout/_proposed_shipment.erb +18 -0
- data/app/views/spree/components/checkout/_shipment_items.html.erb +22 -0
- data/app/views/spree/components/checkout/_shipping_methods.html.erb +20 -0
- data/app/views/spree/components/checkout/_unshippable_items.html.erb +7 -0
- data/app/views/spree/components/checkout/steps/_address_step.html.erb +60 -0
- data/app/views/spree/components/checkout/steps/_confirm_step.html.erb +31 -0
- data/app/views/spree/components/checkout/steps/_delivery_step.html.erb +31 -0
- data/app/views/spree/components/checkout/steps/_payment_step.html.erb +25 -0
- data/app/views/spree/components/forms/_address_inputs.html.erb +152 -0
- data/app/views/spree/components/forms/inputs/_checkbox_input.html.erb +29 -0
- data/app/views/spree/components/forms/inputs/_collection_select.html.erb +42 -0
- data/app/views/spree/components/forms/inputs/_radio_input.html.erb +29 -0
- data/app/views/spree/components/forms/inputs/_select_input.html.erb +31 -0
- data/app/views/spree/components/forms/inputs/_text.html.erb +54 -0
- data/app/views/spree/components/forms/inputs/_textarea_input.html.erb +42 -0
- data/app/views/spree/components/layout/_category_navigation.html.erb +3 -0
- data/app/views/spree/components/layout/_footer.html.erb +7 -0
- data/app/views/spree/components/layout/_header.html.erb +8 -0
- data/app/views/spree/components/layout/_top_bar.html.erb +8 -0
- data/app/views/spree/components/navigation/_auth_link.html.erb +1 -0
- data/app/views/spree/components/navigation/_breadcrumbs.html.erb +47 -0
- data/app/views/spree/components/navigation/_categories.html.erb +12 -0
- data/app/views/spree/components/navigation/_locale_selector.html.erb +25 -0
- data/app/views/spree/components/navigation/_taxonomies.html.erb +17 -0
- data/app/views/spree/components/navigation/_taxons.html.erb +17 -0
- data/app/views/spree/components/navigation/_taxons_tree.html.erb +29 -0
- data/app/views/spree/components/orders/_address_overview.html.erb +40 -0
- data/app/views/spree/components/orders/_coupon_code.html.erb +22 -0
- data/app/views/spree/components/orders/_line_items.html.erb +55 -0
- data/app/views/spree/components/orders/_order_details.html.erb +35 -0
- data/app/views/spree/components/orders/_order_item.html.erb +33 -0
- data/app/views/spree/components/orders/_order_items.html.erb +5 -0
- data/app/views/spree/components/orders/_order_shipments.html.erb +25 -0
- data/app/views/spree/components/orders/_payment_info.html.erb +31 -0
- data/app/views/spree/components/presentation/_hero.html.erb +14 -0
- data/app/views/spree/components/products/_product-card.html.erb +36 -0
- data/app/views/spree/components/products/_product_availability.html.erb +19 -0
- data/app/views/spree/components/products/_product_form.html.erb +21 -0
- data/app/views/spree/components/products/_product_image.html.erb +6 -0
- data/app/views/spree/components/products/_product_info.html.erb +9 -0
- data/app/views/spree/components/products/_product_promotions.html.erb +25 -0
- data/app/views/spree/components/products/_product_properties.html.erb +19 -0
- data/app/views/spree/components/products/_product_submit.html.erb +39 -0
- data/app/views/spree/components/products/_product_taxons.html.erb +15 -0
- data/app/views/spree/components/products/_product_thumbnails.html.erb +19 -0
- data/app/views/spree/components/products/_product_variants.html.erb +36 -0
- data/app/views/spree/components/products/_products-grid.html.erb +13 -0
- data/app/views/spree/components/products/_products.html.erb +28 -0
- data/app/views/spree/components/products/_products_by_taxon.html.erb +7 -0
- data/app/views/spree/components/products/_variants_list.html.erb +12 -0
- data/app/views/spree/components/search/_filter.html.erb +42 -0
- data/app/views/spree/components/search/_filters.html.erb +20 -0
- data/app/views/spree/components/search/_form.html.erb +12 -0
- data/app/views/spree/components/search/_products_search.html.erb +36 -0
- data/app/views/spree/components/search/_search_bar.html.erb +36 -0
- data/app/views/spree/components/typography/_hero_title.html.erb +11 -0
- data/app/views/spree/components/typography/_subtitle.html.erb +11 -0
- data/app/views/spree/home/index.html.erb +7 -0
- data/app/views/spree/layouts/spree_application.html.erb +27 -0
- data/app/views/spree/orders/edit.html.erb +21 -0
- data/app/views/spree/orders/show.html.erb +29 -0
- data/app/views/spree/products/index.html.erb +22 -0
- data/app/views/spree/products/show.html.erb +18 -0
- data/app/views/spree/shared/_image.html.erb +12 -0
- data/app/views/spree/shared/_link_to_cart.html.erb +1 -0
- data/app/views/spree/shared/_login_bar_items.html.erb +1 -0
- data/app/views/spree/shared/_shipment_tracking.html.erb +11 -0
- data/app/views/spree/shared/unauthorized.html.erb +0 -0
- data/app/views/spree/taxons/show.html.erb +17 -0
- data/bin/console +17 -0
- data/bin/r +13 -0
- data/bin/rails +7 -0
- data/bin/rake +7 -0
- data/bin/rspec +29 -0
- data/bin/sandbox +84 -0
- data/bin/sandbox_rails +18 -0
- data/bin/setup +8 -0
- data/bin/solidus_compare +155 -0
- data/config/initializers/assets.rb +1 -0
- data/config/initializers/canonical_rails.rb +16 -0
- data/config/locales/en.yml +5 -0
- data/config/routes.rb +33 -0
- data/config/solidus_compare.yml +33 -0
- data/docs/development.md +28 -0
- data/exe/solidus_starter_frontend +9 -0
- data/lib/generators/solidus_starter_frontend/install/install_generator.rb +15 -0
- data/lib/generators/solidus_starter_frontend/solidus_starter_frontend_generator.rb +30 -0
- data/lib/generators/solidus_starter_frontend/views/override_generator.rb +50 -0
- data/lib/solidus_starter_frontend.rb +12 -0
- data/lib/solidus_starter_frontend/config.rb +7 -0
- data/lib/solidus_starter_frontend/engine.rb +34 -0
- data/lib/solidus_starter_frontend/factories.rb +4 -0
- data/lib/solidus_starter_frontend/solidus_support_extensions.rb +9 -0
- data/lib/solidus_starter_frontend/version.rb +5 -0
- data/lib/solidus_starter_frontend_configuration.rb +8 -0
- data/lib/views/auth/spree/checkout/registration.html.erb +7 -0
- data/lib/views/auth/spree/components/navigation/_auth_link.html.erb +5 -0
- data/lib/views/auth/spree/user_passwords/edit.html.erb +7 -0
- data/lib/views/auth/spree/user_passwords/new.html.erb +5 -0
- data/lib/views/auth/spree/user_registrations/new.html.erb +7 -0
- data/lib/views/auth/spree/user_sessions/guest.html.erb +5 -0
- data/lib/views/auth/spree/user_sessions/new.html.erb +7 -0
- data/lib/views/auth/spree/users/edit.html.erb +45 -0
- data/lib/views/auth/spree/users/show.html.erb +55 -0
- data/solidus_starter_frontend.gemspec +43 -0
- data/spec/controllers/controller_helpers_spec.rb +29 -0
- data/spec/controllers/locale_controller_spec.rb +57 -0
- data/spec/controllers/spree/checkout_controller_spec.rb +563 -0
- data/spec/controllers/spree/checkout_controller_with_views_spec.rb +37 -0
- data/spec/controllers/spree/current_order_tracking_spec.rb +33 -0
- data/spec/controllers/spree/home_controller_spec.rb +29 -0
- data/spec/controllers/spree/orders_controller_ability_spec.rb +90 -0
- data/spec/controllers/spree/orders_controller_spec.rb +241 -0
- data/spec/controllers/spree/orders_controller_transitions_spec.rb +33 -0
- data/spec/controllers/spree/products_controller_spec.rb +38 -0
- data/spec/controllers/spree/taxons_controller_spec.rb +14 -0
- data/spec/fixtures/thinking-cat.jpg +0 -0
- data/spec/generators/solidus/views/override_generator_spec.rb +50 -0
- data/spec/helpers/base_helper_spec.rb +13 -0
- data/spec/helpers/order_helper_spec.rb +14 -0
- data/spec/helpers/taxon_filters_helper_spec.rb +12 -0
- data/spec/spec_helper.rb +64 -0
- data/spec/support/shared_contexts/checkout_setup.rb +12 -0
- data/spec/support/shared_contexts/custom_products.rb +28 -0
- data/spec/support/shared_contexts/locales.rb +16 -0
- data/spec/system/address_spec.rb +87 -0
- data/spec/system/automatic_promotion_adjustments_spec.rb +49 -0
- data/spec/system/caching/products_spec.rb +48 -0
- data/spec/system/caching/taxons_spec.rb +35 -0
- data/spec/system/cart_spec.rb +81 -0
- data/spec/system/checkout_confirm_insufficient_stock_spec.rb +71 -0
- data/spec/system/checkout_spec.rb +699 -0
- data/spec/system/checkout_unshippable_spec.rb +37 -0
- data/spec/system/coupon_code_spec.rb +267 -0
- data/spec/system/currency_spec.rb +20 -0
- data/spec/system/first_order_promotion_spec.rb +59 -0
- data/spec/system/free_shipping_promotions_spec.rb +60 -0
- data/spec/system/locale_spec.rb +26 -0
- data/spec/system/order_spec.rb +57 -0
- data/spec/system/products_spec.rb +302 -0
- data/spec/system/promotion_code_invalidation_spec.rb +54 -0
- data/spec/system/quantity_promotions_spec.rb +130 -0
- data/spec/system/taxons_spec.rb +158 -0
- data/spec/system/template_rendering_spec.rb +20 -0
- data/spec/views/spree/checkout/_summary_spec.rb +11 -0
- metadata +542 -0
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Spree::ProductsController, type: :controller do
|
6
|
+
let!(:product) { create(:product, available_on: 1.year.from_now) }
|
7
|
+
|
8
|
+
# Regression test for https://github.com/spree/spree/issues/1390
|
9
|
+
it "allows admins to view non-active products" do
|
10
|
+
allow(controller).to receive_messages try_spree_current_user: mock_model(Spree.user_class, has_spree_role?: true, last_incomplete_spree_order: nil, spree_api_key: 'fake')
|
11
|
+
get :show, params: { id: product.to_param }
|
12
|
+
expect(response.status).to eq(200)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "cannot view non-active products" do
|
16
|
+
expect {
|
17
|
+
get :show, params: { id: product.to_param }
|
18
|
+
}.to raise_error(ActiveRecord::RecordNotFound)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should provide the current user to the searcher class" do
|
22
|
+
user = mock_model(Spree.user_class, last_incomplete_spree_order: nil, spree_api_key: 'fake')
|
23
|
+
allow(controller).to receive_messages try_spree_current_user: user
|
24
|
+
expect_any_instance_of(Spree::Config.searcher_class).to receive(:current_user=).with(user)
|
25
|
+
get :index
|
26
|
+
expect(response.status).to eq(200)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Regression test for https://github.com/spree/spree/issues/2249
|
30
|
+
it "doesn't error when given an invalid referer" do
|
31
|
+
current_user = mock_model(Spree.user_class, has_spree_role?: true, last_incomplete_spree_order: nil, generate_spree_api_key!: nil)
|
32
|
+
allow(controller).to receive_messages try_spree_current_user: current_user
|
33
|
+
request.env['HTTP_REFERER'] = "not|a$url"
|
34
|
+
|
35
|
+
# Previously a URI::InvalidURIError exception was being thrown
|
36
|
+
get :show, params: { id: product.to_param }
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Spree::TaxonsController, type: :controller do
|
6
|
+
it "should provide the current user to the searcher class" do
|
7
|
+
taxon = create(:taxon, permalink: "test")
|
8
|
+
user = mock_model(Spree.user_class, last_incomplete_spree_order: nil, spree_api_key: 'fake')
|
9
|
+
allow(controller).to receive_messages try_spree_current_user: user
|
10
|
+
expect_any_instance_of(Spree::Config.searcher_class).to receive(:current_user=).with(user)
|
11
|
+
get :show, params: { id: taxon.permalink }
|
12
|
+
expect(response.status).to eq(200)
|
13
|
+
end
|
14
|
+
end
|
Binary file
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'generator_spec'
|
5
|
+
require 'generators/solidus_starter_frontend/views/override_generator'
|
6
|
+
|
7
|
+
RSpec.describe SolidusStarterFrontend::Views::OverrideGenerator, type: :generator do
|
8
|
+
destination Rails.root.join('app', 'views', 'spree')
|
9
|
+
|
10
|
+
before(:all) do
|
11
|
+
prepare_destination
|
12
|
+
end
|
13
|
+
|
14
|
+
subject! do
|
15
|
+
run_generator arguments
|
16
|
+
end
|
17
|
+
|
18
|
+
let(:src) do
|
19
|
+
::SolidusStarterFrontend::Engine.root.join('app', 'views', 'spree')
|
20
|
+
end
|
21
|
+
|
22
|
+
let(:dest) do
|
23
|
+
Rails.root.join('app', 'views', 'spree')
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'without any arguments' do
|
27
|
+
let(:arguments) { %w() }
|
28
|
+
|
29
|
+
it 'copies all views into the host app' do
|
30
|
+
expect(src.entries).to match_array(dest.entries)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'when "products" is passed as --only argument' do
|
35
|
+
let(:arguments) { %w(--only products) }
|
36
|
+
|
37
|
+
context 'as folder' do
|
38
|
+
it 'exclusively copies views whose name contains "products"' do
|
39
|
+
Dir.glob(dest.join("**", "*")).each do |file|
|
40
|
+
next if File.directory?(file)
|
41
|
+
expect(file.to_s).to match("products")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
after do
|
48
|
+
FileUtils.rm_rf destination_root
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
module Spree
|
6
|
+
describe BaseHelper, type: :helper do
|
7
|
+
# Regression test for https://github.com/spree/spree/issues/2759
|
8
|
+
it "nested_taxons_path works with a Taxon object" do
|
9
|
+
taxon = create(:taxon, name: "iphone")
|
10
|
+
expect(spree.nested_taxons_path(taxon)).to eq("/t/iphone")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
module Spree
|
6
|
+
describe Spree::OrdersHelper, type: :helper do
|
7
|
+
# Regression test for https://github.com/spree/spree/issues/2518 and https://github.com/spree/spree/issues/2323
|
8
|
+
it "truncates HTML correctly in product description" do
|
9
|
+
product = double(description: "<strong>" + ("a" * 95) + "</strong> This content is invisible.")
|
10
|
+
expected = "<strong>" + ("a" * 95) + "</strong>..."
|
11
|
+
expect(truncated_product_description(product)).to eq(expected)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe Spree::TaxonFiltersHelper, type: :helper do
|
6
|
+
let(:taxon) { nil }
|
7
|
+
subject { applicable_filters_for(taxon) }
|
8
|
+
|
9
|
+
it "returns the price/brand filters" do
|
10
|
+
expect(subject.map { |y| y[:name] }).to eq ['Brands', 'Price Range']
|
11
|
+
end
|
12
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Configure Rails Environment
|
4
|
+
ENV['RAILS_ENV'] = 'test'
|
5
|
+
|
6
|
+
# Run Coverage report
|
7
|
+
require 'solidus_dev_support/rspec/coverage'
|
8
|
+
|
9
|
+
require File.expand_path('dummy/config/environment.rb', __dir__)
|
10
|
+
|
11
|
+
require 'rails-controller-testing'
|
12
|
+
require 'rspec/active_model/mocks'
|
13
|
+
|
14
|
+
# Requires factories and other useful helpers defined in spree_core.
|
15
|
+
require 'solidus_dev_support/rspec/feature_helper'
|
16
|
+
require 'spree/testing_support/caching'
|
17
|
+
require 'spree/testing_support/order_walkthrough'
|
18
|
+
require 'spree/testing_support/translations' unless Spree.solidus_gem_version < Gem::Version.new('2.11')
|
19
|
+
|
20
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
21
|
+
# in spec/support/ and its subdirectories.
|
22
|
+
Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
|
23
|
+
|
24
|
+
# Requires factories defined in lib/solidus_starter_frontend/factories.rb
|
25
|
+
require 'solidus_starter_frontend/factories'
|
26
|
+
|
27
|
+
RSpec.configure do |config|
|
28
|
+
config.infer_spec_type_from_file_location!
|
29
|
+
config.use_transactional_fixtures = false
|
30
|
+
|
31
|
+
if Spree.solidus_gem_version < Gem::Version.new('2.11')
|
32
|
+
config.extend Spree::TestingSupport::AuthorizationHelpers::Request, type: :system
|
33
|
+
|
34
|
+
config.after(:each, type: :system) do |example|
|
35
|
+
missing_translations = page.body.scan(/translation missing: #{I18n.locale}\.(.*?)[\s<\"&]/)
|
36
|
+
if missing_translations.any?
|
37
|
+
puts "Found missing translations: #{missing_translations.inspect}\n"
|
38
|
+
puts "In spec: #{example.location}"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
if SolidusSupport.reset_spree_preferences_deprecated?
|
44
|
+
config.before :suite do
|
45
|
+
Spree::TestingSupport::Preferences.freeze_preferences(SolidusStarterFrontend::Config)
|
46
|
+
end
|
47
|
+
else
|
48
|
+
config.before do
|
49
|
+
SolidusStarterFrontend::Config.preference_store = SolidusStarterFrontend::Config.default_preferences
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
config.before do
|
54
|
+
Rails.cache.clear
|
55
|
+
end
|
56
|
+
|
57
|
+
config.before(:each, type: :system) do
|
58
|
+
driven_by((ENV['CAPYBARA_DRIVER'] || :rack_test).to_sym)
|
59
|
+
end
|
60
|
+
|
61
|
+
config.before(:each, type: :system, js: true) do
|
62
|
+
driven_by((ENV['CAPYBARA_JS_DRIVER'] || :apparition).to_sym)
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
shared_context 'checkout setup' do
|
4
|
+
let!(:store) { create(:store) }
|
5
|
+
let!(:country) { create(:country, states_required: true) }
|
6
|
+
let!(:state) { create(:state, country: country) }
|
7
|
+
let!(:shipping_method) { create(:shipping_method) }
|
8
|
+
let!(:stock_location) { create(:stock_location) }
|
9
|
+
let!(:mug) { create(:product, name: "RoR Mug") }
|
10
|
+
let!(:payment_method) { create(:check_payment_method) }
|
11
|
+
let!(:zone) { create(:zone) }
|
12
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
shared_context "custom products" do
|
4
|
+
before(:each) do
|
5
|
+
create(:store)
|
6
|
+
taxonomy = FactoryBot.create(:taxonomy, name: 'Categories')
|
7
|
+
root = taxonomy.root
|
8
|
+
clothing_taxon = FactoryBot.create(:taxon, name: 'Clothing', parent_id: root.id)
|
9
|
+
bags_taxon = FactoryBot.create(:taxon, name: 'Bags', parent_id: root.id)
|
10
|
+
mugs_taxon = FactoryBot.create(:taxon, name: 'Mugs', parent_id: root.id)
|
11
|
+
|
12
|
+
taxonomy = FactoryBot.create(:taxonomy, name: 'Brands')
|
13
|
+
root = taxonomy.root
|
14
|
+
apache_taxon = FactoryBot.create(:taxon, name: 'Apache', parent_id: root.id)
|
15
|
+
rails_taxon = FactoryBot.create(:taxon, name: 'Ruby on Rails', parent_id: root.id)
|
16
|
+
ruby_taxon = FactoryBot.create(:taxon, name: 'Ruby', parent_id: root.id)
|
17
|
+
|
18
|
+
FactoryBot.create(:custom_product, name: 'Ruby on Rails Ringer T-Shirt', price: '19.99', taxons: [rails_taxon, clothing_taxon])
|
19
|
+
FactoryBot.create(:custom_product, name: 'Ruby on Rails Mug', price: '15.99', taxons: [rails_taxon, mugs_taxon])
|
20
|
+
FactoryBot.create(:custom_product, name: 'Ruby on Rails Tote', price: '15.99', taxons: [rails_taxon, bags_taxon])
|
21
|
+
FactoryBot.create(:custom_product, name: 'Ruby on Rails Bag', price: '22.99', taxons: [rails_taxon, bags_taxon])
|
22
|
+
FactoryBot.create(:custom_product, name: 'Ruby on Rails Baseball Jersey', price: '19.99', taxons: [rails_taxon, clothing_taxon])
|
23
|
+
FactoryBot.create(:custom_product, name: 'Ruby on Rails Stein', price: '16.99', taxons: [rails_taxon, mugs_taxon])
|
24
|
+
FactoryBot.create(:custom_product, name: 'Ruby on Rails Jr. Spaghetti', price: '19.99', taxons: [rails_taxon, clothing_taxon])
|
25
|
+
FactoryBot.create(:custom_product, name: 'Ruby Baseball Jersey', price: '19.99', taxons: [ruby_taxon, clothing_taxon])
|
26
|
+
FactoryBot.create(:custom_product, name: 'Apache Baseball Jersey', price: '19.99', taxons: [apache_taxon, clothing_taxon])
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
shared_context 'fr locale' do
|
4
|
+
before do
|
5
|
+
I18n.backend.store_translations(:fr, spree: {
|
6
|
+
i18n: { this_file_language: "Français" },
|
7
|
+
cart: 'Panier',
|
8
|
+
shopping_cart: 'Panier'
|
9
|
+
})
|
10
|
+
end
|
11
|
+
|
12
|
+
after do
|
13
|
+
I18n.locale = :en # reset locale after each spec.
|
14
|
+
I18n.reload!
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe 'Address', type: :system, inaccessible: true do
|
6
|
+
let!(:product) { create(:product, name: "RoR Mug") }
|
7
|
+
let!(:order) { create(:order_with_totals, state: 'cart') }
|
8
|
+
|
9
|
+
stub_authorization!
|
10
|
+
|
11
|
+
before do
|
12
|
+
visit spree.root_path
|
13
|
+
|
14
|
+
click_link 'RoR Mug'
|
15
|
+
click_button 'add-to-cart-button'
|
16
|
+
|
17
|
+
address = 'order_bill_address_attributes'
|
18
|
+
@state_select_css = "##{address}_state_id"
|
19
|
+
@state_name_css = "##{address}_state_name"
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'country requires state', js: true do
|
23
|
+
let!(:canada) { create(:country, name: 'Canada', states_required: true, iso: 'CA') }
|
24
|
+
let!(:uk) { create(:country, name: 'United Kingdom', states_required: true, iso: 'GB') }
|
25
|
+
|
26
|
+
before { stub_spree_preferences(default_country_iso: uk.iso) }
|
27
|
+
|
28
|
+
context 'but has no state' do
|
29
|
+
it 'shows the state input field' do
|
30
|
+
click_button 'Checkout'
|
31
|
+
|
32
|
+
within('#billing') do
|
33
|
+
select canada.name, from: 'Country'
|
34
|
+
expect(page).to have_no_css(@state_select_css)
|
35
|
+
expect(page).to have_css("#{@state_name_css}.required")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'and has state' do
|
41
|
+
before { create(:state, name: 'Ontario', country: canada) }
|
42
|
+
|
43
|
+
it 'shows the state collection selection' do
|
44
|
+
click_button 'Checkout'
|
45
|
+
|
46
|
+
within('#billing') do
|
47
|
+
select canada.name, from: 'Country'
|
48
|
+
expect(page).to have_no_css(@state_name_css)
|
49
|
+
expect(page).to have_css("#{@state_select_css}.required")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'user changes to country without states required' do
|
55
|
+
let!(:france) { create(:country, name: 'France', states_required: false, iso: 'FR') }
|
56
|
+
|
57
|
+
it 'clears the state name' do
|
58
|
+
click_button 'Checkout'
|
59
|
+
within('#billing') do
|
60
|
+
select canada.name, from: 'Country'
|
61
|
+
|
62
|
+
page.find(@state_name_css).set('Toscana')
|
63
|
+
|
64
|
+
select france.name, from: 'Country'
|
65
|
+
|
66
|
+
expect(page).to have_no_css(@state_name_css)
|
67
|
+
expect(page).to have_no_css(@state_select_css)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context 'country does not require state', js: true do
|
74
|
+
let!(:france) { create(:country, name: 'France', states_required: false, iso: 'FR') }
|
75
|
+
|
76
|
+
it 'shows a disabled state input field' do
|
77
|
+
click_button 'Checkout'
|
78
|
+
|
79
|
+
within('#billing') do
|
80
|
+
select france.name, from: 'Country'
|
81
|
+
|
82
|
+
expect(page).to have_no_css(@state_name_css)
|
83
|
+
expect(page).to have_css("#{@state_select_css}[disabled]", visible: false)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe 'Automatic promotions', type: :system, js: true do
|
6
|
+
let!(:store) { create(:store) }
|
7
|
+
let!(:country) { create(:country, name: "United States of America", states_required: true) }
|
8
|
+
let!(:state) { create(:state, name: "Alabama", country: country) }
|
9
|
+
let!(:zone) { create(:zone) }
|
10
|
+
let!(:shipping_method) { create(:shipping_method) }
|
11
|
+
let!(:payment_method) { create(:check_payment_method) }
|
12
|
+
let!(:product) { create(:product, name: "RoR Mug", price: 20) }
|
13
|
+
|
14
|
+
let!(:promotion) do
|
15
|
+
promotion = Spree::Promotion.create!(name: "$10 off when you spend more than $100", apply_automatically: true)
|
16
|
+
|
17
|
+
calculator = Spree::Calculator::FlatRate.new
|
18
|
+
calculator.preferred_amount = 10
|
19
|
+
|
20
|
+
rule = Spree::Promotion::Rules::ItemTotal.create
|
21
|
+
rule.preferred_amount = 100
|
22
|
+
rule.save
|
23
|
+
|
24
|
+
promotion.rules << rule
|
25
|
+
|
26
|
+
action = Spree::Promotion::Actions::CreateAdjustment.create
|
27
|
+
action.calculator = calculator
|
28
|
+
action.save
|
29
|
+
|
30
|
+
promotion.actions << action
|
31
|
+
end
|
32
|
+
|
33
|
+
context "on the cart page" do
|
34
|
+
before do
|
35
|
+
visit spree.root_path
|
36
|
+
click_link product.name
|
37
|
+
click_button "add-to-cart-button"
|
38
|
+
end
|
39
|
+
|
40
|
+
it "automatically applies the promotion once the order crosses the threshold" do
|
41
|
+
fill_in "order_line_items_attributes_0_quantity", with: 10
|
42
|
+
click_button "Update"
|
43
|
+
expect(page).to have_content("Promotion ($10 off when you spend more than $100) -$10.00", normalize_ws: true)
|
44
|
+
fill_in "order_line_items_attributes_0_quantity", with: 1
|
45
|
+
click_button "Update"
|
46
|
+
expect(page).not_to have_content("Promotion ($10 off when you spend more than $100) -$10.00", normalize_ws: true)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe 'products', type: :system, caching: true do
|
6
|
+
let!(:product) { create(:product) }
|
7
|
+
let!(:product2) { create(:product) }
|
8
|
+
let!(:taxonomy) { create(:taxonomy) }
|
9
|
+
let!(:taxon) { create(:taxon, taxonomy: taxonomy) }
|
10
|
+
|
11
|
+
before do
|
12
|
+
product2.update_column(:updated_at, 1.day.ago)
|
13
|
+
# warm up the cache
|
14
|
+
visit spree.root_path
|
15
|
+
|
16
|
+
clear_cache_events
|
17
|
+
end
|
18
|
+
|
19
|
+
it "reads from cache upon a second viewing" do
|
20
|
+
visit spree.root_path
|
21
|
+
expect(cache_writes.count).to eq(0)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "busts the cache when a product is updated" do
|
25
|
+
product.update_column(:updated_at, 1.day.from_now)
|
26
|
+
visit spree.root_path
|
27
|
+
expect(cache_writes.count).to eq(2)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "busts the cache when all products are soft-deleted" do
|
31
|
+
product.discard
|
32
|
+
product2.discard
|
33
|
+
visit spree.root_path
|
34
|
+
expect(cache_writes.count).to eq(1)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "busts the cache when the newest product is soft-deleted" do
|
38
|
+
product.discard
|
39
|
+
visit spree.root_path
|
40
|
+
expect(cache_writes.count).to eq(1)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "busts the cache when an older product is soft-deleted" do
|
44
|
+
product2.discard
|
45
|
+
visit spree.root_path
|
46
|
+
expect(cache_writes.count).to eq(1)
|
47
|
+
end
|
48
|
+
end
|