From f661ec93755bdd8075df3516ba90836180c69137 Mon Sep 17 00:00:00 2001 From: Mayur Shah Date: Fri, 28 Mar 2025 15:51:39 +0530 Subject: [PATCH 1/7] Fix the generator to address the link_directory error After this change [solidusio/solidus@16fcb10](solidusio/solidus@16fcb10) The command `bundle exec rake` started failing with the following error: ``` An error occurred in a `before(:suite)` hook. Failure/Error: //= link_directory ../javascripts .js Sprockets::ArgumentError: link_directory argument must be a directory ``` - Ensure that the correct directory is specified in the manifest file to avoid the `Sprockets::ArgumentError`. --- lib/generators/solidus_globalize/install/install_generator.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/generators/solidus_globalize/install/install_generator.rb b/lib/generators/solidus_globalize/install/install_generator.rb index b17463e..6f540f2 100644 --- a/lib/generators/solidus_globalize/install/install_generator.rb +++ b/lib/generators/solidus_globalize/install/install_generator.rb @@ -8,6 +8,7 @@ class InstallGenerator < Rails::Generators::Base def add_javascripts append_file "vendor/assets/javascripts/spree/backend/all.js", "//= require spree/backend/solidus_globalize\n" + empty_directory 'app/assets/javascripts' end def add_migrations From 988db44524fba011929fa1a50e13d3ac857ba768 Mon Sep 17 00:00:00 2001 From: Mayur Shah Date: Fri, 28 Mar 2025 15:53:22 +0530 Subject: [PATCH 2/7] Upgrade globalize to version 7.0 Update the globalize dependency to ~> 7.0. https://github.com/globalize/globalize/releases/tag/v7.0.0 --- solidus_globalize.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solidus_globalize.gemspec b/solidus_globalize.gemspec index e743dce..e0df910 100644 --- a/solidus_globalize.gemspec +++ b/solidus_globalize.gemspec @@ -32,7 +32,7 @@ Gem::Specification.new do |s| s.add_dependency 'deface', '~> 1.5' s.add_dependency 'friendly_id-globalize' - s.add_dependency 'globalize', '~> 6.0' + s.add_dependency 'globalize', '~> 7.0' s.add_dependency 'solidus_core', ['>= 2.0.0', '< 5'] s.add_dependency 'solidus_support', '~> 0.8' From 1ab4b7a1d581e5e248d0a76b9689d8e1f6d19ff4 Mon Sep 17 00:00:00 2001 From: Mayur Shah Date: Fri, 28 Mar 2025 15:54:51 +0530 Subject: [PATCH 3/7] Update locales to display accurate resource Update en.yml to display accurate resource names on the crumbs of globalize pages. --- config/locales/en.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 26f3703..22b98bd 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,6 +1,7 @@ en: spree: - back_to_resource_list: Back to resource list + back_to_resource_list: Back to %{resource} list + editing_resource: Editing %{resource} globalize: locales_displayed_on_translation_forms: Locales displayed on translation forms no_translations_for_criteria: There are no translations for given criteria From 2eac73a2229e61a4c272c70ec41ccd041a686d20 Mon Sep 17 00:00:00 2001 From: Mayur Shah Date: Fri, 28 Mar 2025 15:56:06 +0530 Subject: [PATCH 4/7] Add default to prevent not null constraint Added default value on `friendly_id_slugs` table to prevent not null constraint violation while gem installation. --- db/migrate/20191108162345_add_locale_to_friendly_id_slugs.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db/migrate/20191108162345_add_locale_to_friendly_id_slugs.rb b/db/migrate/20191108162345_add_locale_to_friendly_id_slugs.rb index fbb186a..4de374e 100644 --- a/db/migrate/20191108162345_add_locale_to_friendly_id_slugs.rb +++ b/db/migrate/20191108162345_add_locale_to_friendly_id_slugs.rb @@ -2,7 +2,8 @@ class AddLocaleToFriendlyIdSlugs < SolidusSupport::Migration[4.2] def change - add_column :friendly_id_slugs, :locale, :string, length: 2, null: false, after: :scope + # Added default to prevent not null constraint violation. + add_column :friendly_id_slugs, :locale, :string, length: 2, default: 'en', null: false, after: :scope remove_index :friendly_id_slugs, [:slug, :sluggable_type] add_index :friendly_id_slugs, [:slug, :sluggable_type, :locale], From d587fba6bf38d487f150055a01923b51d9df3c2f Mon Sep 17 00:00:00 2001 From: Mayur Shah Date: Tue, 1 Apr 2025 13:53:25 +0530 Subject: [PATCH 5/7] Update Sandbox script --- bin/sandbox | 78 ++++++++++++++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 40 deletions(-) diff --git a/bin/sandbox b/bin/sandbox index 75a3890..ecc41b5 100755 --- a/bin/sandbox +++ b/bin/sandbox @@ -1,78 +1,76 @@ #!/usr/bin/env bash set -e -test -z "${DEBUG+empty_string}" || set -x -test "$DB" = "sqlite" && export DB="sqlite3" - -if [ -z "$SOLIDUS_BRANCH" ] -then - echo "~~> Use 'export SOLIDUS_BRANCH=[master|v3.2|...]' to control the Solidus branch" - SOLIDUS_BRANCH="master" -fi -echo "~~> Using branch $SOLIDUS_BRANCH of solidus" +case "$DB" in +postgres|postgresql) + RAILSDB="postgresql" + ;; +mysql) + RAILSDB="mysql" + ;; +sqlite|'') + RAILSDB="sqlite3" + ;; +*) + echo "Invalid DB specified: $DB" + exit 1 + ;; +esac -if [ -z "$SOLIDUS_FRONTEND" ] +if [ ! -z $SOLIDUS_BRANCH ] then - echo "~~> Use 'export SOLIDUS_FRONTEND=[solidus_frontend|solidus_starter_frontend]' to control the Solidus frontend" - SOLIDUS_FRONTEND="solidus_frontend" + BRANCH=$SOLIDUS_BRANCH +else + BRANCH="main" fi -echo "~~> Using branch $SOLIDUS_FRONTEND as the solidus frontend" extension_name="solidus_globalize" # Stay away from the bundler env of the containing extension. function unbundled { - ruby -rbundler -e'b = proc {system *ARGV}; Bundler.respond_to?(:with_unbundled_env) ? Bundler.with_unbundled_env(&b) : Bundler.with_clean_env(&b)' -- $@ + ruby -rbundler -e'b = proc {system *ARGV}; Bundler.respond_to?(:with_unbundled_env) ? Bundler.with_unbundled_env(&b) : Bundler.with_clean_env(&b)' -- "$@" } rm -rf ./sandbox -unbundled bundle exec rails new sandbox \ - --database="${DB:-sqlite3}" \ - --skip-bundle \ +rails new sandbox \ + --database="$RAILSDB" \ --skip-git \ - --skip-keeps \ --skip-rc \ - --skip-spring \ - --skip-test \ - --skip-javascript if [ ! -d "sandbox" ]; then echo 'sandbox rails application failed' exit 1 fi +# ๐Ÿ”ฅ Fix for Sprockets error: Ensure the manifest.js file exists +mkdir -p sandbox/app/assets/config +cat < sandbox/app/assets/config/manifest.js +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css +EOF + cd ./sandbox cat <> Gemfile -gem 'solidus', github: 'solidusio/solidus', branch: '$SOLIDUS_BRANCH' -gem 'rails-i18n' -gem 'solidus_i18n' - -gem '$extension_name', path: '..' - group :test, :development do platforms :mri do gem 'pry-byebug' end end RUBY - -unbundled bundle install --gemfile Gemfile - +unbundled bundle add solidus --github solidusio/solidus --branch "${BRANCH:-main}" --version '> 0.a' unbundled bundle exec rake db:drop db:create - unbundled bundle exec rails generate solidus:install \ --auto-accept \ - --user_class=Spree::User \ - --enforce_available_locales=true \ - --with-authentication=true \ --payment-method=none \ - --frontend=${SOLIDUS_FRONTEND} \ $@ - -unbundled bundle exec rails generate solidus:auth:install --auto-run-migrations -unbundled bundle exec rails generate ${extension_name}:install --auto-run-migrations +unbundled bundle add ${extension_name} --path '../' +unbundled bundle exec rails generate $extension_name:install --auto-run-migrations echo -echo "๐Ÿš€ Sandbox app successfully created for $extension_name!" -echo "๐Ÿงช This app is intended for test purposes." +echo "๐Ÿš€ Sandbox app successfully created for ${extension_name}!" +echo "๐Ÿš€ Using $RAILSDB and Solidus $BRANCH" +echo "๐Ÿš€ Use 'export DB=[postgres|mysql|sqlite]' to control the DB adapter" +echo "๐Ÿš€ Use 'export SOLIDUS_BRANCH=' to control the Solidus version" +echo "๐Ÿš€ This app is intended for test purposes." From 6dee5e8ebac8acfee8d90df571c0ec2ac8705c42 Mon Sep 17 00:00:00 2001 From: Mayur Shah Date: Tue, 15 Apr 2025 12:51:30 +0530 Subject: [PATCH 6/7] Lint code --- .rubocop.yml | 30 ++++++++++++++++++++++++++++ .rubocop_todo.yml | 26 +++++++++--------------- spec/features/admin/products_spec.rb | 2 +- 3 files changed, 40 insertions(+), 18 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index ed101eb..3d7abd4 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -3,5 +3,35 @@ inherit_from: .rubocop_todo.yml require: - solidus_dev_support/rubocop +FactoryBot/CreateList: + Enabled: false + +FactoryBot/AssociationStyle: + Enabled: false + +FactoryBot/FactoryNameStyle: + Enabled: false + +FactoryBot/ConsistentParenthesesStyle: + Enabled: false + +FactoryBot/FactoryClassName: + Enabled: false + +FactoryBot/RedundantFactoryOption: + Enabled: false + +Gemspec/RequiredRubyVersion: + Enabled: false + +Capybara/RSpec/PredicateMatcher: + Enabled: false + +Capybara/ClickLinkOrButtonStyle: + Enabled: false + +Capybara/NegationMatcher: + Enabled: false + AllCops: NewCops: disable diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index b47d97e..9c8f42b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,22 +1,20 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2023-05-23 11:06:18 UTC using RuboCop version 1.51.0. +# on 2025-04-15 07:15:34 UTC using RuboCop version 1.74.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 -Capybara/VisibilityMatcher: +# Offense count: 28 +Capybara/AmbiguousClick: Exclude: - - 'spec/features/admin/products_spec.rb' + - 'spec/features/admin/translations_spec.rb' # Offense count: 1 -# Configuration parameters: Severity, Include. -# Include: **/*.gemspec -Gemspec/RequiredRubyVersion: +Capybara/VisibilityMatcher: Exclude: - - 'solidus_globalize.gemspec' + - 'spec/features/admin/products_spec.rb' # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). @@ -27,8 +25,9 @@ Layout/ExtraSpacing: # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator. +# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator, EnforcedStyleForRationalLiterals. # SupportedStylesForExponentOperator: space, no_space +# SupportedStylesForRationalLiterals: space, no_space Layout/SpaceAroundOperators: Exclude: - 'app/models/concerns/solidus_globalize/translatable.rb' @@ -81,16 +80,9 @@ RSpec/NamedSubject: - 'spec/models/product_property_spec.rb' - 'spec/support/shared_contexts/translatable_context.rb' -# Offense count: 1 -# Configuration parameters: Include. -# Include: db/migrate/*.rb -Rails/NotNullColumn: - Exclude: - - 'db/migrate/20191108162345_add_locale_to_friendly_id_slugs.rb' - # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings. # URISchemes: http, https Layout/LineLength: Max: 128 diff --git a/spec/features/admin/products_spec.rb b/spec/features/admin/products_spec.rb index 285b88e..4d7b462 100644 --- a/spec/features/admin/products_spec.rb +++ b/spec/features/admin/products_spec.rb @@ -10,7 +10,7 @@ it "doesnt blow up" do visit spree.admin_products_path click_icon :copy - expect(page).to have_selector '.flash', text: 'Product has been cloned', visible: false + expect(page).to have_css '.flash', text: 'Product has been cloned', visible: false end end end From faff5f92475517dc9b0188b9085e91275bbcbd78 Mon Sep 17 00:00:00 2001 From: Mayur Shah Date: Tue, 15 Apr 2025 12:51:56 +0530 Subject: [PATCH 7/7] Update License --- LICENSE | 2 ++ 1 file changed, 2 insertions(+) diff --git a/LICENSE b/LICENSE index 0cb7db7..0a25671 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,6 @@ Copyright (c) 2020 Solidus +Copyright (c) 2016-2025 Nebulab +Triodec, GMS and other contributors All rights reserved. Redistribution and use in source and binary forms, with or without modification,