Skip to content

Commit

Permalink
Update gem to support the latest Solidus version
Browse files Browse the repository at this point in the history
  • Loading branch information
shahmayur001 committed Jan 28, 2025
1 parent 7699ce0 commit aac1289
Show file tree
Hide file tree
Showing 66 changed files with 880 additions and 233 deletions.
49 changes: 45 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,71 @@
version: 2.1

orbs:
# Required for feature specs.
browser-tools: circleci/[email protected]

# Always take the latest version of the orb, this allows us to
# run specs against Solidus supported versions only without the need
# to change this configuration every time a Solidus version is released
# or goes EOL.
solidusio_extensions: solidusio/extensions@volatile

commands:
test-with-starter-frontend:
steps:
- checkout
- browser-tools/install-chrome
- run:
name: Install libvips
command: |
sudo apt-get update
sudo apt-get install -yq libvips-dev
- solidusio_extensions/test-branch:
branch: main
command: |
export FRONTEND=starter
sudo gem update --system
gem install bundler rails:'~>7.2'
bundle exec rake
- solidusio_extensions/store-test-results

jobs:
run-specs-with-postgres:
executor:
name: solidusio_extensions/postgres
ruby_version: "3.0"
ruby_version: "3.2"
steps:
- solidusio_extensions/run-tests
- test-with-starter-frontend

run-specs-with-mysql:
executor:
name: solidusio_extensions/mysql
ruby_version: "3.0"
ruby_version: "3.2"
steps:
- solidusio_extensions/run-tests
- test-with-starter-frontend

run-specs-with-sqlite:
executor:
name: solidusio_extensions/sqlite
ruby_version: "3.1"
steps:
- test-with-starter-frontend

lint-code:
executor:
name: solidusio_extensions/sqlite-memory
ruby_version: "3.2"
steps:
- solidusio_extensions/lint-code

workflows:
"Run specs on supported Solidus versions":
jobs:
- run-specs-with-postgres
- run-specs-with-mysql
- run-specs-with-sqlite
- lint-code

"Weekly run specs against master":
triggers:
- schedule:
Expand All @@ -37,3 +77,4 @@ workflows:
jobs:
- run-specs-with-postgres
- run-specs-with-mysql
- run-specs-with-sqlite
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ pkg
*.swp
spec/dummy
spec/examples.txt
/sandbox
/dummy-app

7 changes: 7 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
inherit_from: .rubocop_todo.yml

require:
- solidus_dev_support/rubocop

AllCops:
TargetRubyVersion: 3.0
NewCops: disable

154 changes: 154 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
# 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
11 changes: 2 additions & 9 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,13 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
branch = ENV.fetch('SOLIDUS_BRANCH', 'main')
gem 'solidus', github: 'solidusio/solidus', branch: branch

# The solidus_frontend gem has been pulled out since v3.2
if branch >= 'v3.2'
gem 'solidus_frontend'
elsif branch == 'main'
gem 'solidus_frontend', github: 'solidusio/solidus_frontend', branch: branch
else
gem 'solidus_frontend', github: 'solidusio/solidus', branch: branch
end

# 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'

# Provides basic authentication functionality for testing parts of your engine
gem 'solidus_auth_devise'

Expand Down
8 changes: 7 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# frozen_string_literal: true

require "bundler/gem_tasks"
require 'solidus_dev_support/rake_tasks'
SolidusDevSupport::RakeTasks.install

task default: 'extension:specs'
task :default do
require 'bundler'
Bundler.with_unbundled_env do
sh 'bin/rspec'
end
end
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
# frozen_string_literal: true

module SolidusMultiDomain::CreateLineItemSupport
extend ActiveSupport::Concern
module SolidusMultiDomain
module CreateLineItemSupport
extend ActiveSupport::Concern

included do
prepend(InstanceMethods)
rescue_from SolidusMultiDomain::ProductDoesNotBelongToStoreError, with: :product_does_not_belong_to_store
end
included do
prepend(InstanceMethods)
rescue_from SolidusMultiDomain::ProductDoesNotBelongToStoreError, with: :product_does_not_belong_to_store
end

module InstanceMethods
private
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') }, status: :unprocessable_entity
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') },
status: :unprocessable_entity
end
end
end
end
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
# frozen_string_literal: true

module SolidusMultiDomain::ShowProductSupport
extend ActiveSupport::Concern
module SolidusMultiDomain
module ShowProductSupport
extend ActiveSupport::Concern

included do
prepend(InstanceMethods)
before_action :can_show_product, only: :show
end
included do
prepend(InstanceMethods)
before_action :can_show_product, only: :show
end

module InstanceMethods
def can_show_product
@product ||= Spree::Product.friendly.find(params[:id])
return unless @product.stores.empty? || !@product.stores.include?(current_store)

module InstanceMethods
def can_show_product
@product ||= Spree::Product.friendly.find(params[:id])
if @product.stores.empty? || !@product.stores.include?(current_store)
raise ActiveRecord::RecordNotFound
end
end
Expand Down
Loading

0 comments on commit aac1289

Please sign in to comment.