diff --git a/.rubocop.yml b/.rubocop.yml index d6fbb9d9..7f4dff49 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,9 +1,7 @@ -inherit_from: .rubocop_todo.yml - require: - solidus_dev_support/rubocop AllCops: TargetRubyVersion: 3.0 NewCops: disable - \ No newline at end of file + SuggestExtensions: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml deleted file mode 100644 index d00947fb..00000000 --- a/.rubocop_todo.yml +++ /dev/null @@ -1,154 +0,0 @@ -# This configuration was generated by -# `rubocop --auto-gen-config` -# on 2025-01-22 08:20:44 UTC using RuboCop version 1.70.0. -# The point is for the user to remove these configuration records -# one by one as the offenses are removed from the code base. -# Note that changes in the inspected code, or installation of new -# versions of RuboCop, may require this file to be generated again. - -# Offense count: 1 -# Configuration parameters: Severity, Include. -# Include: **/*.gemspec -Gemspec/RequiredRubyVersion: - Exclude: - - 'solidus_multi_domain.gemspec' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Layout/EmptyLineAfterGuardClause: - Exclude: - - 'app/decorators/controllers/solidus_multi_domain/taxons_controller_decorator.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. -Layout/ExtraSpacing: - Exclude: - - 'lib/generators/solidus_multi_domain/install/templates/sample_data/taxonomies.rb' - -# Offense count: 2 -# Configuration parameters: AllowedMethods. -# AllowedMethods: enums -Lint/ConstantDefinitionInBlock: - Exclude: - - 'spec/requests/template_renderer_spec.rb' - -# Offense count: 3 -Naming/AccessorMethodName: - Exclude: - - 'app/decorators/helpers/solidus_multi_domain/spree/products_helper_decorator.rb' - - 'app/models/spree/search/multi_domain.rb' - - 'lib/solidus_multi_domain/multi_domain_helpers.rb' - -# Offense count: 5 -# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns. -# SupportedStyles: snake_case, normalcase, non_integer -# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64 -Naming/VariableNumber: - Exclude: - - 'spec/controllers/products_controller_spec.rb' - - 'spec/models/spree/store_spec.rb' - - 'spec/requests/spree/api/products_controller_spec.rb' - -# Offense count: 2 -RSpec/BeforeAfterAll: - Exclude: - - 'spec/requests/template_renderer_spec.rb' - -# Offense count: 8 -# Configuration parameters: Prefixes, AllowedPatterns. -# Prefixes: when, with, without -RSpec/ContextWording: - Exclude: - - 'spec/controllers/spree/api/line_items_controller_spec.rb' - - 'spec/controllers/spree/api/shipments_controller_spec.rb' - - 'spec/models/spree/line_item_spec.rb' - - 'spec/models/spree/taxon_decorator_spec.rb' - - 'spec/requests/template_renderer_spec.rb' - -# Offense count: 3 -# Configuration parameters: IgnoredMetadata. -RSpec/DescribeClass: - Exclude: - - 'spec/lib/spree_multi_domain/testing_support/factory_overrides_spec.rb' - - 'spec/requests/global_controller_helpers_spec.rb' - - 'spec/requests/template_renderer_spec.rb' - -# Offense count: 1 -RSpec/DescribeSymbol: - Exclude: - - 'spec/requests/spree/api/products_controller_spec.rb' - -# Offense count: 15 -# Configuration parameters: AssignmentOnly. -RSpec/InstanceVariable: - Exclude: - - 'spec/controllers/spree/admin/products_controller_spec.rb' - - 'spec/models/spree/product_spec.rb' - - 'spec/requests/template_renderer_spec.rb' - -# Offense count: 2 -RSpec/LeakyConstantDeclaration: - Exclude: - - 'spec/requests/template_renderer_spec.rb' - -# Offense count: 4 -RSpec/LetSetup: - Exclude: - - 'spec/controllers/products_controller_spec.rb' - - 'spec/requests/global_controller_helpers_spec.rb' - -# Offense count: 7 -RSpec/MultipleExpectations: - Max: 4 - -# Offense count: 4 -# Configuration parameters: AllowSubject. -RSpec/MultipleMemoizedHelpers: - Max: 6 - -# Offense count: 10 -# Configuration parameters: EnforcedStyle, IgnoreSharedExamples. -# SupportedStyles: always, named_only -RSpec/NamedSubject: - Exclude: - - 'spec/controllers/spree/api/line_items_controller_spec.rb' - - 'spec/controllers/spree/api/shipments_controller_spec.rb' - - 'spec/models/spree/line_item_spec.rb' - - 'spec/requests/spree/api/products_controller_spec.rb' - -# Offense count: 4 -# Configuration parameters: AllowedGroups. -RSpec/NestedGroups: - Max: 4 - -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: Whitelist, AllowedMethods, AllowedReceivers. -# Whitelist: find_by_sql, find_by_token_for -# AllowedMethods: find_by_sql, find_by_token_for -# AllowedReceivers: Gem::Specification, page -Rails/DynamicFindBy: - Exclude: - - 'app/decorators/controllers/solidus_multi_domain/taxons_controller_decorator.rb' - -# Offense count: 1 -# Configuration parameters: Include. -# Include: app/controllers/**/*.rb, app/mailers/**/*.rb -Rails/LexicallyScopedActionFilter: - Exclude: - - 'app/controllers/concerns/solidus_multi_domain/show_product_support.rb' - -# Offense count: 1 -# Configuration parameters: ForbiddenMethods, AllowedMethods. -# ForbiddenMethods: decrement!, decrement_counter, increment!, increment_counter, insert, insert!, insert_all, insert_all!, toggle!, touch, touch_all, update_all, update_attribute, update_column, update_columns, update_counters, upsert, upsert_all -Rails/SkipsModelValidations: - Exclude: - - 'app/decorators/helpers/solidus_multi_domain/spree/core/controller_helpers/order_decorator.rb' - -# Offense count: 11 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings. -# URISchemes: http, https -Layout/LineLength: - Max: 339 diff --git a/.standard.yml b/.standard.yml new file mode 100644 index 00000000..c57b8951 --- /dev/null +++ b/.standard.yml @@ -0,0 +1,5 @@ +parallel: true # default: false +format: progress # default: Standard::Formatter +ignore: + - "dummy-app/**/*" + - "sandbox/**/*" diff --git a/Gemfile b/Gemfile index 189fd4d5..12327baa 100644 --- a/Gemfile +++ b/Gemfile @@ -1,36 +1,34 @@ # frozen_string_literal: true -source 'https://rubygems.org' +source "https://rubygems.org" git_source(:github) { |repo| "https://github.com/#{repo}.git" } -branch = ENV.fetch('SOLIDUS_BRANCH', 'main') -gem 'solidus', github: 'solidusio/solidus', branch: branch +branch = ENV.fetch("SOLIDUS_BRANCH", "main") +gem "solidus", github: "solidusio/solidus", branch: branch # Needed to help Bundler figure out how to resolve dependencies, # otherwise it takes forever to resolve them. # See https://github.com/bundler/bundler/issues/6677 -gem 'rails', '>0.a' - -gem 'rubocop-rails-omakase' +gem "rails", ">0.a" # Provides basic authentication functionality for testing parts of your engine -gem 'solidus_auth_devise' +gem "solidus_auth_devise" -case ENV['DB'] -when 'mysql' - gem 'mysql2' -when 'postgresql' - gem 'pg' +case ENV["DB"] +when "mysql" + gem "mysql2" +when "postgresql" + gem "pg" else - gem 'sqlite3' + gem "sqlite3" end group :test do - gem 'rails-controller-testing' + gem "rails-controller-testing" end gemspec # Use a local Gemfile to include development dependencies that might not be # relevant for the project or for other contributors, e.g.: `gem 'pry-debug'`. -send :eval_gemfile, 'Gemfile-local' if File.exist? 'Gemfile-local' +send :eval_gemfile, "Gemfile-local" if File.exist? "Gemfile-local" diff --git a/Rakefile b/Rakefile index 079e7e91..f886863a 100644 --- a/Rakefile +++ b/Rakefile @@ -1,12 +1,12 @@ # frozen_string_literal: true require "bundler/gem_tasks" -require 'solidus_dev_support/rake_tasks' +require "solidus_dev_support/rake_tasks" SolidusDevSupport::RakeTasks.install task :default do - require 'bundler' + require "bundler" Bundler.with_unbundled_env do - sh 'bin/rspec' + sh "bin/rspec" end end diff --git a/app/controllers/concerns/solidus_multi_domain/create_line_item_support.rb b/app/controllers/concerns/solidus_multi_domain/create_line_item_support.rb index 6106f43b..4789d69f 100644 --- a/app/controllers/concerns/solidus_multi_domain/create_line_item_support.rb +++ b/app/controllers/concerns/solidus_multi_domain/create_line_item_support.rb @@ -13,7 +13,7 @@ module InstanceMethods private def product_does_not_belong_to_store - render json: { message: I18n.t('spree.errors.products_from_different_stores_may_not_be_added_to_this_order') }, + render json: {message: I18n.t("spree.errors.products_from_different_stores_may_not_be_added_to_this_order")}, status: :unprocessable_entity end end diff --git a/app/controllers/spree/admin/stores_controller.rb b/app/controllers/spree/admin/stores_controller.rb index 7b09a3ca..014d1f18 100644 --- a/app/controllers/spree/admin/stores_controller.rb +++ b/app/controllers/spree/admin/stores_controller.rb @@ -8,7 +8,7 @@ class StoresController < Spree::Admin::ResourceController def index @stores = @stores.ransack(name_or_domains_or_code_cont: params[:q]).result if params[:q] - @stores = @stores.where(id: params[:ids].split(',')) if params[:ids] + @stores = @stores.where(id: params[:ids].split(",")) if params[:ids] respond_with(@stores) do |format| format.html diff --git a/app/decorators/components/solidus_multi_domain/taxons_tree_component_decorator.rb b/app/decorators/components/solidus_multi_domain/taxons_tree_component_decorator.rb index 9963d54c..8126c070 100644 --- a/app/decorators/components/solidus_multi_domain/taxons_tree_component_decorator.rb +++ b/app/decorators/components/solidus_multi_domain/taxons_tree_component_decorator.rb @@ -17,7 +17,7 @@ def tree(root_taxon:, item_classes:, current_item_classes:, max_level:) classes = item_classes if current_item_classes && current_taxon&.self_and_ancestors&.include?(taxon) classes = [classes, - current_item_classes].join(' ') + current_item_classes].join(" ") end content_tag :li, class: classes do diff --git a/app/decorators/controllers/solidus_multi_domain/products_controller_decorator.rb b/app/decorators/controllers/solidus_multi_domain/products_controller_decorator.rb index 32855c72..03de3759 100644 --- a/app/decorators/controllers/solidus_multi_domain/products_controller_decorator.rb +++ b/app/decorators/controllers/solidus_multi_domain/products_controller_decorator.rb @@ -7,11 +7,11 @@ def self.prepended(base) end def show - @variants = @product. - variants_including_master. - display_includes. - with_prices(current_pricing_options). - includes([:option_values, :images]) + @variants = @product + .variants_including_master + .display_includes + .with_prices(current_pricing_options) + .includes([:option_values, :images]) @taxonomies = get_taxonomies @product_properties = @product.product_properties.includes(:property) @taxon = Spree::Taxon.find(params[:taxon_id]) if params[:taxon_id] diff --git a/app/decorators/controllers/solidus_multi_domain/spree/api/shipments_controller_decorator.rb b/app/decorators/controllers/solidus_multi_domain/spree/api/shipments_controller_decorator.rb index 6aae0e68..8c3b97c4 100644 --- a/app/decorators/controllers/solidus_multi_domain/spree/api/shipments_controller_decorator.rb +++ b/app/decorators/controllers/solidus_multi_domain/spree/api/shipments_controller_decorator.rb @@ -10,7 +10,7 @@ def self.prepended(base) def mine super - @shipments = @shipments.where(spree_orders: { store_id: current_store.id }) if @shipments + @shipments = @shipments.where(spree_orders: {store_id: current_store.id}) if @shipments end ::Spree::Api::ShipmentsController.prepend(self) if SolidusMultiDomain::Engine.api_available? diff --git a/app/decorators/controllers/solidus_multi_domain/users_controller_decorator.rb b/app/decorators/controllers/solidus_multi_domain/users_controller_decorator.rb index 9870b826..b1c0d1f2 100644 --- a/app/decorators/controllers/solidus_multi_domain/users_controller_decorator.rb +++ b/app/decorators/controllers/solidus_multi_domain/users_controller_decorator.rb @@ -4,7 +4,7 @@ module SolidusMultiDomain module UsersControllerDecorator def show load_object - @orders = @user.orders.complete.by_store(current_store).order('completed_at desc') + @orders = @user.orders.complete.by_store(current_store).order("completed_at desc") end ::UsersController.prepend(self) diff --git a/app/decorators/helpers/solidus_multi_domain/spree/products_helper_decorator.rb b/app/decorators/helpers/solidus_multi_domain/spree/products_helper_decorator.rb index 259b3d2f..fe02b54c 100644 --- a/app/decorators/helpers/solidus_multi_domain/spree/products_helper_decorator.rb +++ b/app/decorators/helpers/solidus_multi_domain/spree/products_helper_decorator.rb @@ -7,11 +7,11 @@ def self.prepended(base) base.module_eval do def get_taxonomies @taxonomies ||= if current_store.present? - ::Spree::Taxonomy.where(["store_id = ?", - current_store.id]) - else - ::Spree::Taxonomy - end + ::Spree::Taxonomy.where(["store_id = ?", + current_store.id]) + else + ::Spree::Taxonomy + end @taxonomies = @taxonomies.includes(root: :children) @taxonomies end diff --git a/app/decorators/helpers/solidus_multi_domain/spree/taxons_helper_decorator.rb b/app/decorators/helpers/solidus_multi_domain/spree/taxons_helper_decorator.rb index debfa831..8ff04fcc 100644 --- a/app/decorators/helpers/solidus_multi_domain/spree/taxons_helper_decorator.rb +++ b/app/decorators/helpers/solidus_multi_domain/spree/taxons_helper_decorator.rb @@ -9,25 +9,25 @@ def taxon_preview(taxon, max = 4) price_scope = ::Spree::Price.where(current_pricing_options.search_arguments) products = taxon.active_products - .joins(:stores) - .where("spree_products_stores.store_id = ?", current_store.id) - .joins(:prices) - .merge(price_scope) - .select("DISTINCT spree_products.*, spree_products_taxons.position") - .limit(max) + .joins(:stores) + .where("spree_products_stores.store_id = ?", current_store.id) + .joins(:prices) + .merge(price_scope) + .select("DISTINCT spree_products.*, spree_products_taxons.position") + .limit(max) if products.size < max products_arel = ::Spree::Product.arel_table taxon.descendants.each do |descendent_taxon| to_get = max - products.length products += descendent_taxon.active_products - .joins(:stores) - .where("spree_products_stores.store_id = ?", current_store.id) - .joins(:prices) - .merge(price_scope) - .select("DISTINCT spree_products.*, spree_products_taxons.position") - .where(products_arel[:id].not_in(products.map(&:id))) - .limit(to_get) + .joins(:stores) + .where("spree_products_stores.store_id = ?", current_store.id) + .joins(:prices) + .merge(price_scope) + .select("DISTINCT spree_products.*, spree_products_taxons.position") + .where(products_arel[:id].not_in(products.map(&:id))) + .limit(to_get) break if products.size >= max end end diff --git a/app/decorators/lib/solidus_multi_domain/action_view/template_renderer_decorator.rb b/app/decorators/lib/solidus_multi_domain/action_view/template_renderer_decorator.rb index 74642b85..0743216f 100644 --- a/app/decorators/lib/solidus_multi_domain/action_view/template_renderer_decorator.rb +++ b/app/decorators/lib/solidus_multi_domain/action_view/template_renderer_decorator.rb @@ -3,7 +3,7 @@ module SolidusMultiDomain module ActionView module TemplateRendererDecorator - if Rails.gem_version >= Gem::Version.new('6.0.0') + if Rails.gem_version >= Gem::Version.new("6.0.0") def render_template(view, template, layout_name, locals) @view = view super @@ -14,20 +14,20 @@ def find_layout(layout, *args) return if api_request? if @view.respond_to?(:current_store) && layout.present? && - @view.current_store && !@view.controller.is_a?(::Spree::Admin::BaseController) + @view.current_store && !@view.controller.is_a?(::Spree::Admin::BaseController) store_layout = if layout.is_a?(String) - layout.gsub("layouts/", "layouts/#{@view.current_store.code}/") - else - layout.call.try(:gsub, "layouts/", "layouts/#{@view.current_store.code}/") - end + layout.gsub("layouts/", "layouts/#{@view.current_store.code}/") + else + layout.call.try(:gsub, "layouts/", "layouts/#{@view.current_store.code}/") + end begin super(store_layout, *args) rescue ::ActionView::MissingTemplate - super(layout, *args) + super end else - super(layout, *args) + super end end @@ -37,7 +37,7 @@ def controller_name end def api_request? - true if controller_name.include?('::Api::') + true if controller_name.include?("::Api::") end ::ActionView::TemplateRenderer.prepend self diff --git a/app/decorators/models/solidus_multi_domain/spree/product_decorator.rb b/app/decorators/models/solidus_multi_domain/spree/product_decorator.rb index bb08d95d..125edd2e 100644 --- a/app/decorators/models/solidus_multi_domain/spree/product_decorator.rb +++ b/app/decorators/models/solidus_multi_domain/spree/product_decorator.rb @@ -5,7 +5,7 @@ module Spree module ProductDecorator def self.prepended(base) base.class_eval do - has_and_belongs_to_many :stores, join_table: 'spree_products_stores' + has_and_belongs_to_many :stores, join_table: "spree_products_stores" scope :by_store, lambda { |store| joins(:stores).where("spree_products_stores.store_id = ?", store) } end diff --git a/app/decorators/models/solidus_multi_domain/spree/store_decorator.rb b/app/decorators/models/solidus_multi_domain/spree/store_decorator.rb index 1da383ae..93ed3bc8 100644 --- a/app/decorators/models/solidus_multi_domain/spree/store_decorator.rb +++ b/app/decorators/models/solidus_multi_domain/spree/store_decorator.rb @@ -5,22 +5,22 @@ module Spree module StoreDecorator def self.prepended(base) base.class_eval do - has_and_belongs_to_many :products, join_table: 'spree_products_stores' + has_and_belongs_to_many :products, join_table: "spree_products_stores" has_many :taxonomies has_many :orders has_many :store_shipping_methods has_many :shipping_methods, through: :store_shipping_methods - has_and_belongs_to_many :promotion_rules, class_name: 'Spree::Promotion::Rules::Store', - join_table: 'spree_promotion_rules_stores', association_foreign_key: 'promotion_rule_id' + has_and_belongs_to_many :promotion_rules, class_name: "Spree::Promotion::Rules::Store", + join_table: "spree_promotion_rules_stores", association_foreign_key: "promotion_rule_id" has_attached_file :logo, - styles: { mini: '48x48>', small: '100x100>', medium: '250x250>' }, + styles: {mini: "48x48>", small: "100x100>", medium: "250x250>"}, default_style: :medium, - url: '/spree/stores/:id/:style/:basename.:extension', - path: ':rails_root/public/spree/stores/:id/:style/:basename.:extension', - convert_options: { all: '-strip -auto-orient' } + url: "/spree/stores/:id/:style/:basename.:extension", + path: ":rails_root/public/spree/stores/:id/:style/:basename.:extension", + convert_options: {all: "-strip -auto-orient"} validates_attachment_file_name :logo, matches: [/png\Z/i, /jpe?g\Z/i], if: -> { respond_to?(:logo_file_name) } diff --git a/bin/dummy-app b/bin/dummy-app index 9c08a661..d18c58d3 100755 --- a/bin/dummy-app +++ b/bin/dummy-app @@ -13,6 +13,14 @@ function unbundled { test "$DB" = "sqlite" && export DB="sqlite3" rm -rf ./dummy-app + +mkdir -p dummy-app/app/assets/config +cat < dummy-app/app/assets/config/manifest.js +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css +MANIFEST + rails_version=`bundle exec ruby -e'require "rails"; puts Rails.version'` rails _${rails_version}_ new dummy-app \ --database=${DB:-sqlite3} \ diff --git a/bin/sandbox b/bin/sandbox index 47cd7325..d0967278 100755 --- a/bin/sandbox +++ b/bin/sandbox @@ -33,6 +33,14 @@ function unbundled { } rm -rf ./sandbox + +mkdir -p sandbox/app/assets/config +cat < sandbox/app/assets/config/manifest.js +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css +MANIFEST + rails new sandbox \ --database="$RAILSDB" \ --skip-git \ diff --git a/db/migrate/20091202123245_add_order_store.rb b/db/migrate/20091202123245_add_order_store.rb index 3b2681df..13ca78b5 100644 --- a/db/migrate/20091202123245_add_order_store.rb +++ b/db/migrate/20091202123245_add_order_store.rb @@ -2,17 +2,17 @@ class AddOrderStore < SolidusSupport::Migration[4.2] def self.up - if table_exists?('orders') + if table_exists?("orders") add_column :orders, :store_id, :integer - elsif table_exists?('spree_orders') + elsif table_exists?("spree_orders") add_column :spree_orders, :store_id, :integer unless column_exists?(:spree_orders, :store_id) end end def self.down - if table_exists?('orders') + if table_exists?("orders") remove_column :orders, :store_id - elsif table_exists?('spree_orders') + elsif table_exists?("spree_orders") remove_column :spree_orders, :store_id end end diff --git a/db/migrate/20100616204303_store_id_for_taxonomies.rb b/db/migrate/20100616204303_store_id_for_taxonomies.rb index 8f96e257..55579b76 100644 --- a/db/migrate/20100616204303_store_id_for_taxonomies.rb +++ b/db/migrate/20100616204303_store_id_for_taxonomies.rb @@ -2,19 +2,19 @@ class StoreIdForTaxonomies < SolidusSupport::Migration[4.2] def self.up - if table_exists?('taxonomies') + if table_exists?("taxonomies") add_column :taxonomies, :store_id, :integer add_index :taxonomies, :store_id - elsif table_exists?('spree_taxonomies') + elsif table_exists?("spree_taxonomies") add_column :spree_taxonomies, :store_id, :integer add_index :spree_taxonomies, :store_id end end def self.down - if table_exists?('taxonomies') + if table_exists?("taxonomies") remove_column :taxonomies, :store_id - elsif table_exists?('spree_taxonomies') + elsif table_exists?("spree_taxonomies") remove_column :spree_taxonomies, :store_id end end diff --git a/lib/components/admin/solidus_multi_domain/orders/index/component.rb b/lib/components/admin/solidus_multi_domain/orders/index/component.rb index 72703366..ecd6f1e2 100644 --- a/lib/components/admin/solidus_multi_domain/orders/index/component.rb +++ b/lib/components/admin/solidus_multi_domain/orders/index/component.rb @@ -21,10 +21,10 @@ def store_column def filters super + [ { - label: t('.filters.promotions'), - combinator: 'or', + label: t(".filters.promotions"), + combinator: "or", attribute: promotion_attribute, - predicate: 'in', + predicate: "in", options: promotion_options } ] @@ -33,7 +33,7 @@ def filters private def promotion_attribute - Object.const_defined?('Spree::Promotion') ? 'promotions_id' : 'solidus_promotions_id' + Object.const_defined?("Spree::Promotion") ? "promotions_id" : "solidus_promotions_id" end def promotion_options @@ -41,7 +41,7 @@ def promotion_options end def promotion_class - if Object.const_defined?('Spree::Promotion') + if Object.const_defined?("Spree::Promotion") ::Spree::Promotion else ::SolidusPromotions::Promotion diff --git a/lib/generators/solidus_multi_domain/install/install_generator.rb b/lib/generators/solidus_multi_domain/install/install_generator.rb index f65c839a..cde2f016 100644 --- a/lib/generators/solidus_multi_domain/install/install_generator.rb +++ b/lib/generators/solidus_multi_domain/install/install_generator.rb @@ -7,13 +7,13 @@ class InstallGenerator < Rails::Generators::Base class_option :auto_copy_sample, type: :boolean, default: false class_option :specs, type: :string, enum: %w[all], hide: true - source_root File.expand_path('templates', __dir__) + source_root File.expand_path("templates", __dir__) def handle_solidus_sample_data - return unless File.read('Gemfile').include?('solidus_sample') + return unless File.read("Gemfile").include?("solidus_sample") - response = options[:auto_copy_sample] || ['', 'y', - 'Y'].include?(ask("Do you want to load sample data files? (y/n)")) + response = options[:auto_copy_sample] || ["", "y", + "Y"].include?(ask("Do you want to load sample data files? (y/n)")) if response say "Copying sample data files..." @@ -25,28 +25,28 @@ def handle_solidus_sample_data end def generate_specs - return unless options[:specs] == 'all' + return unless options[:specs] == "all" - spec_path = engine.root.join('spec') + spec_path = engine.root.join("spec") if spec_path.directory? - directory spec_path.to_s, 'spec' + directory spec_path.to_s, "spec" else say_status :error, "Spec directory not found: #{spec_path}", :red end end def add_migrations - run 'bin/rails railties:install:migrations FROM=solidus_multi_domain' + run "bin/rails railties:install:migrations FROM=solidus_multi_domain" end def run_migrations - run_migrations = options[:auto_run_migrations] || ['', 'y', - 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]')) + run_migrations = options[:auto_run_migrations] || ["", "y", + "Y"].include?(ask("Would you like to run the migrations now? [Y/n]")) if run_migrations - run 'bin/rails db:migrate' + run "bin/rails db:migrate" else - puts 'Skipping bin/rails db:migrate, don\'t forget to run it!' # rubocop:disable Rails/Output + puts "Skipping bin/rails db:migrate, don't forget to run it!" # rubocop:disable Rails/Output end end diff --git a/lib/generators/solidus_multi_domain/install/templates/sample_data/products.rb b/lib/generators/solidus_multi_domain/install/templates/sample_data/products.rb index c784a30a..76ddeb77 100644 --- a/lib/generators/solidus_multi_domain/install/templates/sample_data/products.rb +++ b/lib/generators/solidus_multi_domain/install/templates/sample_data/products.rb @@ -12,7 +12,7 @@ "Perferendis sed voluptatem error ipsam voluptatem esse ipsa incidunt. Doloremque quos ratione quia voluptas consequatur mollitia optio. Optio sed iure aut aliquid voluptatum facilis mollitia cum. Dignissimos in saepe consequatur et consequatur dolorem blanditiis.", "Necessitatibus optio quod ullam itaque quis corporis occaecati. Saepe harum voluptates consectetur rerum dolorum. Corrupti officiis reprehenderit quo excepturi cumque. Soluta eos perspiciatis aut et ea nulla amet dolores. Dolores distinctio nesciunt libero voluptas molestiae consequatur aut veritatis.", "Soluta sed error debitis repellendus et. Voluptates unde enim qui velit. Libero earum tenetur nulla similique temporibus quod repellendus quibusdam.", - "Recusandae animi deserunt provident dignissimos ullam harum alias et. Itaque dicta maxime consectetur ut nemo non voluptatem. Voluptatem ipsum ut culpa eaque dolores.", + "Recusandae animi deserunt provident dignissimos ullam harum alias et. Itaque dicta maxime consectetur ut nemo non voluptatem. Voluptatem ipsum ut culpa eaque dolores." ] default_attrs = { @@ -30,7 +30,7 @@ weight: 0.5, height: 20, width: 10, - depth: 5, + depth: 5 }, { name: "Solidus tote", @@ -41,7 +41,7 @@ weight: 0.5, height: 20, width: 10, - depth: 5, + depth: 5 }, { name: "Solidus hoodie", @@ -52,7 +52,7 @@ weight: 1, height: 20, width: 10, - depth: 5, + depth: 5 }, { name: "Solidus mug set", diff --git a/lib/generators/solidus_multi_domain/install/templates/sample_data/taxonomies.rb b/lib/generators/solidus_multi_domain/install/templates/sample_data/taxonomies.rb index f6faec6c..1a5f32a8 100644 --- a/lib/generators/solidus_multi_domain/install/templates/sample_data/taxonomies.rb +++ b/lib/generators/solidus_multi_domain/install/templates/sample_data/taxonomies.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true taxonomies = [ - { name: "Categories", store: Spree::Store.first! }, - { name: "Brands", store: Spree::Store.first! } + {name: "Categories", store: Spree::Store.first!}, + {name: "Brands", store: Spree::Store.first!} ] taxonomies.each do |taxonomy_attrs| diff --git a/lib/solidus_multi_domain.rb b/lib/solidus_multi_domain.rb index 988d9f19..d8bd6567 100644 --- a/lib/solidus_multi_domain.rb +++ b/lib/solidus_multi_domain.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require 'solidus_core' -require 'solidus_support' -require 'deface' +require "solidus_core" +require "solidus_support" +require "deface" -require 'solidus_multi_domain/version' -require 'solidus_multi_domain/create_line_item_support' -require 'solidus_multi_domain/multi_domain_helpers' -require 'solidus_multi_domain/show_product_support' -require 'solidus_multi_domain/engine' +require "solidus_multi_domain/version" +require "solidus_multi_domain/create_line_item_support" +require "solidus_multi_domain/multi_domain_helpers" +require "solidus_multi_domain/show_product_support" +require "solidus_multi_domain/engine" diff --git a/lib/solidus_multi_domain/create_line_item_support.rb b/lib/solidus_multi_domain/create_line_item_support.rb index 5c60e57b..8cfcf06a 100644 --- a/lib/solidus_multi_domain/create_line_item_support.rb +++ b/lib/solidus_multi_domain/create_line_item_support.rb @@ -6,7 +6,7 @@ def self.prepended(base) base.class_eval do rescue_from( SolidusMultiDomain::ProductDoesNotBelongToStoreError, - with: :product_does_not_belong_to_store, + with: :product_does_not_belong_to_store ) end end @@ -14,7 +14,7 @@ def self.prepended(base) private def product_does_not_belong_to_store - render json: { message: I18n.t('spree.errors.products_from_different_stores_may_not_be_added_to_this_order') }, + render json: {message: I18n.t("spree.errors.products_from_different_stores_may_not_be_added_to_this_order")}, status: :unprocessable_entity end end diff --git a/lib/solidus_multi_domain/engine.rb b/lib/solidus_multi_domain/engine.rb index 62fab2be..61d718e8 100644 --- a/lib/solidus_multi_domain/engine.rb +++ b/lib/solidus_multi_domain/engine.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'spree/core' +require "spree/core" module SolidusMultiDomain class Engine < Rails::Engine @@ -8,7 +8,7 @@ class Engine < Rails::Engine isolate_namespace ::Spree - engine_name 'solidus_multi_domain' + engine_name "solidus_multi_domain" # use rspec for tests config.generators do |g| @@ -31,11 +31,11 @@ def self.activate config.to_prepare(&method(:activate).to_proc) def self.admin_available? - const_defined?('::Spree::Backend::Engine') + const_defined?("::Spree::Backend::Engine") end def self.api_available? - const_defined?('::Spree::Api::Engine') + const_defined?("::Spree::Api::Engine") end end end diff --git a/lib/solidus_multi_domain/multi_domain_helpers.rb b/lib/solidus_multi_domain/multi_domain_helpers.rb index 48df1f1e..e24bc1eb 100644 --- a/lib/solidus_multi_domain/multi_domain_helpers.rb +++ b/lib/solidus_multi_domain/multi_domain_helpers.rb @@ -7,8 +7,8 @@ module MultiDomainHelpers included do include ::Spree::Core::ControllerHelpers::Store # current_store include ::Spree::Core::ControllerHelpers::Common # layout :get_layout - helper 'spree/products' - helper 'spree/taxons' + helper "spree/products" + helper "spree/taxons" before_action :add_current_store_id_to_params helper_method :current_store @@ -16,11 +16,11 @@ module MultiDomainHelpers def get_taxonomies @taxonomies ||= if current_store.present? - ::Spree::Taxonomy.where(["store_id = ?", - current_store.id]) - else - ::Spree::Taxonomy - end + ::Spree::Taxonomy.where(["store_id = ?", + current_store.id]) + else + ::Spree::Taxonomy + end @taxonomies = @taxonomies.includes(root: :children) @taxonomies end diff --git a/lib/solidus_multi_domain/version.rb b/lib/solidus_multi_domain/version.rb index eff2aa26..2ecfcf15 100644 --- a/lib/solidus_multi_domain/version.rb +++ b/lib/solidus_multi_domain/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module SolidusMultiDomain - VERSION = '2.0.0.alpha' + VERSION = "2.0.0.alpha" end diff --git a/solidus_multi_domain.gemspec b/solidus_multi_domain.gemspec index 26e8c4bd..471ea7cc 100644 --- a/solidus_multi_domain.gemspec +++ b/solidus_multi_domain.gemspec @@ -1,39 +1,38 @@ # frozen_string_literal: true -require_relative 'lib/solidus_multi_domain/version' +require_relative "lib/solidus_multi_domain/version" Gem::Specification.new do |spec| - spec.name = 'solidus_multi_domain' + spec.name = "solidus_multi_domain" spec.version = SolidusMultiDomain::VERSION - spec.authors = ['Solidus Team'] - spec.email = 'contact@solidus.io' + spec.authors = ["Solidus Team"] + spec.email = "contact@solidus.io" - spec.summary = 'Adds multiple site support to Solidus' - spec.description = 'Multiple Solidus stores on different domains - single unified backed for processing orders.' - spec.homepage = 'https://github.com/solidusio-contrib/solidus_multi_domain#readme' - spec.license = 'BSD-3-Clause' + spec.summary = "Adds multiple site support to Solidus" + spec.description = "Multiple Solidus stores on different domains - single unified backed for processing orders." + spec.homepage = "https://github.com/solidusio-contrib/solidus_multi_domain#readme" + spec.license = "BSD-3-Clause" - spec.metadata['homepage_uri'] = spec.homepage - spec.metadata['source_code_uri'] = 'https://github.com/solidusio-contrib/solidus_multi_domain' - spec.metadata['changelog_uri'] = 'https://github.com/solidusio-contrib/solidus_multi_domain/releases' + spec.metadata["homepage_uri"] = spec.homepage + spec.metadata["source_code_uri"] = "https://github.com/solidusio-contrib/solidus_multi_domain" + spec.metadata["changelog_uri"] = "https://github.com/solidusio-contrib/solidus_multi_domain/releases" - spec.required_ruby_version = Gem::Requirement.new('>= 2.4') + spec.required_ruby_version = Gem::Requirement.new(">= 2.4") # Specify which files should be added to the gem when it is released. # The `git ls-files -z` loads the files in the RubyGem that have been added into git. files = Dir.chdir(__dir__) { `git ls-files -z`.split("\x0") } spec.files = files.grep_v(%r{^(test|spec|features)/}) - spec.test_files = files.grep(%r{^(test|spec|features)/}) spec.bindir = "exe" spec.executables = files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.add_dependency 'deface', '~> 1.0' - spec.add_dependency 'solidus_core', ['>= 2.6.0', '< 5'] - spec.add_dependency 'solidus_support', '~> 0.5' + spec.add_dependency "deface", "~> 1.0" + spec.add_dependency "solidus_core", [">= 2.6.0", "< 5"] + spec.add_dependency "solidus_support", "~> 0.5" - spec.add_development_dependency 'coffee-rails' - spec.add_development_dependency 'sass-rails' - spec.add_development_dependency 'solidus_dev_support' + spec.add_development_dependency "coffee-rails" + spec.add_development_dependency "sass-rails" + spec.add_development_dependency "solidus_dev_support" end diff --git a/spec/controllers/products_controller_spec.rb b/spec/controllers/products_controller_spec.rb index 71ee0b0a..c7e57ddf 100644 --- a/spec/controllers/products_controller_spec.rb +++ b/spec/controllers/products_controller_spec.rb @@ -1,27 +1,27 @@ # frozen_string_literal: true -require 'solidus_multi_domain_spec_helper' +require "solidus_multi_domain_spec_helper" RSpec.describe ::ProductsController do let!(:product) { FactoryBot.create(:product) } - describe 'on :show to a product without any stores' do + describe "on :show to a product without any stores" do let!(:store) { FactoryBot.create(:store) } - it 'returns 404' do - if Spree.solidus_gem_version < Gem::Version.new('2.5.x') - get :show, params: { id: product.to_param } + it "returns 404" do + if Spree.solidus_gem_version < Gem::Version.new("2.5.x") + get :show, params: {id: product.to_param} expect(response.response_code).to eq 404 else expect { - get :show, params: { id: product.to_param } + get :show, params: {id: product.to_param} }.to raise_error(ActiveRecord::RecordNotFound) end end end # Regression test for #75 - describe 'on :show to a product in the wrong store' do + describe "on :show to a product in the wrong store" do let!(:store_1) { FactoryBot.create(:store) } let!(:store_2) { FactoryBot.create(:store) } @@ -29,30 +29,30 @@ product.stores << store_1 end - it 'returns 404' do + it "returns 404" do allow(controller).to receive_messages(current_store: store_2) - if Spree.solidus_gem_version < Gem::Version.new('2.5.x') - get :show, params: { id: product.to_param } + if Spree.solidus_gem_version < Gem::Version.new("2.5.x") + get :show, params: {id: product.to_param} expect(response.response_code).to eq 404 else expect { - get :show, params: { id: product.to_param } + get :show, params: {id: product.to_param} }.to raise_error(ActiveRecord::RecordNotFound) end end end - describe 'on :show to a product w/ store' do + describe "on :show to a product w/ store" do let!(:store) { FactoryBot.create(:store) } before do product.stores << store end - it 'returns 200' do + it "returns 200" do allow(controller).to receive_messages(current_store: store) - get :show, params: { id: product.to_param } + get :show, params: {id: product.to_param} expect(response.response_code).to eq 200 end diff --git a/spec/controllers/spree/admin/products_controller_spec.rb b/spec/controllers/spree/admin/products_controller_spec.rb index db6f1605..6d7c5b55 100644 --- a/spec/controllers/spree/admin/products_controller_spec.rb +++ b/spec/controllers/spree/admin/products_controller_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'solidus_multi_domain_spec_helper' +require "solidus_multi_domain_spec_helper" RSpec.describe Spree::Admin::ProductsController do routes { Spree::Core::Engine.routes } @@ -26,8 +26,8 @@ put :update, params: { id: @product.to_param, - product: { name: @product.name }, - update_store_ids: 'true' + product: {name: @product.name}, + update_store_ids: "true" } expect(@product.reload.store_ids).to be_empty @@ -39,8 +39,8 @@ put :update, params: { id: @product.to_param, - product: { name: @product.name, store_ids: [@store.id] }, - update_store_ids: 'true' + product: {name: @product.name, store_ids: [@store.id]}, + update_store_ids: "true" } expect(@product.reload.store_ids).to eq [@store.id] diff --git a/spec/controllers/spree/admin/stores_controller_spec.rb b/spec/controllers/spree/admin/stores_controller_spec.rb index 9f993dc0..7173e292 100644 --- a/spec/controllers/spree/admin/stores_controller_spec.rb +++ b/spec/controllers/spree/admin/stores_controller_spec.rb @@ -1,27 +1,27 @@ # frozen_string_literal: true -require 'solidus_multi_domain_spec_helper' +require "solidus_multi_domain_spec_helper" RSpec.describe Spree::Admin::StoresController do routes { Spree::Core::Engine.routes } stub_authorization! - describe '#index' do + describe "#index" do render_views - it 'renders' do + it "renders" do get :index expect(response).to be_successful end end - describe '#edit' do + describe "#edit" do render_views let(:store) { create(:store) } - it 'renders' do - get :edit, params: { id: store.to_param } + it "renders" do + get :edit, params: {id: store.to_param} expect(response).to be_successful end end diff --git a/spec/controllers/spree/api/line_items_controller_spec.rb b/spec/controllers/spree/api/line_items_controller_spec.rb index 8931742c..2cf109c6 100644 --- a/spec/controllers/spree/api/line_items_controller_spec.rb +++ b/spec/controllers/spree/api/line_items_controller_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'solidus_multi_domain_spec_helper' +require "solidus_multi_domain_spec_helper" RSpec.describe Spree::Api::LineItemsController do routes { Spree::Core::Engine.routes } @@ -9,7 +9,7 @@ end describe "POST create" do - subject { post :create, params: { line_item: line_item, order_id: line_item.order.number } } + subject { post :create, params: {line_item: line_item, order_id: line_item.order.number} } let(:user) { create(:user) } let(:current_api_user) { user } diff --git a/spec/controllers/spree/api/shipments_controller_spec.rb b/spec/controllers/spree/api/shipments_controller_spec.rb index 259386ea..5f0a2dc2 100644 --- a/spec/controllers/spree/api/shipments_controller_spec.rb +++ b/spec/controllers/spree/api/shipments_controller_spec.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true -require 'solidus_multi_domain_spec_helper' +require "solidus_multi_domain_spec_helper" RSpec.describe Spree::Api::ShipmentsController do routes { Spree::Core::Engine.routes } - describe '#mine' do + describe "#mine" do let!(:user) { FactoryBot.create(:user) } let!(:store1) { FactoryBot.create(:store) } let!(:store2) { FactoryBot.create(:store) } @@ -15,7 +15,7 @@ allow(controller).to receive_messages(current_api_user: user) end - it 'returns only shipments from the correct store' do + it "returns only shipments from the correct store" do FactoryBot.create(:shipment, order: order_from_store1) FactoryBot.create(:shipment, order: order_from_store2) @@ -34,7 +34,7 @@ end describe "PUT add" do - subject { put :add, params: { variant_id: variant.id, id: shipment.number, quantity: 1 } } + subject { put :add, params: {variant_id: variant.id, id: shipment.number, quantity: 1} } let(:current_api_user) { create(:admin_user) } let(:shipment) { create(:shipment) } diff --git a/spec/helpers/products_helper_decorator_spec.rb b/spec/helpers/products_helper_decorator_spec.rb index fe200c2c..1cdc0fe0 100644 --- a/spec/helpers/products_helper_decorator_spec.rb +++ b/spec/helpers/products_helper_decorator_spec.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true -require 'solidus_multi_domain_spec_helper' +require "solidus_multi_domain_spec_helper" module Spree RSpec.describe ProductsHelper do before do - @store = FactoryBot.create(:store) - @taxonomy = FactoryBot.create(:taxonomy, store: @store) + @store = FactoryBot.create(:store) + @taxonomy = FactoryBot.create(:taxonomy, store: @store) @taxonomy2 = FactoryBot.create(:taxonomy, store: FactoryBot.create(:store)) allow(helper).to receive(:current_store) { @store } diff --git a/spec/lib/spree_multi_domain/testing_support/factory_overrides_spec.rb b/spec/lib/spree_multi_domain/testing_support/factory_overrides_spec.rb index 21476ace..bbead52f 100644 --- a/spec/lib/spree_multi_domain/testing_support/factory_overrides_spec.rb +++ b/spec/lib/spree_multi_domain/testing_support/factory_overrides_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'solidus_multi_domain_spec_helper' +require "solidus_multi_domain_spec_helper" RSpec.describe "spree core factories should not raise ProductDoesNotBelongToStoreError" do it "is able to build a line_item" do diff --git a/spec/models/spree/line_item_spec.rb b/spec/models/spree/line_item_spec.rb index a37deb1b..58e6c18b 100644 --- a/spec/models/spree/line_item_spec.rb +++ b/spec/models/spree/line_item_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'solidus_multi_domain_spec_helper' +require "solidus_multi_domain_spec_helper" RSpec.describe Spree::LineItem do describe "before create" do @@ -8,9 +8,9 @@ let(:order_store) { create(:store) } let(:other_store) { create(:store) } - let(:order) { create(:order, store: order_store) } - let(:variant) { create(:variant, product: product) } - let(:line_item) { build(:line_item, order: order, product: product) } + let(:order) { create(:order, store: order_store) } + let(:variant) { create(:variant, product: product) } + let(:line_item) { build(:line_item, order: order, product: product) } context "the order does not have a store" do before do @@ -23,16 +23,16 @@ let(:product) { create(:product, stores: [order_store]) } - it 'does not raise an error' do - expect{ subject }.not_to raise_error + it "does not raise an error" do + expect { subject }.not_to raise_error end end context "the line item's product does not belong to the order's store" do let(:product) { create(:product, stores: [other_store]) } - it 'raises the correct error' do - expect{ subject }.to raise_error(SolidusMultiDomain::ProductDoesNotBelongToStoreError) + it "raises the correct error" do + expect { subject }.to raise_error(SolidusMultiDomain::ProductDoesNotBelongToStoreError) end end @@ -40,7 +40,7 @@ let(:product) { create(:product, stores: [order_store]) } it "does not raise an error" do - expect{ subject }.not_to raise_error + expect { subject }.not_to raise_error end end end diff --git a/spec/models/spree/order_spec.rb b/spec/models/spree/order_spec.rb index abdde6b1..83b9836f 100644 --- a/spec/models/spree/order_spec.rb +++ b/spec/models/spree/order_spec.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require 'solidus_multi_domain_spec_helper' +require "solidus_multi_domain_spec_helper" diff --git a/spec/models/spree/permission_sets/store_display_spec.rb b/spec/models/spree/permission_sets/store_display_spec.rb index 08eaa6fa..9f2ba139 100644 --- a/spec/models/spree/permission_sets/store_display_spec.rb +++ b/spec/models/spree/permission_sets/store_display_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'solidus_multi_domain_spec_helper' +require "solidus_multi_domain_spec_helper" RSpec.describe Spree::PermissionSets::StoreDisplay do subject { ability } diff --git a/spec/models/spree/permission_sets/store_management_spec.rb b/spec/models/spree/permission_sets/store_management_spec.rb index 2cbfb9e6..3cce937f 100644 --- a/spec/models/spree/permission_sets/store_management_spec.rb +++ b/spec/models/spree/permission_sets/store_management_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'solidus_multi_domain_spec_helper' +require "solidus_multi_domain_spec_helper" RSpec.describe Spree::PermissionSets::StoreManagement do subject { ability } diff --git a/spec/models/spree/product_spec.rb b/spec/models/spree/product_spec.rb index 1b7891d6..a175ebd8 100644 --- a/spec/models/spree/product_spec.rb +++ b/spec/models/spree/product_spec.rb @@ -1,16 +1,16 @@ # frozen_string_literal: true -require 'solidus_multi_domain_spec_helper' +require "solidus_multi_domain_spec_helper" RSpec.describe Spree::Product do before do @store = FactoryBot.create(:store) @product = FactoryBot.create(:product, stores: [@store]) - @product2 = FactoryBot.create(:product, slug: 'something else') + @product2 = FactoryBot.create(:product, slug: "something else") end - it 'correctlies find products by store' do + it "correctlies find products by store" do products_by_store = described_class.by_store(@store) expect(products_by_store).to include(@product) diff --git a/spec/models/spree/shipping_method_decorator_spec.rb b/spec/models/spree/shipping_method_decorator_spec.rb index 297bbe88..b522b9a6 100644 --- a/spec/models/spree/shipping_method_decorator_spec.rb +++ b/spec/models/spree/shipping_method_decorator_spec.rb @@ -1,16 +1,16 @@ # frozen_string_literal: true -require 'solidus_multi_domain_spec_helper' +require "solidus_multi_domain_spec_helper" RSpec.describe Spree::ShippingMethod do let(:shipping_method) { create :shipping_method } let(:order) { create :order, store: store } let(:store) { create :store } - describe '.store_match?' do + describe ".store_match?" do subject { shipping_method.store_match?(order) } - context 'when store contains this shipping method' do + context "when store contains this shipping method" do before { store.shipping_methods << shipping_method } it { is_expected.to eq(true) } diff --git a/spec/models/spree/store_spec.rb b/spec/models/spree/store_spec.rb index 0ca4c388..3e7c6545 100644 --- a/spec/models/spree/store_spec.rb +++ b/spec/models/spree/store_spec.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require 'solidus_multi_domain_spec_helper' +require "solidus_multi_domain_spec_helper" RSpec.describe Spree::Store do let!(:default_store) { FactoryBot.create(:store, default: true, url: "default.com") } - let!(:store_2) { FactoryBot.create(:store, code: 'STORE2', url: 'freethewhales.com') } - let!(:store_3) { FactoryBot.create(:store, code: 'STORE3', url: "website1.com\nwww.subdomain.com") } + let!(:store_2) { FactoryBot.create(:store, code: "STORE2", url: "freethewhales.com") } + let!(:store_3) { FactoryBot.create(:store, code: "STORE3", url: "website1.com\nwww.subdomain.com") } describe "default" do it "ensures there is a default if one doesn't exist yet" do diff --git a/spec/models/spree/taxon_decorator_spec.rb b/spec/models/spree/taxon_decorator_spec.rb index e5076cf0..ba79296c 100644 --- a/spec/models/spree/taxon_decorator_spec.rb +++ b/spec/models/spree/taxon_decorator_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'solidus_multi_domain_spec_helper' +require "solidus_multi_domain_spec_helper" RSpec.describe Spree::Taxon do describe ".find_by_store_id_and_permalink!" do @@ -24,7 +24,7 @@ context "taxon does not exist in given store" do it "raise active_record::not_found" do - expect{ + expect { # rubocop:disable Rails/DynamicFindBy described_class.find_by_store_id_and_permalink!(1, "non-existing-permalink") # rubocop:enable Rails/DynamicFindBy diff --git a/spec/requests/global_controller_helpers_spec.rb b/spec/requests/global_controller_helpers_spec.rb index c9dd9252..bb9b04c2 100644 --- a/spec/requests/global_controller_helpers_spec.rb +++ b/spec/requests/global_controller_helpers_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'solidus_multi_domain_spec_helper' +require "solidus_multi_domain_spec_helper" RSpec.describe "Global controller helpers" do let!(:store) { FactoryBot.create :store } @@ -13,43 +13,43 @@ expect(controller.current_store).to eq(store) end - describe '.current_currency' do + describe ".current_currency" do subject { controller.current_currency } context "when store default_currency is nil" do - it { is_expected.to eq('USD') } + it { is_expected.to eq("USD") } end context "when the current store default_currency empty" do - let!(:store) { FactoryBot.create :store, default_currency: '' } + let!(:store) { FactoryBot.create :store, default_currency: "" } - it { is_expected.to eq('USD') } + it { is_expected.to eq("USD") } end context "when the current store default_currency is a currency" do - let!(:store) { FactoryBot.create :store, default_currency: 'EUR' } + let!(:store) { FactoryBot.create :store, default_currency: "EUR" } - it { is_expected.to eq('EUR') } + it { is_expected.to eq("EUR") } end context "when session[:currency] set by spree_multi_currency" do before do - session[:currency] = 'AUD' + session[:currency] = "AUD" end - let!(:aud) { ::Money::Currency.find('AUD') } - let!(:eur) { ::Money::Currency.find('EUR') } - let!(:usd) { ::Money::Currency.find('USD') } - let!(:store) { FactoryBot.create :store, default_currency: 'EUR' } + let!(:aud) { ::Money::Currency.find("AUD") } + let!(:eur) { ::Money::Currency.find("EUR") } + let!(:usd) { ::Money::Currency.find("USD") } + let!(:store) { FactoryBot.create :store, default_currency: "EUR" } - it 'returns supported currencies' do + it "returns supported currencies" do allow(controller).to receive(:supported_currencies).and_return([aud, eur, usd]) - expect(controller.current_currency).to eql('AUD') + expect(controller.current_currency).to eql("AUD") end - it 'returns store currency if not supported' do + it "returns store currency if not supported" do allow(controller).to receive(:supported_currencies).and_return([eur, usd]) - expect(controller.current_currency).to eql('EUR') + expect(controller.current_currency).to eql("EUR") end end end diff --git a/spec/requests/spree/api/products_controller_spec.rb b/spec/requests/spree/api/products_controller_spec.rb index 0184ecf5..881a8cb2 100644 --- a/spec/requests/spree/api/products_controller_spec.rb +++ b/spec/requests/spree/api/products_controller_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'solidus_multi_domain_spec_helper' +require "solidus_multi_domain_spec_helper" RSpec.describe Spree::Api::ProductsController, type: :request do subject { @@ -8,38 +8,38 @@ } let!(:product) { FactoryBot.create(:product) } - let!(:user) { create(:user, :with_api_key) } + let!(:user) { create(:user, :with_api_key) } let!(:store) { FactoryBot.create(:store) } - if Spree.solidus_gem_version >= Gem::Version.new('2.8') - let!(:headers) { { 'Authorization': "Bearer #{user.spree_api_key}" } } + if Spree.solidus_gem_version >= Gem::Version.new("2.8") + let!(:headers) { {Authorization: "Bearer #{user.spree_api_key}"} } else - let!(:headers) { { 'X-Spree-Token' => user.spree_api_key } } + let!(:headers) { {"X-Spree-Token" => user.spree_api_key} } end describe :show do - context 'when the product is not added to the store' do - it 'returns 404' do + context "when the product is not added to the store" do + it "returns 404" do subject expect(response.response_code).to eq(404) end end - context 'when the product is added to the store' do + context "when the product is added to the store" do before { product.stores << store } - describe 'requesting a wrong store for the product' do + describe "requesting a wrong store for the product" do let!(:store_2) { FactoryBot.create(:store) } - it 'returns 404' do + it "returns 404" do host! store_2.url subject expect(response.response_code).to eq(404) end end - describe 'requesting the right store for the product' do - it 'returns a successful product with successful code' do + describe "requesting the right store for the product" do + it "returns a successful product with successful code" do subject expect(response.response_code).to eq(200) end diff --git a/spec/requests/template_renderer_spec.rb b/spec/requests/template_renderer_spec.rb index e6a94f2d..e1069db8 100644 --- a/spec/requests/template_renderer_spec.rb +++ b/spec/requests/template_renderer_spec.rb @@ -1,6 +1,14 @@ # frozen_string_literal: true -require 'solidus_multi_domain_spec_helper' +require "solidus_multi_domain_spec_helper" + +NormalController = Class.new(ApplicationController) + +ExplicitLayoutController = Class.new(ApplicationController) do + def index + render :index, layout: "fancy" + end +end RSpec.describe "Template renderer with dynamic layouts" do before do @@ -32,17 +40,13 @@ end context "for a controller inheriting from ApplicationController" do - before(:all) do - NormalController = Class.new(ApplicationController) - end - before do ApplicationController.view_paths += [ActionView::FixtureResolver.new( "normal/index.html.erb" => "just normal" )] Rails.application.routes.draw do - get 'normal', to: 'normal#index' + get "normal", to: "normal#index" end end @@ -62,14 +66,6 @@ end context "with an explicit `layout` passed to render" do - before(:all) do - ExplicitLayoutController = Class.new(ApplicationController) do - def index - render :index, layout: 'fancy' - end - end - end - before do ApplicationController.view_paths += [ActionView::FixtureResolver.new( "layouts/fancy.html.erb" => "Fancy <%= yield %>", @@ -77,7 +73,7 @@ def index )] Rails.application.routes.draw do - get 'explicit_layout', to: 'explicit_layout#index' + get "explicit_layout", to: "explicit_layout#index" end end diff --git a/spec/solidus_multi_domain_spec_helper.rb b/spec/solidus_multi_domain_spec_helper.rb index 762ff3a7..ce6e6bbd 100644 --- a/spec/solidus_multi_domain_spec_helper.rb +++ b/spec/solidus_multi_domain_spec_helper.rb @@ -1,14 +1,14 @@ # frozen_string_literal: true -require 'solidus_starter_frontend_spec_helper' -require 'support/solidus_multi_domain/testing_support/factories' -require 'solidus_core' -require 'solidus_api' -require 'solidus_backend' -require 'spree/testing_support/authorization_helpers' -require 'spree/testing_support/url_helpers' -require 'support/api' -require 'support/cancan' +require "solidus_starter_frontend_spec_helper" +require "support/solidus_multi_domain/testing_support/factories" +require "solidus_core" +require "solidus_api" +require "solidus_backend" +require "spree/testing_support/authorization_helpers" +require "spree/testing_support/url_helpers" +require "support/api" +require "support/cancan" RSpec.configure do |config| config.include Spree::TestingSupport::UrlHelpers diff --git a/spec/support/api.rb b/spec/support/api.rb index 8b8bbe1d..3b055b66 100644 --- a/spec/support/api.rb +++ b/spec/support/api.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require 'spree/api/testing_support/setup' -require 'spree/api/testing_support/helpers' +require "spree/api/testing_support/setup" +require "spree/api/testing_support/helpers" RSpec.configure do |config| config.include Spree::Api::TestingSupport::Helpers, type: :controller diff --git a/spec/support/cancan.rb b/spec/support/cancan.rb index c0669f0f..0daff878 100644 --- a/spec/support/cancan.rb +++ b/spec/support/cancan.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require 'cancan/matchers' +require "cancan/matchers"