solidus_starter_frontend 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- metadata +30 -514
- data/.circleci/config.yml +0 -57
- data/.erb-lint.yml +0 -22
- data/.eslintrc +0 -5
- data/.gem_release.yml +0 -5
- data/.github/pull_request_template.md +0 -28
- data/.github/stale.yml +0 -17
- data/.gitignore +0 -17
- data/.hound.yml +0 -16
- data/.rspec +0 -2
- data/.rubocop.yml +0 -19
- data/.rubocop_todo.yml +0 -229
- data/.scss-lint.yml +0 -4
- data/Gemfile +0 -34
- data/LICENSE +0 -26
- data/README.md +0 -69
- data/Rakefile +0 -6
- data/app/assets/config/solidus_starter_frontend_manifest.js +0 -2
- data/app/assets/javascripts/spree/frontend/cart.js +0 -26
- data/app/assets/javascripts/spree/frontend/checkout/address.js +0 -124
- data/app/assets/javascripts/spree/frontend/checkout/payment.js +0 -44
- data/app/assets/javascripts/spree/frontend/checkout.js +0 -34
- data/app/assets/javascripts/spree/frontend/locale_selector.js +0 -9
- data/app/assets/javascripts/spree/frontend/product.js +0 -21
- data/app/assets/javascripts/spree/frontend/solidus_starter_frontend.js +0 -9
- data/app/assets/javascripts/spree/frontend/utils.js.erb +0 -18
- data/app/assets/javascripts/spree/frontend.js +0 -6
- data/app/assets/stylesheets/spree/frontend/base/_base.scss +0 -29
- data/app/assets/stylesheets/spree/frontend/base/_reset.scss +0 -179
- data/app/assets/stylesheets/spree/frontend/base/_responsive.scss +0 -21
- data/app/assets/stylesheets/spree/frontend/components/account/_account_order.scss +0 -23
- data/app/assets/stylesheets/spree/frontend/components/account/_account_summary.scss +0 -17
- data/app/assets/stylesheets/spree/frontend/components/auth/_auth_container.scss +0 -11
- data/app/assets/stylesheets/spree/frontend/components/auth/_auth_form.scss +0 -5
- data/app/assets/stylesheets/spree/frontend/components/brand/_logo.scss +0 -4
- data/app/assets/stylesheets/spree/frontend/components/buttons/_button_inline.scss +0 -8
- data/app/assets/stylesheets/spree/frontend/components/buttons/_button_primary.scss +0 -26
- data/app/assets/stylesheets/spree/frontend/components/cart/_cart_adjustments.scss +0 -6
- data/app/assets/stylesheets/spree/frontend/components/cart/_cart_amount_row.scss +0 -11
- data/app/assets/stylesheets/spree/frontend/components/cart/_cart_empty.scss +0 -10
- data/app/assets/stylesheets/spree/frontend/components/cart/_cart_footer.scss +0 -20
- data/app/assets/stylesheets/spree/frontend/components/cart/_cart_header.scss +0 -12
- data/app/assets/stylesheets/spree/frontend/components/cart/_cart_item.scss +0 -86
- data/app/assets/stylesheets/spree/frontend/components/cart/_cart_link.scss +0 -22
- data/app/assets/stylesheets/spree/frontend/components/cart/_cart_page.scss +0 -15
- data/app/assets/stylesheets/spree/frontend/components/cart/_cart_secondary_actions.scss +0 -19
- data/app/assets/stylesheets/spree/frontend/components/cart/_coupon_code.scss +0 -8
- data/app/assets/stylesheets/spree/frontend/components/cart/_item_info.scss +0 -19
- data/app/assets/stylesheets/spree/frontend/components/checkout/_checkout.scss +0 -27
- data/app/assets/stylesheets/spree/frontend/components/checkout/_checkout_header.scss +0 -19
- data/app/assets/stylesheets/spree/frontend/components/checkout/_checkout_summary.scss +0 -31
- data/app/assets/stylesheets/spree/frontend/components/checkout/_existing_cards.scss +0 -27
- data/app/assets/stylesheets/spree/frontend/components/checkout/_payment_method_controls.scss +0 -5
- data/app/assets/stylesheets/spree/frontend/components/checkout/_payment_method_selector.scss +0 -14
- data/app/assets/stylesheets/spree/frontend/components/checkout/_progress_steps.scss +0 -38
- data/app/assets/stylesheets/spree/frontend/components/checkout/_proposed_shipment.scss +0 -18
- data/app/assets/stylesheets/spree/frontend/components/checkout/_shipment_items.scss +0 -50
- data/app/assets/stylesheets/spree/frontend/components/checkout/_shipping_methods.scss +0 -9
- data/app/assets/stylesheets/spree/frontend/components/checkout/payments/_gateway_payment_method.scss +0 -11
- data/app/assets/stylesheets/spree/frontend/components/checkout/steps/_address_step.scss +0 -20
- data/app/assets/stylesheets/spree/frontend/components/checkout/steps/_confirm_step.scss +0 -13
- data/app/assets/stylesheets/spree/frontend/components/checkout/steps/_delivery_step.scss +0 -13
- data/app/assets/stylesheets/spree/frontend/components/checkout/steps/_payment_step.scss +0 -13
- data/app/assets/stylesheets/spree/frontend/components/forms/_address_inputs.scss +0 -13
- data/app/assets/stylesheets/spree/frontend/components/forms/inputs/_checkbox_input.scss +0 -3
- data/app/assets/stylesheets/spree/frontend/components/forms/inputs/_radio_input.scss +0 -3
- data/app/assets/stylesheets/spree/frontend/components/forms/inputs/_select_input.scss +0 -27
- data/app/assets/stylesheets/spree/frontend/components/forms/inputs/_text.scss +0 -32
- data/app/assets/stylesheets/spree/frontend/components/forms/inputs/_textarea_input.scss +0 -25
- data/app/assets/stylesheets/spree/frontend/components/general/_flash.scss +0 -20
- data/app/assets/stylesheets/spree/frontend/components/layout/_aside.scss +0 -4
- data/app/assets/stylesheets/spree/frontend/components/layout/_breadcrumbs.scss +0 -16
- data/app/assets/stylesheets/spree/frontend/components/layout/_category_navigation.scss +0 -3
- data/app/assets/stylesheets/spree/frontend/components/layout/_footer.scss +0 -8
- data/app/assets/stylesheets/spree/frontend/components/layout/_header.scss +0 -12
- data/app/assets/stylesheets/spree/frontend/components/layout/_horizontal_input_group.scss +0 -7
- data/app/assets/stylesheets/spree/frontend/components/layout/_top_bar.scss +0 -44
- data/app/assets/stylesheets/spree/frontend/components/navigation/_auth_link.scss +0 -11
- data/app/assets/stylesheets/spree/frontend/components/navigation/_categories.scss +0 -29
- data/app/assets/stylesheets/spree/frontend/components/navigation/_locale_selector.scss +0 -21
- data/app/assets/stylesheets/spree/frontend/components/navigation/_taxonomies.scss +0 -7
- data/app/assets/stylesheets/spree/frontend/components/navigation/_taxonomy.scss +0 -28
- data/app/assets/stylesheets/spree/frontend/components/orders/_address_overview.scss +0 -27
- data/app/assets/stylesheets/spree/frontend/components/orders/_coupon_codes.scss +0 -4
- data/app/assets/stylesheets/spree/frontend/components/orders/_line_items.scss +0 -20
- data/app/assets/stylesheets/spree/frontend/components/orders/_order_details.scss +0 -18
- data/app/assets/stylesheets/spree/frontend/components/orders/_order_item.scss +0 -85
- data/app/assets/stylesheets/spree/frontend/components/orders/_order_page.scss +0 -41
- data/app/assets/stylesheets/spree/frontend/components/orders/_order_shipments.scss +0 -27
- data/app/assets/stylesheets/spree/frontend/components/orders/_payment_info.scss +0 -29
- data/app/assets/stylesheets/spree/frontend/components/presentation/_hero.scss +0 -18
- data/app/assets/stylesheets/spree/frontend/components/products/_product_card.scss +0 -35
- data/app/assets/stylesheets/spree/frontend/components/products/_product_image.scss +0 -7
- data/app/assets/stylesheets/spree/frontend/components/products/_product_info.scss +0 -14
- data/app/assets/stylesheets/spree/frontend/components/products/_product_page.scss +0 -31
- data/app/assets/stylesheets/spree/frontend/components/products/_product_properties.scss +0 -23
- data/app/assets/stylesheets/spree/frontend/components/products/_product_submit.scss +0 -9
- data/app/assets/stylesheets/spree/frontend/components/products/_product_taxons.scss +0 -27
- data/app/assets/stylesheets/spree/frontend/components/products/_product_thumbnails.scss +0 -7
- data/app/assets/stylesheets/spree/frontend/components/products/_product_variants.scss +0 -20
- data/app/assets/stylesheets/spree/frontend/components/products/_products.scss +0 -13
- data/app/assets/stylesheets/spree/frontend/components/products/_products_by_taxon.scss +0 -6
- data/app/assets/stylesheets/spree/frontend/components/products/_products_grid.scss +0 -18
- data/app/assets/stylesheets/spree/frontend/components/search/_filter.scss +0 -32
- data/app/assets/stylesheets/spree/frontend/components/search/_search_bar.scss +0 -34
- data/app/assets/stylesheets/spree/frontend/components/typography/_hero_title.scss +0 -6
- data/app/assets/stylesheets/spree/frontend/components/typography/_subtitle.scss +0 -7
- data/app/assets/stylesheets/spree/frontend/placeholders/main.scss +0 -5
- data/app/assets/stylesheets/spree/frontend/screen.scss +0 -89
- data/app/assets/stylesheets/spree/frontend/solidus_starter_frontend.css +0 -7
- data/app/assets/stylesheets/spree/frontend/variables/_colors.scss +0 -20
- data/app/assets/stylesheets/spree/frontend.css +0 -8
- data/app/controllers/concerns/solidus_starter_frontend/auth_views.rb +0 -16
- data/app/controllers/concerns/solidus_starter_frontend/taxonomies.rb +0 -16
- data/app/controllers/spree/checkout_controller.rb +0 -249
- data/app/controllers/spree/coupon_codes_controller.rb +0 -35
- data/app/controllers/spree/home_controller.rb +0 -13
- data/app/controllers/spree/locale_controller.rb +0 -20
- data/app/controllers/spree/orders_controller.rb +0 -126
- data/app/controllers/spree/products_controller.rb +0 -51
- data/app/controllers/spree/store_controller.rb +0 -31
- data/app/controllers/spree/taxons_controller.rb +0 -30
- data/app/helpers/spree/orders_helper.rb +0 -18
- data/app/helpers/spree/taxon_filters_helper.rb +0 -13
- data/app/views/spree/address/_form_hidden.html.erb +0 -12
- data/app/views/spree/checkout/_terms_and_conditions.en.html.erb +0 -1
- data/app/views/spree/checkout/edit.html.erb +0 -16
- data/app/views/spree/checkout/existing_payment/_gateway.html.erb +0 -9
- data/app/views/spree/checkout/payment/_check.html.erb +0 -0
- data/app/views/spree/checkout/payment/_gateway.html.erb +0 -43
- data/app/views/spree/components/auth/_change_form.html.erb +0 -40
- data/app/views/spree/components/auth/_forgot_form.html.erb +0 -28
- data/app/views/spree/components/auth/_guest_form.html.erb +0 -31
- data/app/views/spree/components/auth/_login_form.html.erb +0 -42
- data/app/views/spree/components/auth/_signup_form.html.erb +0 -48
- data/app/views/spree/components/brand/_logo.html.erb +0 -3
- data/app/views/spree/components/buttons/_button_inline.html.erb +0 -23
- data/app/views/spree/components/buttons/_button_primary.html.erb +0 -29
- data/app/views/spree/components/cart/_cart_adjustment.html.erb +0 -15
- data/app/views/spree/components/cart/_cart_adjustments.html.erb +0 -47
- data/app/views/spree/components/cart/_cart_amount_row.html.erb +0 -12
- data/app/views/spree/components/cart/_cart_empty.html.erb +0 -9
- data/app/views/spree/components/cart/_cart_footer.html.erb +0 -15
- data/app/views/spree/components/cart/_cart_header.html.erb +0 -17
- data/app/views/spree/components/cart/_cart_item.html.erb +0 -52
- data/app/views/spree/components/cart/_cart_items.html.erb +0 -23
- data/app/views/spree/components/cart/_cart_link.html.erb +0 -9
- data/app/views/spree/components/cart/_cart_secondary_actions.html.erb +0 -17
- data/app/views/spree/components/cart/_item_info.html.erb +0 -26
- data/app/views/spree/components/checkout/_checkout_header.html.erb +0 -8
- data/app/views/spree/components/checkout/_checkout_step.html.erb +0 -21
- data/app/views/spree/components/checkout/_checkout_summary.html.erb +0 -70
- data/app/views/spree/components/checkout/_existing_cards.html.erb +0 -39
- data/app/views/spree/components/checkout/_payment_method_controls.html.erb +0 -10
- data/app/views/spree/components/checkout/_payment_method_selector.html.erb +0 -14
- data/app/views/spree/components/checkout/_proposed_shipment.erb +0 -18
- data/app/views/spree/components/checkout/_shipment_items.html.erb +0 -22
- data/app/views/spree/components/checkout/_shipping_methods.html.erb +0 -20
- data/app/views/spree/components/checkout/_unshippable_items.html.erb +0 -7
- data/app/views/spree/components/checkout/steps/_address_step.html.erb +0 -60
- data/app/views/spree/components/checkout/steps/_confirm_step.html.erb +0 -31
- data/app/views/spree/components/checkout/steps/_delivery_step.html.erb +0 -31
- data/app/views/spree/components/checkout/steps/_payment_step.html.erb +0 -25
- data/app/views/spree/components/forms/_address_inputs.html.erb +0 -152
- data/app/views/spree/components/forms/inputs/_checkbox_input.html.erb +0 -29
- data/app/views/spree/components/forms/inputs/_collection_select.html.erb +0 -42
- data/app/views/spree/components/forms/inputs/_radio_input.html.erb +0 -29
- data/app/views/spree/components/forms/inputs/_select_input.html.erb +0 -31
- data/app/views/spree/components/forms/inputs/_text.html.erb +0 -54
- data/app/views/spree/components/forms/inputs/_textarea_input.html.erb +0 -42
- data/app/views/spree/components/layout/_category_navigation.html.erb +0 -3
- data/app/views/spree/components/layout/_footer.html.erb +0 -7
- data/app/views/spree/components/layout/_header.html.erb +0 -8
- data/app/views/spree/components/layout/_top_bar.html.erb +0 -8
- data/app/views/spree/components/navigation/_auth_link.html.erb +0 -1
- data/app/views/spree/components/navigation/_breadcrumbs.html.erb +0 -47
- data/app/views/spree/components/navigation/_categories.html.erb +0 -12
- data/app/views/spree/components/navigation/_locale_selector.html.erb +0 -25
- data/app/views/spree/components/navigation/_taxonomies.html.erb +0 -17
- data/app/views/spree/components/navigation/_taxons.html.erb +0 -17
- data/app/views/spree/components/navigation/_taxons_tree.html.erb +0 -29
- data/app/views/spree/components/orders/_address_overview.html.erb +0 -40
- data/app/views/spree/components/orders/_coupon_code.html.erb +0 -22
- data/app/views/spree/components/orders/_line_items.html.erb +0 -55
- data/app/views/spree/components/orders/_order_details.html.erb +0 -35
- data/app/views/spree/components/orders/_order_item.html.erb +0 -33
- data/app/views/spree/components/orders/_order_items.html.erb +0 -5
- data/app/views/spree/components/orders/_order_shipments.html.erb +0 -25
- data/app/views/spree/components/orders/_payment_info.html.erb +0 -31
- data/app/views/spree/components/presentation/_hero.html.erb +0 -14
- data/app/views/spree/components/products/_product-card.html.erb +0 -36
- data/app/views/spree/components/products/_product_availability.html.erb +0 -19
- data/app/views/spree/components/products/_product_form.html.erb +0 -21
- data/app/views/spree/components/products/_product_image.html.erb +0 -6
- data/app/views/spree/components/products/_product_info.html.erb +0 -9
- data/app/views/spree/components/products/_product_promotions.html.erb +0 -25
- data/app/views/spree/components/products/_product_properties.html.erb +0 -19
- data/app/views/spree/components/products/_product_submit.html.erb +0 -39
- data/app/views/spree/components/products/_product_taxons.html.erb +0 -15
- data/app/views/spree/components/products/_product_thumbnails.html.erb +0 -19
- data/app/views/spree/components/products/_product_variants.html.erb +0 -36
- data/app/views/spree/components/products/_products-grid.html.erb +0 -13
- data/app/views/spree/components/products/_products.html.erb +0 -28
- data/app/views/spree/components/products/_products_by_taxon.html.erb +0 -7
- data/app/views/spree/components/products/_variants_list.html.erb +0 -12
- data/app/views/spree/components/search/_filter.html.erb +0 -42
- data/app/views/spree/components/search/_filters.html.erb +0 -20
- data/app/views/spree/components/search/_form.html.erb +0 -12
- data/app/views/spree/components/search/_products_search.html.erb +0 -36
- data/app/views/spree/components/search/_search_bar.html.erb +0 -36
- data/app/views/spree/components/typography/_hero_title.html.erb +0 -11
- data/app/views/spree/components/typography/_subtitle.html.erb +0 -11
- data/app/views/spree/home/index.html.erb +0 -7
- data/app/views/spree/layouts/spree_application.html.erb +0 -27
- data/app/views/spree/orders/edit.html.erb +0 -21
- data/app/views/spree/orders/show.html.erb +0 -29
- data/app/views/spree/products/index.html.erb +0 -22
- data/app/views/spree/products/show.html.erb +0 -18
- data/app/views/spree/shared/_image.html.erb +0 -12
- data/app/views/spree/shared/_link_to_cart.html.erb +0 -1
- data/app/views/spree/shared/_login_bar_items.html.erb +0 -1
- data/app/views/spree/shared/_shipment_tracking.html.erb +0 -11
- data/app/views/spree/shared/unauthorized.html.erb +0 -0
- data/app/views/spree/taxons/show.html.erb +0 -17
- data/bin/console +0 -17
- data/bin/r +0 -13
- data/bin/rails +0 -7
- data/bin/rake +0 -7
- data/bin/rspec +0 -29
- data/bin/sandbox +0 -84
- data/bin/sandbox_rails +0 -18
- data/bin/setup +0 -8
- data/bin/solidus_compare +0 -155
- data/config/initializers/assets.rb +0 -1
- data/config/initializers/canonical_rails.rb +0 -16
- data/config/locales/en.yml +0 -5
- data/config/routes.rb +0 -33
- data/config/solidus_compare.yml +0 -33
- data/docs/development.md +0 -28
- data/exe/solidus_starter_frontend +0 -9
- data/lib/generators/solidus_starter_frontend/install/install_generator.rb +0 -15
- data/lib/generators/solidus_starter_frontend/solidus_starter_frontend_generator.rb +0 -30
- data/lib/generators/solidus_starter_frontend/views/override_generator.rb +0 -50
- data/lib/solidus_starter_frontend/config.rb +0 -7
- data/lib/solidus_starter_frontend/engine.rb +0 -34
- data/lib/solidus_starter_frontend/factories.rb +0 -4
- data/lib/solidus_starter_frontend/solidus_support_extensions.rb +0 -9
- data/lib/solidus_starter_frontend/version.rb +0 -5
- data/lib/solidus_starter_frontend.rb +0 -12
- data/lib/solidus_starter_frontend_configuration.rb +0 -8
- data/lib/views/auth/spree/checkout/registration.html.erb +0 -7
- data/lib/views/auth/spree/components/navigation/_auth_link.html.erb +0 -5
- data/lib/views/auth/spree/user_passwords/edit.html.erb +0 -7
- data/lib/views/auth/spree/user_passwords/new.html.erb +0 -5
- data/lib/views/auth/spree/user_registrations/new.html.erb +0 -7
- data/lib/views/auth/spree/user_sessions/guest.html.erb +0 -5
- data/lib/views/auth/spree/user_sessions/new.html.erb +0 -7
- data/lib/views/auth/spree/users/edit.html.erb +0 -45
- data/lib/views/auth/spree/users/show.html.erb +0 -55
- data/solidus_starter_frontend.gemspec +0 -43
- data/spec/controllers/controller_helpers_spec.rb +0 -29
- data/spec/controllers/locale_controller_spec.rb +0 -57
- data/spec/controllers/spree/checkout_controller_spec.rb +0 -563
- data/spec/controllers/spree/checkout_controller_with_views_spec.rb +0 -37
- data/spec/controllers/spree/current_order_tracking_spec.rb +0 -33
- data/spec/controllers/spree/home_controller_spec.rb +0 -29
- data/spec/controllers/spree/orders_controller_ability_spec.rb +0 -90
- data/spec/controllers/spree/orders_controller_spec.rb +0 -241
- data/spec/controllers/spree/orders_controller_transitions_spec.rb +0 -33
- data/spec/controllers/spree/products_controller_spec.rb +0 -38
- data/spec/controllers/spree/taxons_controller_spec.rb +0 -14
- data/spec/fixtures/thinking-cat.jpg +0 -0
- data/spec/generators/solidus/views/override_generator_spec.rb +0 -50
- data/spec/helpers/base_helper_spec.rb +0 -13
- data/spec/helpers/order_helper_spec.rb +0 -14
- data/spec/helpers/taxon_filters_helper_spec.rb +0 -12
- data/spec/spec_helper.rb +0 -64
- data/spec/support/shared_contexts/checkout_setup.rb +0 -12
- data/spec/support/shared_contexts/custom_products.rb +0 -28
- data/spec/support/shared_contexts/locales.rb +0 -16
- data/spec/system/address_spec.rb +0 -87
- data/spec/system/automatic_promotion_adjustments_spec.rb +0 -49
- data/spec/system/caching/products_spec.rb +0 -48
- data/spec/system/caching/taxons_spec.rb +0 -35
- data/spec/system/cart_spec.rb +0 -81
- data/spec/system/checkout_confirm_insufficient_stock_spec.rb +0 -71
- data/spec/system/checkout_spec.rb +0 -699
- data/spec/system/checkout_unshippable_spec.rb +0 -37
- data/spec/system/coupon_code_spec.rb +0 -267
- data/spec/system/currency_spec.rb +0 -20
- data/spec/system/first_order_promotion_spec.rb +0 -59
- data/spec/system/free_shipping_promotions_spec.rb +0 -60
- data/spec/system/locale_spec.rb +0 -26
- data/spec/system/order_spec.rb +0 -57
- data/spec/system/products_spec.rb +0 -302
- data/spec/system/promotion_code_invalidation_spec.rb +0 -54
- data/spec/system/quantity_promotions_spec.rb +0 -130
- data/spec/system/taxons_spec.rb +0 -158
- data/spec/system/template_rendering_spec.rb +0 -20
- data/spec/views/spree/checkout/_summary_spec.rb +0 -11
@@ -1,563 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Spree::CheckoutController, type: :controller do
|
6
|
-
let(:token) { 'some_token' }
|
7
|
-
let(:user) { create(:user) }
|
8
|
-
let(:order) { FactoryBot.create(:order_with_totals) }
|
9
|
-
|
10
|
-
let(:address_params) do
|
11
|
-
address = FactoryBot.build(:address)
|
12
|
-
address.attributes.except("created_at", "updated_at")
|
13
|
-
end
|
14
|
-
|
15
|
-
before do
|
16
|
-
allow(controller).to receive_messages try_spree_current_user: user
|
17
|
-
allow(controller).to receive_messages current_order: order
|
18
|
-
end
|
19
|
-
|
20
|
-
context "#edit" do
|
21
|
-
it 'should check if the user is authorized for :edit' do
|
22
|
-
expect(controller).to receive(:authorize!).with(:edit, order, token)
|
23
|
-
request.cookie_jar.signed[:guest_token] = token
|
24
|
-
get :edit, params: { state: 'address' }
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should redirect to the cart path unless checkout_allowed?" do
|
28
|
-
allow(order).to receive_messages checkout_allowed?: false
|
29
|
-
get :edit, params: { state: "delivery" }
|
30
|
-
expect(response).to redirect_to(spree.cart_path)
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should redirect to the cart path if current_order is nil" do
|
34
|
-
allow(controller).to receive(:current_order).and_return(nil)
|
35
|
-
get :edit, params: { state: "delivery" }
|
36
|
-
expect(response).to redirect_to(spree.cart_path)
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should redirect to cart if order is completed" do
|
40
|
-
allow(order).to receive_messages(completed?: true)
|
41
|
-
get :edit, params: { state: "address" }
|
42
|
-
expect(response).to redirect_to(spree.cart_path)
|
43
|
-
end
|
44
|
-
|
45
|
-
# Regression test for https://github.com/spree/spree/issues/2280
|
46
|
-
it "should redirect to current step trying to access a future step" do
|
47
|
-
order.update_column(:state, "address")
|
48
|
-
get :edit, params: { state: "delivery" }
|
49
|
-
expect(response).to redirect_to spree.checkout_state_path("address")
|
50
|
-
end
|
51
|
-
|
52
|
-
context "when entering the checkout" do
|
53
|
-
before do
|
54
|
-
# The first step for checkout controller is address
|
55
|
-
# Transitioning into this state first is required
|
56
|
-
order.update_column(:state, "address")
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should associate the order with a user" do
|
60
|
-
order.update_column :user_id, nil
|
61
|
-
expect(order).to receive(:associate_user!).with(user)
|
62
|
-
get :edit
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
context "#update" do
|
68
|
-
it 'should check if the user is authorized for :edit' do
|
69
|
-
expect(controller).to receive(:authorize!).with(:edit, order, token)
|
70
|
-
request.cookie_jar.signed[:guest_token] = token
|
71
|
-
post :update, params: { state: 'address', order: { bill_address_attributes: address_params } }
|
72
|
-
end
|
73
|
-
|
74
|
-
context "save successful" do
|
75
|
-
def post_address
|
76
|
-
post :update, params: {
|
77
|
-
state: "address",
|
78
|
-
order: {
|
79
|
-
bill_address_attributes: address_params,
|
80
|
-
use_billing: true
|
81
|
-
}
|
82
|
-
}
|
83
|
-
end
|
84
|
-
|
85
|
-
let!(:payment_method) { create(:payment_method) }
|
86
|
-
before do
|
87
|
-
# Must have *a* shipping method and a payment method so updating from address works
|
88
|
-
allow(order).to receive_messages ensure_available_shipping_rates: true
|
89
|
-
order.line_items << FactoryBot.create(:line_item)
|
90
|
-
end
|
91
|
-
|
92
|
-
context "with the order in the cart state", partial_double_verification: false do
|
93
|
-
before do
|
94
|
-
order.update! user: user
|
95
|
-
order.update_column(:state, "cart")
|
96
|
-
end
|
97
|
-
|
98
|
-
it "should assign order" do
|
99
|
-
post :update, params: { state: "address", order: { bill_address_attributes: address_params } }
|
100
|
-
expect(assigns[:order]).not_to be_nil
|
101
|
-
end
|
102
|
-
|
103
|
-
it "should advance the state" do
|
104
|
-
post_address
|
105
|
-
expect(order.reload.state).to eq("delivery")
|
106
|
-
end
|
107
|
-
|
108
|
-
it "should redirect the next state" do
|
109
|
-
post_address
|
110
|
-
expect(response).to redirect_to spree.checkout_state_path("delivery")
|
111
|
-
end
|
112
|
-
|
113
|
-
context "current_user respond to save address method" do
|
114
|
-
it "calls persist order address on user" do
|
115
|
-
expect(user).to receive(:persist_order_address)
|
116
|
-
post :update, params: {
|
117
|
-
state: "address",
|
118
|
-
order: {
|
119
|
-
bill_address_attributes: address_params,
|
120
|
-
use_billing: true
|
121
|
-
},
|
122
|
-
save_user_address: "1"
|
123
|
-
}
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
context "current_user doesnt respond to persist_order_address" do
|
128
|
-
it "doesnt raise any error" do
|
129
|
-
post :update, params: {
|
130
|
-
state: "address",
|
131
|
-
order: {
|
132
|
-
bill_address_attributes: address_params,
|
133
|
-
use_billing: true
|
134
|
-
},
|
135
|
-
save_user_address: "1"
|
136
|
-
}
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
context "with the order in the address state", partial_double_verification: false do
|
142
|
-
before do
|
143
|
-
order.update! user: user
|
144
|
-
order.update_columns(ship_address_id: create(:address).id, state: "address")
|
145
|
-
end
|
146
|
-
|
147
|
-
context 'landing to address page' do
|
148
|
-
it "tries to associate user addresses to order" do
|
149
|
-
expect(order).to receive(:assign_default_user_addresses)
|
150
|
-
get :edit
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
context "with a billing and shipping address", partial_double_verification: false do
|
155
|
-
subject do
|
156
|
-
post :update, params: {
|
157
|
-
state: "address",
|
158
|
-
order: {
|
159
|
-
bill_address_attributes: order.bill_address.attributes.except("created_at", "updated_at").compact,
|
160
|
-
ship_address_attributes: order.ship_address.attributes.except("created_at", "updated_at").compact,
|
161
|
-
use_billing: false
|
162
|
-
}
|
163
|
-
}
|
164
|
-
end
|
165
|
-
|
166
|
-
it "doesn't change bill address" do
|
167
|
-
expect {
|
168
|
-
subject
|
169
|
-
}.not_to change { order.reload.ship_address.id }
|
170
|
-
end
|
171
|
-
|
172
|
-
it "doesn't change ship address" do
|
173
|
-
expect {
|
174
|
-
subject
|
175
|
-
}.not_to change { order.reload.bill_address.id }
|
176
|
-
end
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
# This is the only time that we need the 'set_payment_parameters_amount'
|
181
|
-
# controller code, because otherwise the transition to 'confirm' will
|
182
|
-
# trigger the 'add_store_credit_payments' transition code which will do
|
183
|
-
# the same thing here.
|
184
|
-
# Perhaps we can just remove 'set_payment_parameters_amount' entirely at
|
185
|
-
# some point?
|
186
|
-
context "when there is a checkout step between payment and confirm", partial_double_verification: false do
|
187
|
-
before do
|
188
|
-
@old_checkout_flow = Spree::Order.checkout_flow
|
189
|
-
Spree::Order.class_eval do
|
190
|
-
insert_checkout_step :new_step, after: :payment
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
after do
|
195
|
-
Spree::Order.checkout_flow(&@old_checkout_flow)
|
196
|
-
end
|
197
|
-
|
198
|
-
let(:order) { create(:order_with_line_items) }
|
199
|
-
let(:payment_method) { create(:credit_card_payment_method) }
|
200
|
-
|
201
|
-
let(:params) do
|
202
|
-
{
|
203
|
-
state: 'payment',
|
204
|
-
order: {
|
205
|
-
payments_attributes: [
|
206
|
-
{
|
207
|
-
payment_method_id: payment_method.id.to_s,
|
208
|
-
source_attributes: attributes_for(:credit_card)
|
209
|
-
}
|
210
|
-
]
|
211
|
-
}
|
212
|
-
}
|
213
|
-
end
|
214
|
-
|
215
|
-
before do
|
216
|
-
order.update! user: user
|
217
|
-
3.times { order.next! } # should put us in the payment state
|
218
|
-
end
|
219
|
-
|
220
|
-
it 'sets the payment amount' do
|
221
|
-
post :update, params: params
|
222
|
-
order.reload
|
223
|
-
expect(order.state).to eq('new_step')
|
224
|
-
expect(order.payments.size).to eq(1)
|
225
|
-
expect(order.payments.first.amount).to eq(order.total)
|
226
|
-
end
|
227
|
-
end
|
228
|
-
|
229
|
-
context "when in the payment state", partial_double_verification: false do
|
230
|
-
let(:order) { create(:order_with_line_items) }
|
231
|
-
let(:payment_method) { create(:credit_card_payment_method) }
|
232
|
-
|
233
|
-
let(:params) do
|
234
|
-
{
|
235
|
-
state: 'payment',
|
236
|
-
order: {
|
237
|
-
payments_attributes: [
|
238
|
-
{
|
239
|
-
payment_method_id: payment_method.id.to_s,
|
240
|
-
source_attributes: attributes_for(:credit_card)
|
241
|
-
}
|
242
|
-
]
|
243
|
-
}
|
244
|
-
}
|
245
|
-
end
|
246
|
-
|
247
|
-
before do
|
248
|
-
order.update! user: user
|
249
|
-
3.times { order.next! } # should put us in the payment state
|
250
|
-
end
|
251
|
-
|
252
|
-
context 'with a permitted payment method' do
|
253
|
-
it 'sets the payment amount' do
|
254
|
-
post :update, params: params
|
255
|
-
order.reload
|
256
|
-
expect(order.state).to eq('confirm')
|
257
|
-
expect(order.payments.size).to eq(1)
|
258
|
-
expect(order.payments.first.amount).to eq(order.total)
|
259
|
-
end
|
260
|
-
end
|
261
|
-
|
262
|
-
context 'with an unpermitted payment method' do
|
263
|
-
before { payment_method.update!(available_to_users: false) }
|
264
|
-
|
265
|
-
it 'sets the payment amount' do
|
266
|
-
expect {
|
267
|
-
post :update, params: params
|
268
|
-
}.to raise_error(ActiveRecord::RecordNotFound)
|
269
|
-
|
270
|
-
expect(order.state).to eq('payment')
|
271
|
-
expect(order.payments).to be_empty
|
272
|
-
end
|
273
|
-
end
|
274
|
-
|
275
|
-
context 'trying to change the address' do
|
276
|
-
let(:params) do
|
277
|
-
{
|
278
|
-
state: 'payment',
|
279
|
-
order: {
|
280
|
-
payments_attributes: [
|
281
|
-
{
|
282
|
-
payment_method_id: payment_method.id.to_s,
|
283
|
-
source_attributes: attributes_for(:credit_card)
|
284
|
-
}
|
285
|
-
],
|
286
|
-
ship_address_attributes: {
|
287
|
-
zipcode: 'TEST'
|
288
|
-
}
|
289
|
-
}
|
290
|
-
}
|
291
|
-
end
|
292
|
-
|
293
|
-
it 'does not change the address' do
|
294
|
-
expect do
|
295
|
-
post :update, params: params
|
296
|
-
end.not_to change { order.reload.ship_address.zipcode }
|
297
|
-
end
|
298
|
-
end
|
299
|
-
end
|
300
|
-
|
301
|
-
context "when in the confirm state" do
|
302
|
-
before do
|
303
|
-
order.update! user: user
|
304
|
-
order.update_column(:state, "confirm")
|
305
|
-
# An order requires a payment to reach the complete state
|
306
|
-
# This is because payment_required? is true on the order
|
307
|
-
create(:payment, amount: order.total, order: order)
|
308
|
-
order.create_proposed_shipments
|
309
|
-
order.payments.reload
|
310
|
-
end
|
311
|
-
|
312
|
-
# This inadvertently is a regression test for https://github.com/spree/spree/issues/2694
|
313
|
-
it "should redirect to the order view" do
|
314
|
-
post :update, params: { state: "confirm" }
|
315
|
-
expect(response).to redirect_to spree.order_path(order)
|
316
|
-
end
|
317
|
-
|
318
|
-
it "should populate the flash message" do
|
319
|
-
post :update, params: { state: "confirm" }
|
320
|
-
expect(flash.notice).to eq(I18n.t('spree.order_processed_successfully'))
|
321
|
-
end
|
322
|
-
|
323
|
-
it "should remove completed order from current_order" do
|
324
|
-
post :update, params: { state: "confirm" }
|
325
|
-
expect(assigns(:current_order)).to be_nil
|
326
|
-
expect(assigns(:order)).to eql controller.current_order
|
327
|
-
end
|
328
|
-
end
|
329
|
-
end
|
330
|
-
|
331
|
-
context "save unsuccessful" do
|
332
|
-
before do
|
333
|
-
order.update! user: user
|
334
|
-
allow(order).to receive_messages valid?: false
|
335
|
-
end
|
336
|
-
|
337
|
-
it "should not assign order" do
|
338
|
-
post :update, params: { state: "address", order: { email: '' } }
|
339
|
-
expect(assigns[:order]).not_to be_nil
|
340
|
-
end
|
341
|
-
|
342
|
-
it "should not change the order state" do
|
343
|
-
expect do
|
344
|
-
post :update, params: { state: 'address', order: { bill_address_attributes: address_params } }
|
345
|
-
end.not_to change { order.reload.state }
|
346
|
-
end
|
347
|
-
|
348
|
-
it "should render the edit template" do
|
349
|
-
post :update, params: { state: 'address', order: { bill_address_attributes: address_params } }
|
350
|
-
expect(response).to render_template :edit
|
351
|
-
end
|
352
|
-
end
|
353
|
-
|
354
|
-
context "when current_order is nil" do
|
355
|
-
before { allow(controller).to receive_messages current_order: nil }
|
356
|
-
|
357
|
-
it "should not change the state if order is completed" do
|
358
|
-
expect(order).not_to receive(:update_attribute)
|
359
|
-
post :update, params: { state: "confirm" }
|
360
|
-
end
|
361
|
-
|
362
|
-
it "should redirect to the cart_path" do
|
363
|
-
post :update, params: { state: "confirm" }
|
364
|
-
expect(response).to redirect_to spree.cart_path
|
365
|
-
end
|
366
|
-
end
|
367
|
-
|
368
|
-
context "Spree::Core::GatewayError" do
|
369
|
-
before do
|
370
|
-
order.update! user: user
|
371
|
-
allow(order).to receive(:next).and_raise(Spree::Core::GatewayError.new("Invalid something or other."))
|
372
|
-
post :update, params: { state: "address", order: { bill_address_attributes: address_params } }
|
373
|
-
end
|
374
|
-
|
375
|
-
it "should render the edit template and display exception message" do
|
376
|
-
expect(response).to render_template :edit
|
377
|
-
expect(flash.now[:error]).to eq(I18n.t('spree.spree_gateway_error_flash_for_checkout'))
|
378
|
-
expect(assigns(:order).errors[:base]).to include("Invalid something or other.")
|
379
|
-
end
|
380
|
-
end
|
381
|
-
|
382
|
-
context "fails to transition from address" do
|
383
|
-
let(:order) do
|
384
|
-
FactoryBot.create(:order_with_line_items).tap do |order|
|
385
|
-
order.next!
|
386
|
-
expect(order.state).to eq('address')
|
387
|
-
end
|
388
|
-
end
|
389
|
-
|
390
|
-
before do
|
391
|
-
allow(controller).to receive_messages current_order: order
|
392
|
-
allow(controller).to receive_messages check_authorization: true
|
393
|
-
end
|
394
|
-
|
395
|
-
context "when the order is invalid" do
|
396
|
-
before do
|
397
|
-
allow(order).to receive_messages valid?: true, next: nil
|
398
|
-
order.errors.add :base, 'Base error'
|
399
|
-
order.errors.add :adjustments, 'error'
|
400
|
-
end
|
401
|
-
|
402
|
-
it "due to the order having errors" do
|
403
|
-
put :update, params: { state: order.state, order: { bill_address_attributes: address_params } }
|
404
|
-
expect(flash[:error]).to eq("Base error\nAdjustments error")
|
405
|
-
expect(response).to redirect_to(spree.checkout_state_path('address'))
|
406
|
-
end
|
407
|
-
end
|
408
|
-
|
409
|
-
context "when the country is not a shippable country" do
|
410
|
-
let(:foreign_address) { create(:address, country_iso_code: "CA") }
|
411
|
-
|
412
|
-
before do
|
413
|
-
order.update(shipping_address: foreign_address)
|
414
|
-
end
|
415
|
-
|
416
|
-
it "due to no available shipping rates for any of the shipments" do
|
417
|
-
put :update, params: { state: "address", order: { bill_address_attributes: address_params } }
|
418
|
-
expect(flash[:error]).to eq(I18n.t('spree.items_cannot_be_shipped'))
|
419
|
-
expect(response).to redirect_to(spree.checkout_state_path('address'))
|
420
|
-
end
|
421
|
-
end
|
422
|
-
end
|
423
|
-
|
424
|
-
context "when GatewayError is raised" do
|
425
|
-
let(:order) do
|
426
|
-
FactoryBot.create(:order_with_line_items).tap do |order|
|
427
|
-
until order.state == 'payment'
|
428
|
-
order.next!
|
429
|
-
end
|
430
|
-
# So that the confirmation step is skipped and we get straight to the action.
|
431
|
-
payment_method = FactoryBot.create(:simple_credit_card_payment_method)
|
432
|
-
payment = FactoryBot.create(:payment, payment_method: payment_method, amount: order.total)
|
433
|
-
order.payments << payment
|
434
|
-
order.next!
|
435
|
-
end
|
436
|
-
end
|
437
|
-
|
438
|
-
before do
|
439
|
-
allow(controller).to receive_messages current_order: order
|
440
|
-
allow(controller).to receive_messages check_authorization: true
|
441
|
-
end
|
442
|
-
|
443
|
-
it "fails to transition from payment to complete" do
|
444
|
-
allow_any_instance_of(Spree::Payment).to receive(:process!).and_raise(Spree::Core::GatewayError.new(I18n.t('spree.payment_processing_failed')))
|
445
|
-
put :update, params: { state: order.state, order: {} }
|
446
|
-
expect(flash[:error]).to eq(I18n.t('spree.payment_processing_failed'))
|
447
|
-
end
|
448
|
-
end
|
449
|
-
|
450
|
-
context "when InsufficientStock error is raised" do
|
451
|
-
before do
|
452
|
-
allow(controller).to receive_messages current_order: order
|
453
|
-
allow(controller).to receive_messages check_authorization: true
|
454
|
-
allow(controller).to receive_messages ensure_sufficient_stock_lines: true
|
455
|
-
end
|
456
|
-
|
457
|
-
context "when the order has no shipments" do
|
458
|
-
let(:order) { Spree::TestingSupport::OrderWalkthrough.up_to(:address) }
|
459
|
-
|
460
|
-
before do
|
461
|
-
allow(order).to receive_messages shipments: []
|
462
|
-
# Order#next is the tipical failure point here:
|
463
|
-
allow(order).to receive(:next).and_raise(Spree::Order::InsufficientStock)
|
464
|
-
end
|
465
|
-
|
466
|
-
it "redirects the customer to the cart page with an error message" do
|
467
|
-
put :update, params: { state: order.state, order: { bill_address_attributes: address_params } }
|
468
|
-
expect(flash[:error]).to eq(I18n.t('spree.insufficient_stock_for_order'))
|
469
|
-
expect(response).to redirect_to(spree.cart_path)
|
470
|
-
end
|
471
|
-
end
|
472
|
-
|
473
|
-
context "when the order has shipments" do
|
474
|
-
let(:order) { Spree::TestingSupport::OrderWalkthrough.up_to(:payment) }
|
475
|
-
|
476
|
-
context "when items become somehow not available anymore" do
|
477
|
-
before { Spree::StockItem.update_all backorderable: false }
|
478
|
-
|
479
|
-
it "redirects the customer to the address checkout page with an error message" do
|
480
|
-
put :update, params: { state: order.state, order: {} }
|
481
|
-
error = I18n.t('spree.inventory_error_flash_for_insufficient_shipment_quantity', unavailable_items: order.products.first.name)
|
482
|
-
expect(flash[:error]).to eq(error)
|
483
|
-
expect(response).to redirect_to(spree.checkout_state_path(state: :address))
|
484
|
-
end
|
485
|
-
end
|
486
|
-
end
|
487
|
-
end
|
488
|
-
end
|
489
|
-
|
490
|
-
context "When last inventory item has been purchased" do
|
491
|
-
let(:product) { mock_model(Spree::Product, name: "Amazing Object") }
|
492
|
-
let(:variant) { mock_model(Spree::Variant) }
|
493
|
-
let(:line_item) { mock_model Spree::LineItem, insufficient_stock?: true, amount: 0, name: "Amazing Item" }
|
494
|
-
let(:order) { create(:order) }
|
495
|
-
|
496
|
-
before do
|
497
|
-
allow(order).to receive_messages(line_items: [line_item], state: "payment")
|
498
|
-
|
499
|
-
stub_spree_preferences(track_inventory_levels: true)
|
500
|
-
end
|
501
|
-
|
502
|
-
context "and back orders are not allowed" do
|
503
|
-
before do
|
504
|
-
post :update, params: { state: "payment" }
|
505
|
-
end
|
506
|
-
|
507
|
-
it "should redirect to cart" do
|
508
|
-
expect(response).to redirect_to spree.cart_path
|
509
|
-
end
|
510
|
-
|
511
|
-
it "should set flash message for no inventory" do
|
512
|
-
expect(flash[:error]).to eq("Amazing Item became unavailable.")
|
513
|
-
end
|
514
|
-
end
|
515
|
-
end
|
516
|
-
|
517
|
-
context "order doesn't have a delivery step" do
|
518
|
-
before do
|
519
|
-
allow(order).to receive_messages(checkout_steps: ["cart", "address", "payment"])
|
520
|
-
allow(order).to receive_messages state: "address"
|
521
|
-
allow(controller).to receive_messages check_authorization: true
|
522
|
-
end
|
523
|
-
|
524
|
-
it "doesn't set a default shipping address on the order" do
|
525
|
-
expect(order).to_not receive(:ship_address=)
|
526
|
-
post :update, params: { state: order.state, order: { bill_address_attributes: address_params } }
|
527
|
-
end
|
528
|
-
|
529
|
-
it "doesn't remove unshippable items before payment" do
|
530
|
-
expect {
|
531
|
-
post :update, params: { state: "payment" }
|
532
|
-
}.to_not change { order.line_items }
|
533
|
-
end
|
534
|
-
end
|
535
|
-
|
536
|
-
it "does remove unshippable items before payment" do
|
537
|
-
allow(order).to receive_messages payment_required?: true
|
538
|
-
allow(controller).to receive_messages check_authorization: true
|
539
|
-
|
540
|
-
expect {
|
541
|
-
post :update, params: { state: "payment", order: { email: "johndoe@example.com" } }
|
542
|
-
}.to change { order.line_items.to_a.size }.from(1).to(0)
|
543
|
-
end
|
544
|
-
|
545
|
-
context 'trying to apply a coupon code' do
|
546
|
-
let(:order) { create(:order_with_line_items, state: 'payment', guest_token: 'a token') }
|
547
|
-
let(:coupon_code) { "coupon_code" }
|
548
|
-
|
549
|
-
before { cookies.signed[:guest_token] = order.guest_token }
|
550
|
-
|
551
|
-
context "when coupon code is empty" do
|
552
|
-
let(:coupon_code) { "" }
|
553
|
-
|
554
|
-
it 'does not try to apply coupon code' do
|
555
|
-
expect(Spree::PromotionHandler::Coupon).not_to receive :new
|
556
|
-
|
557
|
-
put :update, params: { state: order.state, order: { coupon_code: coupon_code } }
|
558
|
-
|
559
|
-
expect(response).to redirect_to(spree.checkout_state_path('confirm'))
|
560
|
-
end
|
561
|
-
end
|
562
|
-
end
|
563
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
# This spec is useful for when we just want to make sure a view is rendering correctly
|
6
|
-
# Walking through the entire checkout process is rather tedious, don't you think?
|
7
|
-
describe Spree::CheckoutController, type: :controller do
|
8
|
-
render_views
|
9
|
-
let(:token) { 'some_token' }
|
10
|
-
let(:user) { stub_model(Spree::LegacyUser) }
|
11
|
-
|
12
|
-
before do
|
13
|
-
allow(controller).to receive_messages try_spree_current_user: user
|
14
|
-
end
|
15
|
-
|
16
|
-
# Regression test for https://github.com/spree/spree/issues/3246
|
17
|
-
context "when using GBP" do
|
18
|
-
before do
|
19
|
-
stub_spree_preferences(currency: "GBP")
|
20
|
-
end
|
21
|
-
|
22
|
-
context "when order is in delivery" do
|
23
|
-
before do
|
24
|
-
# Using a let block won't acknowledge the currency setting
|
25
|
-
# Therefore we just do it like this...
|
26
|
-
order = Spree::TestingSupport::OrderWalkthrough.up_to(:address)
|
27
|
-
allow(controller).to receive_messages current_order: order
|
28
|
-
end
|
29
|
-
|
30
|
-
it "displays rate cost in correct currency" do
|
31
|
-
get :edit
|
32
|
-
html = Nokogiri::HTML(response.body)
|
33
|
-
expect(html.css('.shipping-methods__rate').text.strip).to have_content("£10.00")
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe 'current order tracking', type: :controller do
|
6
|
-
let!(:store) { create(:store) }
|
7
|
-
let(:user) { create(:user) }
|
8
|
-
|
9
|
-
controller(Spree::StoreController) do
|
10
|
-
def index
|
11
|
-
head :ok
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
let(:order) { FactoryBot.create(:order) }
|
16
|
-
|
17
|
-
it 'automatically tracks who the order was created by & IP address' do
|
18
|
-
allow(controller).to receive_messages(try_spree_current_user: user)
|
19
|
-
get :index
|
20
|
-
expect(controller.current_order(create_order_if_necessary: true).created_by).to eq controller.try_spree_current_user
|
21
|
-
expect(controller.current_order.last_ip_address).to eq "0.0.0.0"
|
22
|
-
end
|
23
|
-
|
24
|
-
context "current order creation" do
|
25
|
-
before { allow(controller).to receive_messages(try_spree_current_user: user) }
|
26
|
-
|
27
|
-
it "doesn't create a new order out of the blue" do
|
28
|
-
expect {
|
29
|
-
get :index
|
30
|
-
}.not_to change { Spree::Order.count }
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Spree::HomeController, type: :controller do
|
6
|
-
it "provides current user to the searcher class" do
|
7
|
-
user = mock_model(Spree.user_class, last_incomplete_spree_order: nil, spree_api_key: 'fake')
|
8
|
-
allow(controller).to receive_messages try_spree_current_user: user
|
9
|
-
expect_any_instance_of(Spree::Config.searcher_class).to receive(:current_user=).with(user)
|
10
|
-
get :index
|
11
|
-
expect(response.status).to eq(200)
|
12
|
-
end
|
13
|
-
|
14
|
-
context "layout" do
|
15
|
-
it "renders default layout" do
|
16
|
-
get :index
|
17
|
-
expect(response).to render_template(layout: 'spree/layouts/spree_application')
|
18
|
-
end
|
19
|
-
|
20
|
-
context "different layout specified in config" do
|
21
|
-
before { stub_spree_preferences(layout: 'layouts/application') }
|
22
|
-
|
23
|
-
it "renders specified layout" do
|
24
|
-
get :index
|
25
|
-
expect(response).to render_template(layout: 'layouts/application')
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|