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
Extract spree_multi_store to standalone gem (#13642)
Damian Legawiec315257e5b5e6
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.ymlindex 434c13dda1..22484d2c6f 100644--- a/.github/workflows/tests.yml+++ b/.github/workflows/tests.yml@@ -52,7 +52,7 @@ jobs:- name: Install all project dependenciesrun: |- for project in core api admin emails multi_store; do+ for project in core api admin emails; doecho "--- Installing gems for $project ---"cd backend/engines/$projectbundle config set --local path ${{ github.workspace }}/vendor/bundle@@ -91,7 +91,7 @@ jobs:- name: Install all project dependenciesrun: |- for project in core api admin emails multi_store; do+ for project in core api admin emails; doecho "--- Installing gems for $project ---"cd backend/engines/$projectbundle config set --local path ${{ github.workspace }}/vendor/bundle@@ -122,8 +122,6 @@ jobs:- { project: admin, shard: 2, total_shards: 2 }# emails: 1 shard- { project: emails, shard: 1, total_shards: 1 }- # multi_store: 1 shard- - { project: multi_store, shard: 1, total_shards: 1 }services:postgres:image: postgres:16@@ -263,8 +261,6 @@ jobs:- { project: admin, shard: 2, total_shards: 2 }# emails: 1 shard- { project: emails, shard: 1, total_shards: 1 }- # multi_store: 1 shard- - { project: multi_store, shard: 1, total_shards: 1 }services:mysql:image: mysql:8.0diff --git a/backend/engines/multi_store/Gemfile b/backend/engines/multi_store/Gemfiledeleted file mode 100644index 8ce2a0ac90..0000000000--- a/backend/engines/multi_store/Gemfile+++ /dev/null@@ -1,13 +0,0 @@-eval_gemfile('../common_spree_dependencies.rb')--gem 'spree', path: '../'-gem 'spree_admin', path: '../admin'-gem 'spree_emails', path: '../emails'--gem 'sprockets-rails', '>= 3.5.2'--group :test, :development do- gem 'selenium-webdriver'-end--gemspecdiff --git a/backend/engines/multi_store/LICENSE.md b/backend/engines/multi_store/LICENSE.mddeleted file mode 100644index 1708018b23..0000000000--- a/backend/engines/multi_store/LICENSE.md+++ /dev/null@@ -1,14 +0,0 @@-Copyright (c) 2026 Vendo Connect Inc. Vendo Sp. z o.o.--This program is free software: you can redistribute it and/or modify-it under the terms of the GNU Affero General Public License as published by-the Free Software Foundation, either version 3 of the License, or-(at your option) any later version.--This program is distributed in the hope that it will be useful,-but WITHOUT ANY WARRANTY; without even the implied warranty of-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-GNU Affero General Public License for more details.--You should have received a copy of the GNU Affero General Public License-along with this program. If not, see <https://www.gnu.org/licenses/>.diff --git a/backend/engines/multi_store/Rakefile b/backend/engines/multi_store/Rakefiledeleted file mode 100644index d1229bb687..0000000000--- a/backend/engines/multi_store/Rakefile+++ /dev/null@@ -1,17 +0,0 @@-require 'rubygems'-require 'rake'-require 'rake/testtask'-require 'rspec/core/rake_task'-require 'spree/testing_support/common_rake'--RSpec::Core::RakeTask.new--task default: :spec--desc "Generates a dummy app for testing"-task :test_app do- ENV['LIB_NAME'] = 'spree/multi_store'- Rake::Task['common:test_app'].execute(- install_admin: true- )-enddiff --git a/backend/engines/multi_store/app/controllers/spree/admin/custom_domains_controller.rb b/backend/engines/multi_store/app/controllers/spree/admin/custom_domains_controller.rbdeleted file mode 100644index 47b4144bc9..0000000000--- a/backend/engines/multi_store/app/controllers/spree/admin/custom_domains_controller.rb+++ /dev/null@@ -1,21 +0,0 @@-module Spree- module Admin- class CustomDomainsController < ResourceController- include Spree::Admin::SettingsConcern-- protected-- def collection_url- spree.admin_custom_domains_path- end-- def location_after_save- spree.admin_custom_domains_path- end-- def permitted_resource_params- params.require(:custom_domain).permit(Spree::PermittedAttributes.custom_domain_attributes)- end- end- end-enddiff --git a/backend/engines/multi_store/app/controllers/spree/admin/multi_store/base_controller_decorator.rb b/backend/engines/multi_store/app/controllers/spree/admin/multi_store/base_controller_decorator.rbdeleted file mode 100644index cbd2596db7..0000000000--- a/backend/engines/multi_store/app/controllers/spree/admin/multi_store/base_controller_decorator.rb+++ /dev/null@@ -1,13 +0,0 @@-module Spree- module Admin- module MultiStore- module BaseControllerDecorator- def self.prepended(base)- base.helper 'spree/admin/multi_store'- end- end- end-- BaseController.prepend(MultiStore::BaseControllerDecorator)- end-enddiff --git a/backend/engines/multi_store/app/controllers/spree/admin/multi_store/stores_controller.rb b/backend/engines/multi_store/app/controllers/spree/admin/multi_store/stores_controller.rbdeleted file mode 100644index 8d09838574..0000000000--- a/backend/engines/multi_store/app/controllers/spree/admin/multi_store/stores_controller.rb+++ /dev/null@@ -1,35 +0,0 @@-module Spree- module Admin- module MultiStore- class StoresController < Spree::Admin::BaseController- def new- @store = Spree::Store.new(default_country_iso: 'US')- render :new, layout: 'spree/admin_wizard'- end-- def create- @store = Spree::Store.new(permitted_store_params)- @store.mail_from_address = current_store.mail_from_address-- if @store.save- # Move/copy all existing users (staff) to the new store- current_store.role_users.each do |role_user|- @store.add_user(role_user.user, role_user.role)- end-- flash[:success] = flash_message_for(@store, :successfully_created)- redirect_to spree.admin_getting_started_url(host: @store.url), allow_other_host: true- else- render :new, status: :unprocessable_content, layout: 'spree/admin_wizard'- end- end-- protected-- def permitted_store_params- params.require(:store).permit(permitted_store_attributes)- end- end- end- end-enddiff --git a/backend/engines/multi_store/app/finders/spree/stores/find_current.rb b/backend/engines/multi_store/app/finders/spree/stores/find_current.rbdeleted file mode 100644index 978985c73a..0000000000--- a/backend/engines/multi_store/app/finders/spree/stores/find_current.rb+++ /dev/null@@ -1,28 +0,0 @@-module Spree- module Stores- class FindCurrent- def initialize(scope: nil, url: nil)- @scope = scope || Spree::Store- @url = url- end-- def execute- store = by_url(scope) || scope.default- return if store.nil?-- Spree::Current.store = store- store- end-- protected-- attr_reader :scope, :url-- def by_url(scope)- return if url.blank?-- scope.by_custom_domain(url).or(scope.by_url(url)).first- end- end- end-enddiff --git a/backend/engines/multi_store/app/helpers/spree/admin/multi_store_helper.rb b/backend/engines/multi_store/app/helpers/spree/admin/multi_store_helper.rbdeleted file mode 100644index 9fbde228f4..0000000000--- a/backend/engines/multi_store/app/helpers/spree/admin/multi_store_helper.rb+++ /dev/null@@ -1,11 +0,0 @@-module Spree- module Admin- module MultiStoreHelper- def available_stores- scope = Spree::Store.accessible_by(current_ability, :manage).includes(:logo_attachment, :favicon_image_attachment)- scope = scope.includes(:default_custom_domain) if Spree::Store.reflect_on_association(:default_custom_domain)- @available_stores ||= scope- end- end- end-enddiff --git a/backend/engines/multi_store/app/models/concerns/spree/multi_store_resource.rb b/backend/engines/multi_store/app/models/concerns/spree/multi_store_resource.rbdeleted file mode 100644index 109d38bbc3..0000000000--- a/backend/engines/multi_store/app/models/concerns/spree/multi_store_resource.rb+++ /dev/null@@ -1,33 +0,0 @@-module Spree- module MultiStoreResource- extend ActiveSupport::Concern-- included do- scope :for_store, ->(store) { joins(:stores).where(Store.table_name => { id: store.id }) }-- before_validation :set_default_store, if: :new_record?-- validate :must_have_one_store, unless: :disable_store_presence_validation?- end-- protected-- def must_have_one_store- return if stores.any?-- errors.add(:stores, Spree.t(:must_have_one_store))- end-- def set_default_store- return if disable_store_presence_validation?- return if stores.any?-- stores << Spree::Store.default- end-- # this can be overridden on model basis- def disable_store_presence_validation?- Spree::Config[:disable_store_presence_validation]- end- end-enddiff --git a/backend/engines/multi_store/app/models/concerns/spree/store/multi_store_class_overrides.rb b/backend/engines/multi_store/app/models/concerns/spree/store/multi_store_class_overrides.rbdeleted file mode 100644index 3831b349d6..0000000000--- a/backend/engines/multi_store/app/models/concerns/spree/store/multi_store_class_overrides.rb+++ /dev/null@@ -1,15 +0,0 @@-module Spree- module Store::MultiStoreClassOverrides- def current(url = nil)- if url.present?- Spree.current_store_finder.new(url: url).execute- else- Spree::Current.store- end- end-- def available_locales- Spree::Store.all.map(&:supported_locales_list).flatten.uniq- end- end-enddiff --git a/backend/engines/multi_store/app/models/concerns/spree/store/multi_store_methods.rb b/backend/engines/multi_store/app/models/concerns/spree/store/multi_store_methods.rbdeleted file mode 100644index 474e6b986e..0000000000--- a/backend/engines/multi_store/app/models/concerns/spree/store/multi_store_methods.rb+++ /dev/null@@ -1,108 +0,0 @@-module Spree- module Store::MultiStoreMethods- extend ActiveSupport::Concern-- RESERVED_CODES = %w(- admin default app api www cdn files assets checkout account auth login user- )-- included do- has_many :custom_domains, class_name: 'Spree::CustomDomain', dependent: :destroy- has_one :default_custom_domain, -> { where(default: true) }, class_name: 'Spree::CustomDomain'-- attribute :import_products_from_store_id, :string, default: nil- attribute :import_payment_methods_from_store_id, :string, default: nil-- attr_accessor :skip_validate_not_last-- validates :code, uniqueness: { case_sensitive: false, conditions: -> { with_deleted } },- exclusion: Spree::Store::MultiStoreMethods::RESERVED_CODES-- before_validation :set_url- after_create :import_products_from_store, if: -> { import_products_from_store_id.present? }- after_create :import_payment_methods_from_store, if: -> { import_payment_methods_from_store_id.present? }- after_commit :handle_code_changes, on: :update, if: -> { code_previously_changed? }- before_destroy :validate_not_last, unless: :skip_validate_not_last- before_destroy :pass_default_flag_to_other_store-- scope :by_custom_domain, ->(url) { left_joins(:custom_domains).where("#{Spree::CustomDomain.table_name}.url" => url) }- scope :by_url, ->(url) { where(url: url).or(where("#{table_name}.url like ?", "%#{url}%")) }-- # Re-configure FriendlyId to use :history for code tracking across renames- friendly_id :slug_candidates, use: [:slugged, :history], slug_column: :code, routes: :normal- end-- def formatted_custom_domain- return unless default_custom_domain-- @formatted_custom_domain ||= if Rails.env.development? || Rails.env.test?- URI::Generic.build(- scheme: Rails.application.routes.default_url_options[:protocol] || 'http',- host: default_custom_domain.url,- port: Rails.application.routes.default_url_options[:port]- ).to_s- else- URI::HTTPS.build(host: default_custom_domain.url).to_s- end- end-- def can_be_deleted?- self.class.where.not(id: id).any?- end-- def import_products_from_store- store = Spree::Store.find(import_products_from_store_id)- product_ids = store.products.pluck(:id)-- return if product_ids.empty?-- Spree::StoreProduct.insert_all(product_ids.map { |product_id| { store_id: id, product_id: product_id } })- end-- def import_payment_methods_from_store- store = Spree::Store.find(import_payment_methods_from_store_id)- payment_method_ids = store.payment_method_ids-- return if payment_method_ids.empty?-- Spree::StorePaymentMethod.insert_all(payment_method_ids.map { |payment_method_id| { store_id: id, payment_method_id: payment_method_id } })- end-- private-- def validate_not_last- unless can_be_deleted?- errors.add(:base, :cannot_destroy_only_store)- throw(:abort)- end- end-- def pass_default_flag_to_other_store- if default? && can_be_deleted?- self.class.where.not(id: id).first.update!(default: true)- self.default = false- end- end-- def handle_code_changes- # hook for custom logic on code changes- end-- # Auto-assign internal URL for stores based on code + root domain- def set_url- return if url_changed?- return unless code_changed?- return unless Spree.root_domain.present?-- self.url = [code, Spree.root_domain].join('.')- end-- def slug_candidates- []- end-- def should_generate_new_friendly_id?- false- end- end-enddiff --git a/backend/engines/multi_store/app/models/concerns/spree/store/multi_store_overrides.rb b/backend/engines/multi_store/app/models/concerns/spree/store/multi_store_overrides.rbdeleted file mode 100644index b26335cf64..0000000000--- a/backend/engines/multi_store/app/models/concerns/spree/store/multi_store_overrides.rb+++ /dev/null@@ -1,39 +0,0 @@-module Spree- module Store::MultiStoreOverrides- def url_or_custom_domain- default_custom_domain&.url || url- end-- def formatted_url_or_custom_domain- formatted_custom_domain || formatted_url- end-- def can_be_deleted?- self.class.where.not(id: id).any?- end-- private-- # Override core's simple set_default_code with full code generation logic- def set_default_code- self.code = if code.present?- code.parameterize.strip- elsif name.present?- name.parameterize.strip- end-- return if self.code.blank?-- # ensure code is unique- self.code = [name.parameterize, rand(9999)].join('-') while Spree::Store.with_deleted.where(code: self.code).exists?- end-- def should_generate_new_friendly_id?- false- end-- def slug_candidates- []- end- end-enddiff --git a/backend/engines/multi_store/app/models/spree/custom_domain.rb b/backend/engines/multi_store/app/models/spree/custom_domain.rbdeleted file mode 100644index 28c113390d..0000000000--- a/backend/engines/multi_store/app/models/spree/custom_domain.rb+++ /dev/null@@ -1,61 +0,0 @@-module Spree- class CustomDomain < Spree::Base- has_prefix_id :domain-- include Spree::SingleStoreResource- include Spree::Metafields- include Spree::Metadata-- normalizes :url, with: ->(value) { value&.to_s&.squish&.presence }-- #- # Associations- #- belongs_to :store, class_name: 'Spree::Store', inverse_of: :custom_domains, touch: true-- #- # Validations- #- validates :url, presence: true, uniqueness: true, format: {- with: %r{\A(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\z}i- }, length: { in: 1..63 }- validate :url_is_valid-- #- # Callbacks- #- before_validation :sanitize_url- after_save :ensure_has_one_default- after_validation :ensure_default, on: :create-- def url_is_valid- return if url.blank?- parts = url.split('.')-- errors.add(:url, 'use domain or subdomain') if parts.size > 4 || parts.size < 2- end-- def ensure_default- self.default = store.custom_domains.count.zero?- end-- def ensure_has_one_default- store.custom_domains.where.not(id: id).update_all(default: false) if default?- end-- def active?- true- end-- def name- url- end-- private-- # remove https:// and http:// from the url- def sanitize_url- self.url = url&.gsub(%r{https?://}, '')- end- end-enddiff --git a/backend/engines/multi_store/app/models/spree/multi_store/payment_method_decorator.rb b/backend/engines/multi_store/app/models/spree/multi_store/payment_method_decorator.rbdeleted file mode 100644index de6bd16f64..0000000000--- a/backend/engines/multi_store/app/models/spree/multi_store/payment_method_decorator.rb+++ /dev/null@@ -1,11 +0,0 @@-module Spree- module MultiStore- module PaymentMethodDecorator- def self.prepended(base)- base.include Spree::MultiStoreResource- end- end- end-- PaymentMethod.prepend(MultiStore::PaymentMethodDecorator)-enddiff --git a/backend/engines/multi_store/app/models/spree/multi_store/product_decorator.rb b/backend/engines/multi_store/app/models/spree/multi_store/product_decorator.rbdeleted file mode 100644index e7c931bad1..0000000000--- a/backend/engines/multi_store/app/models/spree/multi_store/product_decorator.rb+++ /dev/null@@ -1,11 +0,0 @@-module Spree- module MultiStore- module ProductDecorator- def self.prepended(base)- base.include Spree::MultiStoreResource- end- end- end-- Product.prepend(MultiStore::ProductDecorator)-enddiff --git a/backend/engines/multi_store/app/models/spree/multi_store/promotion_decorator.rb b/backend/engines/multi_store/app/models/spree/multi_store/promotion_decorator.rbdeleted file mode 100644index 59d190f1b8..0000000000--- a/backend/engines/multi_store/app/models/spree/multi_store/promotion_decorator.rb+++ /dev/null@@ -1,11 +0,0 @@-module Spree- module MultiStore- module PromotionDecorator- def self.prepended(base)- base.include Spree::MultiStoreResource- end- end- end-- Promotion.prepend(MultiStore::PromotionDecorator)-enddiff --git a/backend/engines/multi_store/app/models/spree/multi_store/store_decorator.rb b/backend/engines/multi_store/app/models/spree/multi_store/store_decorator.rbdeleted file mode 100644index 7a4101295e..0000000000--- a/backend/engines/multi_store/app/models/spree/multi_store/store_decorator.rb+++ /dev/null@@ -1,13 +0,0 @@-module Spree- module MultiStore- module StoreDecorator- def self.prepended(base)- base.include Spree::Store::MultiStoreMethods- base.singleton_class.prepend Spree::Store::MultiStoreClassOverrides- end- end- end-- Store.prepend(MultiStore::StoreDecorator)- Store.prepend(Store::MultiStoreOverrides)-enddiff --git a/backend/engines/multi_store/app/views/spree/admin/custom_domains/_custom_domain.html.erb b/backend/engines/multi_store/app/views/spree/admin/custom_domains/_custom_domain.html.erbdeleted file mode 100644index 71daad4021..0000000000--- a/backend/engines/multi_store/app/views/spree/admin/custom_domains/_custom_domain.html.erb+++ /dev/null@@ -1,11 +0,0 @@-<tr id="<%= spree_dom_id custom_domain %>">- <td><%= custom_domain.url %></td>- <td>- <%= active_badge(custom_domain.active?) %>- </td>-- <td><%= active_badge(custom_domain.default?) %></td>- <td class="actions">- <%= link_to_edit(custom_domain, no_text: true, url: spree.edit_admin_custom_domain_path(custom_domain), data: { turbo: false }) %>- </td>-</tr>diff --git a/backend/engines/multi_store/app/views/spree/admin/custom_domains/_custom_domains.html.erb b/backend/engines/multi_store/app/views/spree/admin/custom_domains/_custom_domains.html.erbdeleted file mode 100644index 4b1bfea789..0000000000--- a/backend/engines/multi_store/app/views/spree/admin/custom_domains/_custom_domains.html.erb+++ /dev/null@@ -1,19 +0,0 @@-<% if current_store.custom_domains.any? %>- <div class="table-responsive rounded-lg mt-4 border">- <table class="table">- <thead>- <tr>- <th scope="col"><%= sort_link @search, :name, Spree.t(:name) %></th>- <th scope="col"><%= Spree.t(:active) %>?</th>- <th scope="col"><%= Spree.t(:default) %>?</th>- <th scope="col"></th>- </tr>- </thead>- <tbody>- <%= render collection: current_store.custom_domains, partial: 'spree/admin/custom_domains/custom_domain', cached: spree_base_cache_scope %>- </tbody>- </table>- </div>-<% else %>- <%= render 'spree/admin/shared/no_resource_found' %>-<% end %>diff --git a/backend/engines/multi_store/app/views/spree/admin/custom_domains/_form.html.erb b/backend/engines/multi_store/app/views/spree/admin/custom_domains/_form.html.erbdeleted file mode 100644index 8f6f3ce2d2..0000000000--- a/backend/engines/multi_store/app/views/spree/admin/custom_domains/_form.html.erb+++ /dev/null@@ -1,7 +0,0 @@-<div class="card mb-6">- <div class="card-body">- <%= f.spree_text_field :url, label: Spree.t(:domain), prepend: 'https://', autofocus: f.object.new_record?, required: true %>-- <%= f.spree_check_box :default, help: 'We will use this domain in emails to customers.' %>- </div>-</div>diff --git a/backend/engines/multi_store/app/views/spree/admin/custom_domains/edit.html.erb b/backend/engines/multi_store/app/views/spree/admin/custom_domains/edit.html.erbdeleted file mode 100644index f5b8f8cb5d..0000000000--- a/backend/engines/multi_store/app/views/spree/admin/custom_domains/edit.html.erb+++ /dev/null@@ -1 +0,0 @@-<%= render 'spree/admin/shared/edit_resource' %>diff --git a/backend/engines/multi_store/app/views/spree/admin/custom_domains/index.html.erb b/backend/engines/multi_store/app/views/spree/admin/custom_domains/index.html.erbdeleted file mode 100644index aef742ac80..0000000000--- a/backend/engines/multi_store/app/views/spree/admin/custom_domains/index.html.erb+++ /dev/null@@ -1,65 +0,0 @@-<%= content_for(:page_title) do %>- <%= Spree.t(:domains) %>-<% end %>--<% content_for :page_actions do %>- <%= render_admin_partials(:custom_domains_actions_partials) %>-<% end %>--<%= render_admin_partials(:custom_domains_header_partials) %>--<div class="card-lg p-6">- <h5 class="mb-2">Internal URL</h5>- <div class="grid grid-cols-12 gap-6 mb-6">- <div class="col-span-12 lg:col-span-4">- <p class="text-gray-600">- This is your internal Admin URL.- </p>- </div>- <div class="col-span-12 lg:col-span-7 lg:col-start-6">- <%= form_for current_store, url: spree.admin_store_path, data: { turbo: false, controller: 'enable-button', 'enable-button-disable-when-not-changed-value': true } do |f| %>- <% if Spree.root_domain.present? %>- <div class="flex items-center gap-6">- <div class="input-group pr-2 grow <% if current_store.custom_domains.any? %>disabled<% end %>">- <span class="text-gray-400 pl-3 pr-0">https://</span>- <%= f.text_field :code, class: 'border-0 focus:ring-0 focus:outline-none grow rounded-lg text-base pl-0', data: { enable_button_target: 'input' }, required: true, disabled: current_store.custom_domains.any? %>- <span>.<%= Spree.root_domain %></span>-- <%= clipboard_component(current_store.formatted_url) %>- </div>- <% unless current_store.custom_domains.any? %>- <%= turbo_save_button_tag %>- <% end %>- </div>- <% else %>- <div class="flex items-center gap-6">- <div class="input-group pr-2 grow">- <span class="text-gray-400 pl-3 pr-0">https://</span>- <%= f.text_field :url, class: 'border-0 focus:ring-0 focus:outline-none grow rounded-lg text-base pl-0', required: true, data: { enable_button_target: 'input' } %>- <%= clipboard_component(current_store.formatted_url) %>- </div>- <%= turbo_save_button_tag %>- </div>- <% end %>- <% end %>- </div>- </div>- <hr class="my-12" />- <h5 class="mb-2"><%= Spree.t(:custom_domains) %></h5>- <div class="grid grid-cols-12 gap-6">- <div class="col-span-12 lg:col-span-4">- <p class="text-gray-600">- Connect your domain or subdomain to your storefront.- </p>- </div>- <div class="col-span-12 lg:col-span-7 lg:col-start-6">- <div class="text-right">- <%= link_to Spree.t(:new_domain), spree.new_admin_custom_domain_path, class: "btn btn-primary" %>- </div>-- <%= turbo_frame_tag 'admin_custom_domains_index' do %>- <%= render 'custom_domains' %>- <% end %>- </div>- </div>-</div>diff --git a/backend/engines/multi_store/app/views/spree/admin/custom_domains/new.html.erb b/backend/engines/multi_store/app/views/spree/admin/custom_domains/new.html.erbdeleted file mode 100644index 65a817edc9..0000000000--- a/backend/engines/multi_store/app/views/spree/admin/custom_domains/new.html.erb+++ /dev/null@@ -1 +0,0 @@-<%= render 'spree/admin/shared/new_resource' %>diff --git a/backend/engines/multi_store/app/views/spree/admin/multi_store/stores/new.html.erb b/backend/engines/multi_store/app/views/spree/admin/multi_store/stores/new.html.erbdeleted file mode 100644index 004fcae106..0000000000--- a/backend/engines/multi_store/app/views/spree/admin/multi_store/stores/new.html.erb+++ /dev/null@@ -1,122 +0,0 @@-<%= form_for @store, url: spree.admin_stores_path, data: { turbo: false, controller: 'enable-button' } do |f| %>- <div class="container mx-auto px-4 pt-8">- <h1 class="mb-6"><%= Spree.t(:new_store) %></h1>-- <%= render partial: 'spree/admin/shared/error_messages', locals: { target: @store } %>- <div class="grid grid-cols-12 gap-16">- <div class="col-span-12 lg:col-span-6">- <div class="form-group">- <%= f.label :name %>- <%= f.text_field :name, class: 'form-input',- placeholder: Spree.t(:store_name),- required: true,- autofocus: true,- data: {- enable_button_target: 'input',- } %>- </div>-- <div class="form-group">- <%= f.label :default_country_iso, Spree.t(:country) %>- <%= f.collection_select :default_country_iso, Spree::Country.order(:name), :iso, :name, { }, { data: { controller: 'autocomplete-select', enable_button_target: 'input' } } %>- </div>-- <% if available_stores.any? %>- <div class="form-group">- <%= f.label :import_products_from_store_id, Spree.t(:import_products_from) %>- <%= f.select :import_products_from_store_id,- options_for_select(available_stores.pluck(:name, :id)),- { include_blank: Spree.t(:do_not_import) },- {- data: { controller: 'autocomplete-select' }- } %>- </div>-- <div class="form-group">- <%= f.label :import_payment_methods_from_store_id, Spree.t(:import_payment_methods_from) %>- <%= f.select :import_payment_methods_from_store_id,- options_for_select(available_stores.pluck(:name, :id)),- { include_blank: Spree.t(:do_not_import) },- {- data: { controller: 'autocomplete-select' }- } %>- </div>- <% end %>- </div>- <div class="col-span-12 lg:col-span-5 lg:col-start-8">- <h5 class="mb-2">What will be shared with this new store:</h5>- <ul class="list-none p-0">- <li>- <%= icon('check', class: 'text-green-700') %>- <%= Spree.t(:products) %>, <%= Spree.t(:stock_locations) %> & <%= Spree.t(:inventory) %><br>- <em class="ml-5 text-gray-600 text-sm">you can select which ones will be available for this store</em>- </li>- <li>- <%= icon('check', class: 'text-green-700') %>- <%= Spree.t(:customers) %>- </li>- <li>- <%= icon('check', class: 'text-green-700') %>- <%= Spree.t(:shipping_methods) %>- </li>- <li>- <%= icon('check', class: 'text-green-700') %>- <%= Spree.t(:payment_methods) %><br>- <em class="ml-5 text-gray-600 text-sm">you can select which ones will be available for this store</em>- </li>- <li>- <%= icon('check', class: 'text-green-700') %>- Admin user privileges- </li>- </ul>-- <h5 class="mt-6 mb-2">What will not be shared with this new store:</h5>- <ul class="list-none p-0">- <li>- <%= icon('x', class: 'text-danger') %>- <%= Spree.t(:orders) %>- </li>- <li>- <%= icon('x', class: 'text-danger') %>- <%= Spree.t(:shipments) %>- </li>- <li>- <%= icon('x', class: 'text-danger') %>- <%= Spree.t(:payments) %>- </li>- <li>- <%= icon('x', class: 'text-danger') %>- <%= Spree.t(:refunds) %>- </li>- <li>- <%= icon('x', class: 'text-danger') %>- <%= Spree.t(:store_credits) %>- </li>- <li>- <%= icon('x', class: 'text-danger') %>- <%= Spree.t(:gift_cards) %>- </li>- <li>- <%= icon('x', class: 'text-danger') %>- <%= Spree.t(:blogs_posts) %>- </li>- <li>- <%= icon('x', class: 'text-danger') %>- <%= Spree.t(:markets) %>- </li>- <li>- <%= icon('x', class: 'text-danger') %>- <%= Spree.t(:themes) %> & <%= Spree.t(:pages) %>- </li>- <li>- <%= icon('x', class: 'text-danger') %>- <%= Spree.t(:integrations) %> eg. Google Analytics, Meta Pixel, etc.- </li>- </ul>- </div>- </div>- </div>- <footer id="footer" class="fixed bottom-0 left-0 w-full border-t border-gray-200 px-6 py-4 bg-gray-25 flex items-center justify-end gap-4 z-[1000]">- <%= turbo_save_button_tag Spree.t('actions.create'), data: { admin_target: 'save' } %>- </footer>-<% end %>diff --git a/backend/engines/multi_store/app/views/spree/admin/multi_store/stores/new.turbo_stream.erb b/backend/engines/multi_store/app/views/spree/admin/multi_store/stores/new.turbo_stream.erbdeleted file mode 100644index 1a55f650d3..0000000000--- a/backend/engines/multi_store/app/views/spree/admin/multi_store/stores/new.turbo_stream.erb+++ /dev/null@@ -1 +0,0 @@-<%= render template: 'spree/admin/stores/new', formats: [:html] %>diff --git a/backend/engines/multi_store/app/views/spree/admin/products/form/_stores.html.erb b/backend/engines/multi_store/app/views/spree/admin/products/form/_stores.html.erbdeleted file mode 100644index 77d205fdcb..0000000000--- a/backend/engines/multi_store/app/views/spree/admin/products/form/_stores.html.erb+++ /dev/null@@ -1,29 +0,0 @@-<% if available_stores.count > 1 %>- <div class="card mb-6">- <div class="card-header">- <h5 class="card-title">- <%= Spree.t(:stores) %>- </h5>- </div>- <div class="card-body">- <div class="form-group">- <% if can? :modify, Spree::StoreProduct %>- <p class="form-text"><%= Spree.t('admin.products.stores.choose_stores') %>.</p>-- <%= f.collection_check_boxes :store_ids, available_stores, :id, :name do |b| %>- <div class="custom-control form-checkbox mb-1">- <%= b.check_box(class: 'custom-control-input') %>- <%= b.label(class: 'custom-control-label') %>- </div>- <% end %>- <% elsif @product.stores.any? %>- <ul class="text_list">- <% @product.stores.pluck(:name).each do |store_name| %>- <li><%= store_name %></li>- <% end %>- </ul>- <% end %>- </div>- </div>- </div>-<% end %>diff --git a/backend/engines/multi_store/app/views/spree/admin/shared/sidebar/_store_dropdown.html.erb b/backend/engines/multi_store/app/views/spree/admin/shared/sidebar/_store_dropdown.html.erbdeleted file mode 100644index cba68ac1e8..0000000000--- a/backend/engines/multi_store/app/views/spree/admin/shared/sidebar/_store_dropdown.html.erb+++ /dev/null@@ -1,55 +0,0 @@-<div class="store-dropdown" id="store-menu">- <%= dropdown do %>- <%= dropdown_toggle class: 'store-dropdown-button dropdown-toggle' do %>- <%= store_admin_icon(current_store, height: 32, width: 32) %>- <span class="store-name hidden lg:block">- <%= truncate(current_store.name, length: 10) %>- </span>- <% end %>- <%= dropdown_menu do %>- <%= link_to current_store.formatted_url_or_custom_domain, class: 'dropdown-item', target: '_blank' do %>- <%= icon 'eye' %>- <%= Spree.t(:view_store) %>- <% end %>- <%= link_to spree.edit_admin_theme_path(current_store.default_theme), class: 'dropdown-item', data: { turbo_prefetch: false } do %>- <%= icon 'tools' %>- <%= Spree.t('admin.edit_theme') %>- <% end if current_store.respond_to?(:default_theme) && current_store.default_theme && can?(:manage, Spree::Theme) %>-- <% if available_stores.count > 1 %>- <div class="dropdown-divider"></div>- <h6 class="dropdown-header">- <%= Spree.t(:switch_store) %>- </h6>- <div class="store-chooser">- <% available_stores.each do |store| %>- <% if store.id == current_store.id %>- <div class="store-chooser-item active">- <%= store_admin_icon(store, height: 32, width: 32) %>- <span class="flex flex-col mr-2">- <%= store.name %>- <small class="text-gray-600">- <%= store.url_or_custom_domain %>- </small>- </span>- <%= icon('check', class: 'ml-auto') %>- </div>- <% else %>- <%= link_to spree.admin_dashboard_url(host: store.url), class: 'store-chooser-item' do %>- <%= store_admin_icon(store, height: 32, width: 32) %>- <span class="flex flex-col">- <%= store.name %>- <small class="text-gray-600">- <%= store.url_or_custom_domain %>- </small>- </span>- <% end %>- <% end %>- <% end %>- </div>- <% end %>- <% end %>- <% end %>-- <%= render 'spree/admin/shared/new_item_dropdown' %>-</div>diff --git a/backend/engines/multi_store/config/initializers/spree_multi_store.rb b/backend/engines/multi_store/config/initializers/spree_multi_store.rbdeleted file mode 100644index 75bada73fd..0000000000--- a/backend/engines/multi_store/config/initializers/spree_multi_store.rb+++ /dev/null@@ -1,19 +0,0 @@-Rails.application.config.after_initialize do- Spree::Dependencies.current_store_finder = 'Spree::Stores::FindCurrent'-- Spree.metafields.enabled_resources << Spree::CustomDomain-- Spree::PermittedAttributes.store_attributes.push(- :import_products_from_store_id,- :import_payment_methods_from_store_id- )-- if defined?(Spree::Admin)- Spree.admin.partials.product_form_sidebar << 'spree/admin/products/form/stores'- end-- # Multi-store setup- # You need to set a wildcard `root_domain` on the store to enable multi-store setup- # all new stores will be created in a subdomain of the root domain, eg. store1.localhost, store2.localhost, etc.- Spree.root_domain = ENV.fetch('SPREE_ROOT_DOMAIN', 'localhost')-enddiff --git a/backend/engines/multi_store/config/initializers/spree_multi_store_navigation.rb b/backend/engines/multi_store/config/initializers/spree_multi_store_navigation.rbdeleted file mode 100644index 8277d78487..0000000000--- a/backend/engines/multi_store/config/initializers/spree_multi_store_navigation.rb+++ /dev/null@@ -1,14 +0,0 @@-Rails.application.config.after_initialize do- next unless defined?(Spree::Admin)-- settings_nav = Spree.admin.navigation.settings-- # Domains- settings_nav.add :domains,- label: :domains,- url: :admin_custom_domains_path,- icon: 'world-www',- position: 60,- active: -> { controller_name == 'custom_domains' },- if: -> { can?(:manage, Spree::CustomDomain) }-enddiff --git a/backend/engines/multi_store/config/locales/en.yml b/backend/engines/multi_store/config/locales/en.ymldeleted file mode 100644index 5b412bbd23..0000000000--- a/backend/engines/multi_store/config/locales/en.yml+++ /dev/null@@ -1,5 +0,0 @@-----en:- spree:- multi_store:- name: "Multi-Store"diff --git a/backend/engines/multi_store/config/routes.rb b/backend/engines/multi_store/config/routes.rbdeleted file mode 100644index b710ac890a..0000000000--- a/backend/engines/multi_store/config/routes.rb+++ /dev/null@@ -1,6 +0,0 @@-Spree::Core::Engine.add_routes do- namespace :admin, path: Spree.admin_path do- resources :stores, only: [:new, :create], controller: 'multi_store/stores'- resources :custom_domains, except: :show- end-enddiff --git a/backend/engines/multi_store/lib/spree/multi_store.rb b/backend/engines/multi_store/lib/spree/multi_store.rbdeleted file mode 100644index 2caa9ff4a5..0000000000--- a/backend/engines/multi_store/lib/spree/multi_store.rb+++ /dev/null@@ -1,2 +0,0 @@-require 'spree_core'-require 'spree/multi_store/engine'diff --git a/backend/engines/multi_store/lib/spree/multi_store/engine.rb b/backend/engines/multi_store/lib/spree/multi_store/engine.rbdeleted file mode 100644index 81fa807490..0000000000--- a/backend/engines/multi_store/lib/spree/multi_store/engine.rb+++ /dev/null@@ -1,22 +0,0 @@-module Spree- module MultiStore- class Engine < ::Rails::Engine- isolate_namespace Spree- engine_name 'spree_multi_store'-- # Rails 7.1 introduced a new feature that raises an error if a callback action is missing.- # We need to disable it as we use a lot of concerns that add callback actions.- initializer 'spree.multi_store.disable_raise_on_missing_callback_actions' do |app|- app.config.action_controller.raise_on_missing_callback_actions = false- end-- def self.activate- Dir.glob(File.join(File.dirname(__FILE__), '../../../app/**/*_decorator*.rb')) do |c|- Rails.configuration.cache_classes ? require(c) : load(c)- end- end-- config.to_prepare(&method(:activate).to_proc)- end- end-enddiff --git a/backend/engines/multi_store/lib/spree_multi_store.rb b/backend/engines/multi_store/lib/spree_multi_store.rbdeleted file mode 100644index fc752b8240..0000000000--- a/backend/engines/multi_store/lib/spree_multi_store.rb+++ /dev/null@@ -1 +0,0 @@-require 'spree/multi_store'diff --git a/backend/engines/multi_store/spec/controllers/spree/admin/custom_domains_controller_spec.rb b/backend/engines/multi_store/spec/controllers/spree/admin/custom_domains_controller_spec.rbdeleted file mode 100644index 5cba56d8d4..0000000000--- a/backend/engines/multi_store/spec/controllers/spree/admin/custom_domains_controller_spec.rb+++ /dev/null@@ -1,134 +0,0 @@-require 'spec_helper'--describe Spree::Admin::CustomDomainsController, type: :controller do- stub_authorization!-- render_views-- let(:store) { Spree::Store.default }-- describe '#index' do- subject { get :index, format: :html }-- it 'renders index template' do- subject- expect(response).to have_http_status(:ok)- expect(response).to render_template(:index)- end-- context 'with custom domains' do- let!(:custom_domain) { create(:custom_domain, store: store) }-- it 'renders index template' do- subject- expect(response).to have_http_status(:ok)- expect(response).to render_template(:index)- end- end- end-- describe '#new' do- subject { get :new, format: :html }-- it 'renders new template' do- subject- expect(response).to have_http_status(:ok)- expect(response).to render_template(:new)- end- end-- describe '#create' do- subject { post :create, params: params, format: :html }-- let(:params) do- {- custom_domain: {- url: 'test-domain.com',- }- }- end-- context 'with valid params' do- it 'creates a new custom domain' do- expect { subject }.to change(Spree::CustomDomain, :count).by(1)-- expect(response).to redirect_to(spree.admin_custom_domains_path)-- custom_domain = Spree::CustomDomain.last- expect(custom_domain.url).to eq('test-domain.com')- expect(custom_domain.store).to eq(store)- expect(custom_domain.default).to be_truthy- end- end-- context 'with invalid params' do- let(:params) do- {- custom_domain: {- url: ''- }- }- end-- it 'does not create a custom domain' do- expect { subject }.not_to change(Spree::CustomDomain, :count)-- expect(response).to have_http_status(:unprocessable_content)- expect(response).to render_template(:new)- end- end- end-- describe '#edit' do- subject { get :edit, params: { id: custom_domain.to_param } }-- let!(:custom_domain) { create(:custom_domain, store: store) }-- it 'renders edit template' do- subject- expect(response).to have_http_status(:ok)- expect(response).to render_template(:edit)- end- end-- describe '#update' do- subject { put :update, params: params }-- let!(:custom_domain) { create(:custom_domain, store: store) }-- let(:params) do- {- id: custom_domain.to_param,- custom_domain: {- url: 'updated-domain.com'- }- }- end-- context 'with valid params' do- it 'updates the custom domain' do- expect { subject }.to change { custom_domain.reload.url }.to('updated-domain.com')-- expect(response).to redirect_to(spree.admin_custom_domains_path)- end- end-- context 'with invalid params' do- let(:params) do- {- id: custom_domain.to_param,- custom_domain: {- url: ''- }- }- end-- it 'does not update the custom domain' do- expect { subject }.not_to change { custom_domain.reload.url }-- expect(response).to have_http_status(:unprocessable_content)- expect(response).to render_template(:edit)- end- end- end-enddiff --git a/backend/engines/multi_store/spec/controllers/spree/admin/multi_store/stores_controller_spec.rb b/backend/engines/multi_store/spec/controllers/spree/admin/multi_store/stores_controller_spec.rbdeleted file mode 100644index d3dabbf791..0000000000--- a/backend/engines/multi_store/spec/controllers/spree/admin/multi_store/stores_controller_spec.rb+++ /dev/null@@ -1,129 +0,0 @@-require 'spec_helper'--describe Spree::Admin::MultiStore::StoresController, type: :controller do- stub_authorization!- render_views-- let(:store) { Spree::Store.default }-- before do- allow(controller).to receive(:current_store).and_return(store)- allow(Spree).to receive(:root_domain).and_return('lvh.me')- end-- describe 'GET #new' do- subject { get :new }-- it 'renders the new template' do- subject- expect(response).to have_http_status(:ok)- end-- it 'initializes a new store' do- subject- expect(assigns(:store)).to be_a_new(Spree::Store)- end- end-- describe 'POST #create' do- subject { post :create, params: { store: store_params } }-- let!(:country) { Spree::Country.find_by(iso: 'US') || create(:country_us) }- let!(:zone) do- zone = create(:zone, name: 'US Zone', kind: 'country')- zone.zone_members.create!(zoneable: country)- create(:shipping_method, zones: [zone])- zone- end- let(:store_params) do- {- name: 'New Store',- default_country_iso: country.iso- }- end-- context 'with valid params' do- it 'creates a new store' do- expect { subject }.to change(Spree::Store, :count).by(1)- end-- it 'creates a default market with the selected country' do- subject- new_store = Spree::Store.last- expect(new_store.markets.count).to eq(1)-- market = new_store.markets.first- expect(market.name).to eq(country.name)- expect(market).to be_default- expect(market.countries).to include(country)- end-- it 'sets the mail_from_address from the current store' do- subject- expect(Spree::Store.last.mail_from_address).to eq(store.mail_from_address)- end-- it 'copies users to the new store' do- admin_user = create(:admin_user)- store.add_user(admin_user)-- subject-- new_store = Spree::Store.last- expect(new_store.users).to include(admin_user)- end-- it 'auto-generates URL from code and root_domain' do- subject- new_store = Spree::Store.last- expect(new_store.url).to include('lvh.me')- end-- it 'redirects to the getting started page on the new store' do- subject- new_store = Spree::Store.last- expect(response).to redirect_to(spree.admin_getting_started_url(host: new_store.url))- end- end-- context 'without country' do- let(:store_params) { { name: 'Store Without Country' } }-- it 'creates the store without a market' do- expect { subject }.to change(Spree::Store, :count).by(1)- expect(Spree::Store.last.markets.count).to eq(0)- end- end-- context 'with invalid params' do- let(:store_params) { { name: '' } }-- it 'does not create a store' do- expect { subject }.not_to change(Spree::Store, :count)- end-- it 'renders the new template' do- subject- expect(response).to have_http_status(:unprocessable_content)- end- end-- context 'with import_products_from_store_id' do- let!(:product) { create(:product, stores: [store]) }-- let(:store_params) do- {- name: 'Store With Products',- default_country_iso: country.iso,- import_products_from_store_id: store.id- }- end-- it 'imports products from the source store' do- subject- new_store = Spree::Store.last- expect(new_store.products).to include(product)- end- end- end-enddiff --git a/backend/engines/multi_store/spec/features/spree/admin/settings/custom_domains_spec.rb b/backend/engines/multi_store/spec/features/spree/admin/settings/custom_domains_spec.rbdeleted file mode 100644index fd3f98f6a1..0000000000--- a/backend/engines/multi_store/spec/features/spree/admin/settings/custom_domains_spec.rb+++ /dev/null@@ -1,54 +0,0 @@-require 'spec_helper'--describe 'Custom Domains', type: :feature do- stub_authorization!- let(:store) { Spree::Store.default }-- it 'can change store URL' do- allow(Spree).to receive(:root_domain).and_return(nil)- visit spree.admin_custom_domains_path-- fill_in 'store[url]', with: 'new-url.com'- click_on 'Save'-- expect(store.reload.url).to eq('new-url.com')- end-- context 'when multi store is enabled' do- before do- allow(Spree).to receive(:root_domain).and_return('lvh.me')- end-- context 'without custom domains' do- it 'can change store code' do- visit spree.admin_custom_domains_path-- fill_in 'store[code]', with: 'new-code'- click_on 'Save'-- expect(page).to have_field('store[code]', with: 'new-code')- expect(page.current_url).to include('new-code')- end- end-- context 'with custom domains' do- let!(:custom_domain) { create(:custom_domain, store: store) }-- it 'cannot change store code' do- visit spree.admin_custom_domains_path-- expect(page).to have_field('store[code]', with: store.code, disabled: true)- end-- it 'can manage custom domains' do- visit spree.admin_custom_domains_path-- expect(page).to have_link('New domain')-- within_row(1) do- expect(page).to have_content(custom_domain.url)- end- end- end- end-enddiff --git a/backend/engines/multi_store/spec/finders/spree/stores/find_current_spec.rb b/backend/engines/multi_store/spec/finders/spree/stores/find_current_spec.rbdeleted file mode 100644index 345215b1d3..0000000000--- a/backend/engines/multi_store/spec/finders/spree/stores/find_current_spec.rb+++ /dev/null@@ -1,49 +0,0 @@-require 'spec_helper'--module Spree- describe Stores::FindCurrent do- subject { described_class.new(scope: scope, url: url).execute }-- let!(:store) { @default_store }- let!(:store_2) { create(:store, url: 'another.com', default_currency: 'GBP') }-- let(:scope) { nil }- let(:url) { nil }-- before do- Spree::Current.store = nil- end-- context 'no arguments' do- it { expect(subject).to eq(store) }- it { subject; expect(Spree::Current.store).to eq(store) }- end-- context 'existing store' do- let(:url) { 'another.com' }-- it { expect(subject).to eq(store_2) }- it { subject; expect(Spree::Current.store).to eq(store_2) }- end-- context 'non-existing store' do- let(:url) { 'something-different.com' }-- it { expect(subject).to eq(store) }- end-- context 'with scope' do- let(:scope) { Spree::Store.where(default_currency: 'GBP') }- let(:url) { 'another.com' }-- it { expect(subject).to eq(store_2) }- end-- context 'with custom domain' do- let(:url) { 'shop.getvendo.com' }- let!(:custom_domain) { create(:custom_domain, url: url, store: store_2) }-- it { expect(subject).to eq(store_2) }- end- end-enddiff --git a/backend/engines/multi_store/spec/helpers/spree/admin/multi_store_helper_spec.rb b/backend/engines/multi_store/spec/helpers/spree/admin/multi_store_helper_spec.rbdeleted file mode 100644index d76c6904c7..0000000000--- a/backend/engines/multi_store/spec/helpers/spree/admin/multi_store_helper_spec.rb+++ /dev/null@@ -1,38 +0,0 @@-require 'spec_helper'--RSpec.describe Spree::Admin::MultiStoreHelper, type: :helper do- describe '#available_stores' do- let(:user) { create(:admin_user) }- let!(:store1) { create(:store, name: 'Store 1') }- let!(:store2) { create(:store, name: 'Store 2') }- let!(:store3) { create(:store, name: 'Store 3') }-- before do- allow(helper).to receive(:current_ability).and_return(Spree::Ability.new(user))- end-- context 'when user can manage all stores' do- before do- allow_any_instance_of(Spree::Ability).to receive(:can?).with(:manage, Spree::Store).and_return(true)- end-- it 'returns all stores accessible by current ability' do- expect(helper.available_stores).to include(store1, store2, store3)- end- end-- context 'when user has limited store access' do- before do- allow(Spree::Store).to receive(:accessible_by)- .with(kind_of(Spree::Ability), :manage)- .and_return(Spree::Store.where(id: [store1.id, store2.id]))- end-- it 'returns only accessible stores' do- available = helper.available_stores- expect(available).to include(store1, store2)- expect(available).not_to include(store3)- end- end- end-enddiff --git a/backend/engines/multi_store/spec/models/spree/custom_domain_spec.rb b/backend/engines/multi_store/spec/models/spree/custom_domain_spec.rbdeleted file mode 100644index c8e989b75b..0000000000--- a/backend/engines/multi_store/spec/models/spree/custom_domain_spec.rb+++ /dev/null@@ -1,42 +0,0 @@-require 'spec_helper'--RSpec.describe Spree::CustomDomain, type: :model do- let!(:store) { @default_store }-- describe 'Validations' do- describe '#sanitize_url' do- let(:custom_domain) { build(:custom_domain, url: 'https://shop.custom.domain ') }-- it 'removes https:// and http:// from the url' do- custom_domain.valid?- expect(custom_domain.url).to eq('shop.custom.domain')- end- end-- describe '#url_is_valid' do- it 'is valid with valid url' do- expect(build(:custom_domain, url: 'shop.custom.domain')).to be_valid- end-- it 'is valid with composed tlds' do- expect(build(:custom_domain, url: 'shop.domain.com.br')).to be_valid- end-- it 'is invalid with wrong number of parts' do- expect(build(:custom_domain, url: 'com')).not_to be_valid- end- end- end-- describe 'Callbacks' do- let(:store) { create(:store) }- let(:custom_domain) { build(:custom_domain, store: store) }-- describe 'touch store' do- it 'touches the store when the custom domain is created' do- expect(store).to receive(:touch)- custom_domain.save!- end- end- end-enddiff --git a/backend/engines/multi_store/spec/models/spree/store/multi_store_methods_spec.rb b/backend/engines/multi_store/spec/models/spree/store/multi_store_methods_spec.rbdeleted file mode 100644index f8660c095a..0000000000--- a/backend/engines/multi_store/spec/models/spree/store/multi_store_methods_spec.rb+++ /dev/null@@ -1,295 +0,0 @@-require 'spec_helper'--RSpec.describe Spree::Store::MultiStoreMethods, type: :model do- let!(:default_store) { @default_store }-- before do- allow(Spree).to receive(:root_domain).and_return('mydomain.dev')- end-- describe 'URL-based store resolution' do- # Use a URL that won't substring-match via LIKE with other test URLs- let!(:store_2) { create(:store, url: 'mystore.test') }-- before { Spree::Current.store = nil }-- describe '.by_url' do- it 'finds stores matching URL' do- expect(Spree::Store.by_url('mystore.test')).to include(store_2)- end-- it 'finds stores matching partial URL via LIKE' do- expect(Spree::Store.by_url('mystore.test')).to include(store_2)- end-- it 'does not return non-matching stores' do- expect(Spree::Store.by_url('nomatch.xyz')).not_to include(store_2)- end- end-- describe '.by_custom_domain' do- let!(:custom_domain) { create(:custom_domain, store: store_2, url: 'myshop.com') }-- it 'finds store by custom domain' do- expect(Spree::Store.by_custom_domain('myshop.com')).to include(store_2)- end-- it 'does not return non-matching stores' do- expect(Spree::Store.by_custom_domain('nomatch.xyz')).not_to include(store_2)- end- end-- describe '.current' do- it 'resolves store by URL via finder' do- expect(Spree::Store.current('mystore.test')).to eq(store_2)- end-- it 'falls back to default store for unknown URL' do- expect(Spree::Store.current('unknown.com')).to eq(default_store)- end-- it 'sets Spree::Current.store' do- Spree::Store.current('mystore.test')- expect(Spree::Current.store).to eq(store_2)- end-- context 'with custom domain' do- let!(:custom_domain) { create(:custom_domain, store: store_2, url: 'myshop.com') }-- it 'resolves store by custom domain' do- expect(Spree::Store.current('myshop.com')).to eq(store_2)- end- end- end- end-- describe 'custom domain associations' do- let(:store) { create(:store) }-- it 'has_many custom_domains' do- domain = create(:custom_domain, store: store)- expect(store.custom_domains).to include(domain)- end-- it 'returns default_custom_domain' do- # First domain created becomes default via ensure_default callback- first_domain = create(:custom_domain, store: store, url: 'first.com')- expect(first_domain.reload.default).to be true-- # Second domain is not default- second_domain = create(:custom_domain, store: store, url: 'second.com')- expect(second_domain.reload.default).to be false-- expect(store.reload.default_custom_domain).to eq(first_domain)- end-- it 'destroys custom domains when store is destroyed' do- create(:custom_domain, store: store)- expect { store.destroy }.to change(Spree::CustomDomain, :count).by(-1)- end- end-- describe '#url_or_custom_domain' do- let(:store) { create(:store, url: 'store.mysite.com') }-- context 'without custom domain' do- it 'returns the store url' do- expect(store.url_or_custom_domain).to eq('store.mysite.com')- end- end-- context 'with custom domain' do- let!(:domain) { create(:custom_domain, store: store, url: 'custom.shop.com') }-- it 'returns the custom domain url' do- # First custom domain becomes default via ensure_default callback- expect(domain.reload.default).to be true- expect(store.reload.url_or_custom_domain).to eq('custom.shop.com')- end- end- end-- describe 'product import on create' do- let!(:product) { create(:product, stores: [default_store]) }-- it 'imports products from source store' do- new_store = build(:store, import_products_from_store_id: default_store.id)- new_store.save!-- expect(new_store.products).to include(product)- end-- it 'does not import products when source store is not set' do- new_store = create(:store)- expect(new_store.products).to be_empty- end- end-- describe 'payment method import on create' do- let!(:payment_method) { create(:credit_card_payment_method, stores: [default_store]) }-- it 'imports payment methods from source store' do- new_store = build(:store, import_payment_methods_from_store_id: default_store.id)- new_store.save!-- expect(new_store.payment_methods).to include(payment_method)- end- end-- describe '#set_code (via set_default_code override)' do- let(:store) { build(:store, name: 'My Store', code: nil) }-- it 'generates code from name' do- store.valid?- expect(store.code).to eq('my-store')- end-- context 'when code is already set' do- let(:store) { build(:store, name: 'Store', code: 'custom-code') }-- it 'parameterizes the existing code' do- store.valid?- expect(store.code).to eq('custom-code')- end- end-- context 'when code is already taken' do- let!(:existing_store) { create(:store, code: 'store') }- let(:store) { build(:store, name: 'Store', code: existing_store.code) }-- it 'generates a unique code' do- store.valid?- expect(store.code).not_to eq(existing_store.code)- expect(store.code).to match(/store-\d+/)- end- end- end-- describe '#set_url' do- let(:store) { build(:store, code: 'my_store', url: nil) }-- context 'on create' do- it 'sets url from code and root domain' do- store.save!- expect(store.url).to eq('my_store.mydomain.dev')- end- end-- context 'on update with code change' do- let!(:store) { create(:store, code: 'my_store', url: 'my_store.mydomain.dev') }-- it 'updates url and keeps old code via FriendlyId history' do- expect(store.url).to eq('my_store.mydomain.dev')- store.update!(code: 'my_store_2')- expect(store.reload.url).to eq('my_store_2.mydomain.dev')- expect(Spree::Store.friendly.find('my_store').id).to eq(store.id)- end- end- end-- describe 'code validation' do- it 'auto-generates unique code when code is taken' do- existing = create(:store, code: 'store')- new_store = create(:store, name: 'Store', code: existing.code)- expect(new_store.persisted?).to be true- expect(new_store.code).not_to eq(existing.code)- expect(new_store.code).to match(/store-\d+/)- end-- it 'cannot create a store with reserved code' do- store = build(:store, code: 'admin')- expect(store).not_to be_valid- expect(store.errors[:code]).to be_present- end- end-- describe '#ensure_default_exists_and_is_unique' do- it 'ensures there is only one default store' do- store_1 = create(:store, default: true)- store_2 = create(:store, default: true)-- store_1.reload- expect(store_1.default).to be false- expect(store_2.default).to be true- end-- it 'auto-sets default if no default store exists' do- Spree::Store.update_all(default: false)- store = create(:store)- expect(store.default).to be true- end-- context 'when store fails to save' do- let!(:store_1) { create(:store, default: true) }-- it 'does not change default flag of other stores' do- store_2 = build(:store, default: true, name: nil) # will fail validation- store_2.save-- store_1.reload- expect(store_1.default).to be true- end- end- end-- describe '#can_be_deleted?' do- it 'cannot delete the only store' do- Spree::Store.where.not(id: default_store.id).delete_all- expect(default_store.can_be_deleted?).to eq(false)- end-- it 'can delete when there are more than 1 stores' do- create(:store)- expect(default_store.can_be_deleted?).to eq(true)- end- end-- describe 'soft deletion with multi-store protection' do- context 'default store with multiple stores' do- let!(:store_to_destroy) { create(:store, default: true) }- let!(:another_store) { create(:store) }-- before { Spree::Store.where.not(id: [store_to_destroy.id, another_store.id]).delete_all }-- it 'can be deleted' do- expect { store_to_destroy.destroy }.to change(store_to_destroy, :deleted_at)- expect(store_to_destroy.deleted?).to eq(true)- end-- it 'passes default flag to other store' do- expect(another_store.default?).to eq(false)- store_to_destroy.destroy- expect(store_to_destroy.default?).to eq(false)- expect(another_store.reload.default?).to eq(true)- expect(Spree::Store.default).to eq(another_store)- end- end-- context 'single store' do- before { Spree::Store.where.not(id: default_store.id).delete_all }-- it 'cannot be deleted' do- expect { default_store.destroy! }.to raise_error(ActiveRecord::RecordNotDestroyed)- expect(default_store.errors.full_messages.to_sentence).to eq('Cannot destroy the only Store.')- end- end-- context 'non-default store' do- let!(:another_store) { create(:store) }-- it 'soft-deletes when destroy is called' do- another_store.destroy!- expect(another_store.deleted_at).not_to be_nil- end- end- end-- describe '.available_locales' do- let!(:store_en) { create(:store, default_locale: 'en', supported_locales: 'en,fr') }- let!(:store_de) { create(:store, default_locale: 'de', supported_locales: 'de') }-- it 'aggregates locales from all stores' do- expect(Spree::Store.available_locales).to contain_exactly('en', 'fr', 'de')- end- end-enddiff --git a/backend/engines/multi_store/spec/spec_helper.rb b/backend/engines/multi_store/spec/spec_helper.rbdeleted file mode 100644index 6566ffdc1f..0000000000--- a/backend/engines/multi_store/spec/spec_helper.rb+++ /dev/null@@ -1,88 +0,0 @@-if ENV['COVERAGE']- require 'simplecov'- require 'simplecov-cobertura'- SimpleCov.root(ENV.fetch('GITHUB_WORKSPACE', File.expand_path('../../..', __dir__)))- SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter- SimpleCov.start 'rails' do- add_group 'Libraries', 'lib/spree'-- add_filter '/app/views/'- add_filter '/bin/'- add_filter '/config/'- add_filter '/db/'- add_filter '/lib/generators/'- add_filter '/script/'- add_filter '/spec/'-- if ENV['COVERAGE_DIR']- shard = ENV.fetch('CI_SHARD', '1')- coverage_dir "#{ENV['COVERAGE_DIR']}/multi_store_#{shard}"- end- command_name "multi_store_shard_#{ENV.fetch('CI_SHARD', '1')}"- end-end--# This file is copied to ~/spec when you run 'ruby script/generate rspec'-# from the project root directory.-ENV['RAILS_ENV'] ||= 'test'--begin- require File.expand_path('../dummy/config/environment', __FILE__)-rescue LoadError- puts 'Could not load dummy application. Please ensure you have run `bundle exec rake test_app`'-end--require 'rspec/rails'-require 'database_cleaner/active_record'-require 'ffaker'--Dir['./spec/support/**/*.rb'].sort.each { |f| require f }--require 'spree/testing_support/factories'-require 'spree/testing_support/jobs'-require 'spree/testing_support/store'-require 'spree/testing_support/preferences'-require 'spree/testing_support/authorization_helpers'-require 'spree/testing_support/capybara_ext'-require 'spree/testing_support/controller_requests'-require 'spree/testing_support/url_helpers'-require 'spree/testing_support/kernel'-require 'spree/testing_support/rspec_retry_config'--RSpec.configure do |config|- config.color = true- config.default_formatter = 'progress'- config.fail_fast = ENV['FAIL_FAST'] || false- config.infer_spec_type_from_file_location!- config.mock_with :rspec- config.raise_errors_for_deprecations!-- # If you're not using ActiveRecord, or you'd prefer not to run each of your- # examples within a transaction, comment the following line or assign false- # instead of true.- config.use_transactional_fixtures = true-- config.before(:suite) do- Spree::Events.disable!- # Clean out the database state before the tests run- DatabaseCleaner.clean_with(:truncation)- end-- # Re-enable events for specs that need them- config.around(:each, events: true) do |example|- Spree::Events.enable { example.run }- end-- config.before(:each) do- reset_spree_preferences- end-- config.include FactoryBot::Syntax::Methods- config.include Spree::TestingSupport::Preferences- config.include Spree::TestingSupport::Kernel- config.include Spree::TestingSupport::UrlHelpers- config.include Spree::TestingSupport::ControllerRequests, type: :controller-- config.order = :random- Kernel.srand config.seed-enddiff --git a/backend/engines/multi_store/spree_multi_store.gemspec b/backend/engines/multi_store/spree_multi_store.gemspecdeleted file mode 100644index 068a73c409..0000000000--- a/backend/engines/multi_store/spree_multi_store.gemspec+++ /dev/null@@ -1,29 +0,0 @@-# encoding: UTF-8--require_relative '../core/lib/spree/core/version.rb'--Gem::Specification.new do |s|- s.platform = Gem::Platform::RUBY- s.name = 'spree_multi_store'- s.version = Spree.version- s.authors = ['Vendo Connect Inc.', 'Vendo Sp. z o.o.']- s.email = '[email protected]'- s.summary = 'Multi-store switching and resolution for Spree Commerce'- s.description = 'Adds multi-store switching, custom domains, and store resolution to Spree Commerce'- s.homepage = 'https://spreecommerce.org'- s.licenses = ['AGPL-3.0-or-later']-- s.metadata = {- "bug_tracker_uri" => "https://github.com/spree/spree/issues",- "changelog_uri" => "https://github.com/spree/spree/releases/tag/v#{s.version}",- "documentation_uri" => "https://docs.spreecommerce.org/",- "source_code_uri" => "https://github.com/spree/spree/tree/v#{s.version}",- }-- s.required_ruby_version = '>= 3.2'-- s.files = Dir["{app,config,lib}/**/*", "LICENSE.md", "Rakefile", "README.md"]- s.require_path = 'lib'-- s.add_dependency 'spree', s.version-end