Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Add tests, fix some CC issues.
Matthew Kennedyfc5fd0b3644d
diff --git a/api/app/helpers/spree/api/api_helpers.rb b/api/app/helpers/spree/api/api_helpers.rbindex 8ace7d1107..c3d384ca62 100644--- a/api/app/helpers/spree/api/api_helpers.rb+++ b/api/app/helpers/spree/api/api_helpers.rb@@ -9,7 +9,6 @@ module Spree:option_value_attributes,:order_attributes,:line_item_attributes,- :menu_attributes,:option_type_attributes,:payment_attributes,:payment_method_attributes,@@ -86,8 +85,6 @@ module Spree@@line_item_attributes = [:id, :quantity, :price, :variant_id]- @@menu_attributes = [:id, :name, :unique_code]-@@option_type_attributes = [:id, :name, :presentation, :position]@@payment_attributes = [diff --git a/api/app/models/spree/api_dependencies.rb b/api/app/models/spree/api_dependencies.rbindex 5d57e85d9f..c8fc1e47aa 100644--- a/api/app/models/spree/api_dependencies.rb+++ b/api/app/models/spree/api_dependencies.rb@@ -10,10 +10,11 @@ module Spree:storefront_checkout_remove_store_credit_service, :storefront_checkout_get_shipping_rates_service,:storefront_cart_compare_line_items_service, :storefront_cart_serializer, :storefront_credit_card_serializer,:storefront_credit_card_finder, :storefront_shipment_serializer, :storefront_payment_method_serializer, :storefront_country_finder,- :storefront_country_serializer, :storefront_menu_serializer, :storefront_menu_finder, :storefront_current_order_finder, :storefront_completed_order_finder, :storefront_order_sorter,- :storefront_collection_paginator, :storefront_user_serializer, :storefront_products_sorter, :storefront_products_finder,- :storefront_product_serializer, :storefront_taxon_serializer, :storefront_taxon_finder, :storefront_find_by_variant_finder,- :storefront_cart_update_service, :storefront_cart_estimate_shipping_rates_service, :storefront_estimated_shipment_serializer,+ :storefront_country_serializer, :storefront_menu_serializer, :storefront_menu_finder, :storefront_current_order_finder,+ :storefront_completed_order_finder, :storefront_order_sorter, :storefront_collection_paginator, :storefront_user_serializer,+ :storefront_products_sorter, :storefront_products_finder, :storefront_product_serializer, :storefront_taxon_serializer,+ :storefront_taxon_finder, :storefront_find_by_variant_finder, :storefront_cart_update_service,+ :storefront_cart_estimate_shipping_rates_service, :storefront_estimated_shipment_serializer,:storefront_store_serializer, :storefront_address_serializer, :storefront_order_serializer,:storefront_account_create_address_service, :storefront_account_update_address_service, :storefront_address_finder,:storefront_collection_sorter, :error_handlerdiff --git a/api/app/serializers/spree/v2/storefront/menu_item_serializer.rb b/api/app/serializers/spree/v2/storefront/menu_item_serializer.rbindex a03dd61c93..7737f1cece 100644--- a/api/app/serializers/spree/v2/storefront/menu_item_serializer.rb+++ b/api/app/serializers/spree/v2/storefront/menu_item_serializer.rb@@ -19,10 +19,10 @@ module Spreeendhas_one :image,- object_method_name: :image_asset,- id_method_name: :image_asset,- record_type: :image,- serializer: :image+ object_method_name: :image_asset,+ id_method_name: :image_asset,+ record_type: :image,+ serializer: :imagebelongs_to :menuenddiff --git a/backend/spec/features/admin/menus/edit_menu_spec.rb b/backend/spec/features/admin/menus/edit_menu_spec.rbindex f1ff132335..6a39cca564 100644--- a/backend/spec/features/admin/menus/edit_menu_spec.rb+++ b/backend/spec/features/admin/menus/edit_menu_spec.rb@@ -3,10 +3,10 @@ require 'spec_helper'describe 'Menu Edit', type: :feature dostub_authorization!- context 'when link to URL the user can' do- let!(:main_menu) { create(:menu, name: 'Main Menu') }- let!(:menu_item) { create(:menu_item, menu_id: main_menu.id) }+ let!(:main_menu) { create(:menu, name: 'Main Menu', unique_code: 'spree-main') }+ let!(:menu_item) { create(:menu_item, menu_id: main_menu.id, parent_id: main_menu.root.id) }+ context 'when link to URL the user can' dobefore dovisit spree.edit_admin_menu_menu_item_path(main_menu, menu_item)end@@ -20,78 +20,68 @@ describe 'Menu Edit', type: :feature doendend- # FRONT END ONLY-- # context 'setting a home page link', js: true do- # let!(:main_menu) { create(:menu, name: 'Main Menu') }- # let!(:menu_item) { create(:menu_item, menu_id: main_menu.id) }-- # before do- # visit spree.edit_admin_menu_menu_item_path(main_menu, menu_item)- # end-- # it 'allows you to switch to home page link' do- # select2 'Home Page', from: 'Link To'- # expect(page).to have_text 'Click the Update button below to change the link.'- # click_on 'Update'-- # assert_admin_flash_alert_success('Menu item "Link To Somewhere" has been successfully updated!')- # expect(page).to have_text 'This link takes you to your stores home page.'- # end- # end-- # context 'setting the link to a product link', js: true do- # let!(:main_menu) { create(:menu, name: 'Main Menu') }- # let!(:menu_item) { create(:menu_item, menu_id: main_menu.id) }- # let!(:product_1) { create(:product, name: 'Blue Shoes') }- # let!(:product_2) { create(:product, name: 'Black Socks') }- # let!(:product_3) { create(:product, name: 'Green Shirt') }-- # before do- # visit spree.edit_admin_menu_menu_item_path(main_menu, menu_item)- # end-- # it 'allows you to switch to select a product and save' do- # select2 'Spree::Product', from: 'Link To'- # expect(page).to have_text 'Click the Update button below to change the link.'- # click_on 'Update'-- # select2 product_2.name, from: 'Product'- # click_on 'Update'-- # assert_admin_flash_alert_success('Menu item "Link To Somewhere" has been successfully updated!')- # expect(page).to have_css('span.select2-selection', text: product_2.name)- # end- # end-- # context 'setting the link to a taxon link', js: true do- # let!(:main_menu) { create(:menu, name: 'Main Menu') }- # let!(:menu_item) { create(:menu_item, menu_id: main_menu.id) }- # let!(:taxon_1) { create(:taxon) }- # let!(:taxon_2) { create(:taxon) }- # let!(:taxon_3) { create(:taxon) }-- # before do- # visit spree.edit_admin_menu_menu_item_path(main_menu, menu_item)- # end-- # it 'allows you to select a taxon and save' do- # select2 'Spree::Taxon', from: 'Link To'- # expect(page).to have_text 'Click the Update button below to change the link.'- # click_on 'Update'-- # select2 taxon_2.name, from: 'Taxon'- # click_on 'Update'-- # assert_admin_flash_alert_success('Menu item "Link To Somewhere" has been successfully updated!')- # expect(page).to have_css('span.select2-selection', text: taxon_2.pretty_name)- # end- # end+ context 'setting a home page link', js: true do+ before do+ visit spree.edit_admin_menu_menu_item_path(main_menu, menu_item)+ end++ it 'allows you to switch to home page link' do+ select2 'Home Page', from: 'Link To'+ expect(page).to have_text 'Click the Update button below to change the link.'+ click_on 'Update'- context 'trying to save a menu item without a name' do- let!(:main_menu) { create(:menu, name: 'Main Menu') }- let!(:menu_item) { create(:menu_item, menu_id: main_menu.id) }+ assert_admin_flash_alert_success('Menu item "Link To Somewhere" has been successfully updated!')+ expect(page).to have_text 'This link takes you to your stores home page.'+ end+ end++ context 'setting the link to a product link', js: true do+ let!(:product_1) { create(:product, name: 'Blue Shoes') }+ let!(:product_2) { create(:product, name: 'Black Socks') }+ let!(:product_3) { create(:product, name: 'Green Shirt') }++ before do+ visit spree.edit_admin_menu_menu_item_path(main_menu, menu_item)+ end++ it 'allows you to switch to select a product and save' do+ select2 'Spree::Product', from: 'Link To'+ expect(page).to have_text 'Click the Update button below to change the link.'+ click_on 'Update'++ select2 product_2.name, from: 'Product'+ click_on 'Update'++ assert_admin_flash_alert_success('Menu item "Link To Somewhere" has been successfully updated!')+ expect(page).to have_css('span.select2-selection', text: product_2.name)+ expect(page).to have_text("/products/#{product_2.slug}")+ end+ end++ context 'setting the link to a taxon link', js: true do+ let!(:taxon_1) { create(:taxon) }+ let!(:taxon_2) { create(:taxon) }+ let!(:taxon_3) { create(:taxon) }++ before do+ visit spree.edit_admin_menu_menu_item_path(main_menu, menu_item)+ end+ it 'allows you to select a taxon and save' do+ select2 'Spree::Taxon', from: 'Link To'+ expect(page).to have_text 'Click the Update button below to change the link.'+ click_on 'Update'++ select2 taxon_2.name, from: 'Taxon'+ click_on 'Update'++ assert_admin_flash_alert_success('Menu item "Link To Somewhere" has been successfully updated!')+ expect(page).to have_css('span.select2-selection', text: taxon_2.pretty_name)+ expect(page).to have_text("/t/#{taxon_2.permalink}")+ end+ end++ context 'trying to save a menu item without a name' dobefore dovisit spree.edit_admin_menu_menu_item_path(main_menu, menu_item)enddiff --git a/core/app/helpers/spree/base_helper.rb b/core/app/helpers/spree/base_helper.rbindex db6d0088ab..2e0e9f4d3e 100644--- a/core/app/helpers/spree/base_helper.rb+++ b/core/app/helpers/spree/base_helper.rb@@ -35,7 +35,7 @@ module Spreeendif Spree::MenuItem::DYNAMIC_RESOURCE_TYPE.include? item.linked_resource_type- "#{output_locale + item.destination}"+ output_locale.to_s + item.destination.to_selsecase item.linked_resource_typewhen 'URL'diff --git a/core/app/models/spree/menu.rb b/core/app/models/spree/menu.rbindex fc17bdea95..efcc099636 100644--- a/core/app/models/spree/menu.rb+++ b/core/app/models/spree/menu.rb@@ -3,7 +3,7 @@ module Spreehas_many :menu_items, dependent: :destroyhas_and_belongs_to_many :stores- before_save :paremeterize_unique_code+ before_validation :paremeterize_unique_codeafter_create :set_rootafter_save :set_root_menu_item_namediff --git a/core/lib/spree/permitted_attributes.rb b/core/lib/spree/permitted_attributes.rbindex 7ddda8b448..8f355e3401 100644--- a/core/lib/spree/permitted_attributes.rb+++ b/core/lib/spree/permitted_attributes.rb@@ -7,8 +7,6 @@ module Spree:image_attributes,:inventory_unit_attributes,:line_item_attributes,- :menu_attributes,- :menu_item_attributes,:option_type_attributes,:option_value_attributes,:payment_attributes,@@ -53,10 +51,6 @@ module Spree@@line_item_attributes = [:id, :variant_id, :quantity]- @@menu_attributes = [:id, :name, :unique_code]-- @@menu_item_attributes = [:id, :name, :destination, :image_asset, :menu_id]-@@option_type_attributes = [:name, :presentation, :option_values_attributes]@@option_value_attributes = [:name, :presentation]