Skip to content

Commit

Permalink
Merge pull request #67 from cpfergus1/cpfergus1/solidus-4-prep
Browse files Browse the repository at this point in the history
Prep for Solidus 4+
  • Loading branch information
kennyadsl authored May 22, 2023
2 parents 9547d43 + 653e93e commit bb3268f
Show file tree
Hide file tree
Showing 26 changed files with 338 additions and 241 deletions.
62 changes: 50 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,73 @@
version: 2.1

orbs:
# Required for feature specs.
browser-tools: circleci/browser-tools@1.1

# 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

jobs:
run-specs-with-postgres:
executor: solidusio_extensions/postgres
run-specs:
parameters:
solidus:
type: string
default: main
db:
type: string
default: "postgres"
ruby:
type: string
default: "3.2"
executor:
name: solidusio_extensions/<< parameters.db >>
ruby_version: << parameters.ruby >>
steps:
- solidusio_extensions/run-tests
run-specs-with-mysql:
executor: solidusio_extensions/mysql
- checkout
- browser-tools/install-chrome
- solidusio_extensions/run-tests-solidus-<< parameters.solidus >>

lint-code:
executor:
name: solidusio_extensions/sqlite
ruby_version: "3.0"
steps:
- solidusio_extensions/run-tests
- solidusio_extensions/lint-code

workflows:
"Run specs on supported Solidus versions":
jobs:
- run-specs-with-postgres
- run-specs-with-mysql
"Weekly run specs against master":
- run-specs:
name: &name "run-specs-solidus-<< matrix.solidus >>-ruby-<< matrix.ruby >>-db-<< matrix.db >>"
matrix:
parameters: { solidus: ["main"], ruby: ["3.2"], db: ["postgres"] }
- run-specs:
name: *name
matrix:
parameters: { solidus: ["current"], ruby: ["3.1"], db: ["mysql"] }
- run-specs:
name: *name
matrix:
parameters: { solidus: ["older"], ruby: ["3.0"], db: ["sqlite"] }
- lint-code

"Weekly run specs against main":
triggers:
- schedule:
cron: "0 0 * * 4" # every Thursday
filters:
branches:
only:
- master
- main
jobs:
- run-specs-with-postgres
- run-specs-with-mysql
- run-specs:
name: *name
matrix:
parameters: { solidus: ["main"], ruby: ["3.2"], db: ["postgres"] }
- run-specs:
name: *name
matrix:
parameters: { solidus: ["current"], ruby: ["3.1"], db: ["mysql"] }
18 changes: 1 addition & 17 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 60
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
exemptLabels:
- pinned
- security
# Label to use when marking an issue as stale
staleLabel: wontfix
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false
_extends: .github
2 changes: 2 additions & 0 deletions .github_changelog_generator
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
issues=false
exclude-labels=infrastructure
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@
.sass-cache
coverage
Gemfile.lock
Gemfile-local
tmp
nbproject
pkg
*.swp
spec/dummy
spec/examples.txt
.byebug*
Gemfile-local
/sandbox
.rvmrc
.ruby-version
.ruby-gemset
.byebug*
1 change: 0 additions & 1 deletion .rspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
--color
--format documentation
--require spec_helper
5 changes: 4 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
inherit_from: .rubocop_todo.yml

require:
- solidus_dev_support/rubocop

inherit_from: .rubocop_todo.yml
AllCops:
NewCops: disable
94 changes: 18 additions & 76 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,24 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2019-11-23 17:04:33 +0100 using RuboCop version 0.76.0.
# on 2023-05-12 15:47:30 UTC using RuboCop version 1.50.2.
# 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: Include.
# Include: **/*.gemspec,
Gemspec/RequiredRubyVersion:
Exclude:
- 'solidus_volume_pricing.gemspec'

# Offense count: 2
Lint/InterpolationCheck:
Exclude:
- 'spec/lib/solidus_volume_pricing/range_from_string_spec.rb'

# Offense count: 21
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 160

# Offense count: 43
# Configuration parameters: Prefixes.
# Offense count: 42
# Configuration parameters: Prefixes, AllowedPatterns.
# Prefixes: when, with, without
RSpec/ContextWording:
Exclude:
- 'spec/controllers/spree/admin/variants_controller_spec.rb'
- 'spec/helpers/base_helper_spec.rb'
- 'spec/models/solidus_volume_pricing/pricer_spec.rb'
- 'spec/models/spree/order_spec.rb'
- 'spec/models/spree/volume_price_spec.rb'

# Offense count: 2
RSpec/DescribeClass:
Exclude:
- 'spec/features/manage_volume_price_models_feature_spec.rb'
- 'spec/features/manage_volume_prices_feature_spec.rb'

# Offense count: 1
# Configuration parameters: CustomTransform, IgnoreMethods.
# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
# Include: **/*_spec*rb*, **/spec/**/*
RSpec/FilePath:
Exclude:
- 'spec/helpers/base_helper_spec.rb'
Expand All @@ -56,12 +31,17 @@ RSpec/InstanceVariable:
- 'spec/models/spree/order_spec.rb'

# Offense count: 5
# Configuration parameters: AggregateFailuresByDefault.
RSpec/MultipleExpectations:
Max: 3

# Offense count: 58
# Configuration parameters: IgnoreSharedExamples.
# Offense count: 82
# Configuration parameters: AllowSubject.
RSpec/MultipleMemoizedHelpers:
Max: 8

# Offense count: 57
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
# SupportedStyles: always, named_only
RSpec/NamedSubject:
Exclude:
- 'spec/lib/solidus_volume_pricing/range_from_string_spec.rb'
Expand All @@ -70,57 +50,19 @@ RSpec/NamedSubject:
- 'spec/models/spree/volume_price_spec.rb'

# Offense count: 74
# Configuration parameters: AllowedGroups.
RSpec/NestedGroups:
Max: 7

# Offense count: 1
# Configuration parameters: Include.
# Include: db/migrate/*.rb
Rails/CreateTableWithTimestamps:
Exclude:
- 'db/migrate/20150603143015_create_spree_volume_price_models.rb'

# Offense count: 1
# Configuration parameters: Include.
# Include: app/models/**/*.rb
Rails/HasManyOrHasOneDependent:
# Offense count: 2
RSpec/RepeatedExampleGroupDescription:
Exclude:
- 'app/models/spree/volume_price_model.rb'
- 'spec/lib/solidus_volume_pricing/range_from_string_spec.rb'

# Offense count: 2
# Configuration parameters: Include.
# Configuration parameters: IgnoreScopes, Include.
# Include: app/models/**/*.rb
Rails/InverseOf:
Exclude:
- 'app/models/spree/volume_price.rb'
- 'app/models/spree/volume_price_model.rb'

# Offense count: 1
# Configuration parameters: Include.
# Include: app/controllers/**/*.rb
Rails/LexicallyScopedActionFilter:
Exclude:
- 'app/controllers/spree/admin/volume_price_models_controller.rb'

# Offense count: 1
# Configuration parameters: Include.
# Include: app/**/*.rb, config/**/*.rb, db/**/*.rb, lib/**/*.rb
Rails/Output:
Exclude:
- 'lib/generators/solidus_volume_pricing/install/install_generator.rb'

# Offense count: 2
# Configuration parameters: Blacklist, Whitelist.
# Blacklist: decrement!, decrement_counter, increment!, increment_counter, toggle!, touch, update_all, update_attribute, update_column, update_columns, update_counters
Rails/SkipsModelValidations:
Exclude:
- 'spec/models/spree/volume_price_spec.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, EnforcedStyle.
# SupportedStyles: nested, compact
Style/ClassAndModuleChildren:
Exclude:
- 'app/models/spree/volume_price.rb'
- 'app/models/spree/volume_price_model.rb'
27 changes: 16 additions & 11 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@
source 'https://rubygems.org'
git_source(:github) { |repo| "/~https://github.com/#{repo}.git" }

branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
solidus_git, solidus_frontend_git = if (branch == 'master') || (branch >= 'v3.2')
%w[solidusio/solidus solidusio/solidus_frontend]
else
%w[solidusio/solidus] * 2
end
gem 'solidus', github: solidus_git, branch: branch
gem 'solidus_frontend', github: solidus_frontend_git, branch: branch
branch = ENV.fetch('SOLIDUS_BRANCH', 'main')
gem 'solidus', github: 'solidusio/solidus', branch: branch

# The solidus_frontend gem has been pulled out since v3.2
gem 'solidus_frontend'

# Needed to help Bundler figure out how to resolve dependencies,
# otherwise it takes forever to resolve them.
Expand All @@ -20,7 +17,7 @@ gem 'rails', '>0.a'
# Provides basic authentication functionality for testing parts of your engine
gem 'solidus_auth_devise'

case ENV['DB']
case ENV.fetch('DB', nil)
when 'mysql'
gem 'mysql2'
when 'postgresql'
Expand All @@ -29,8 +26,16 @@ else
gem 'sqlite3'
end

# While we still support Ruby < 3 we need to workaround a limitation in
# the 'async' gem that relies on the latest ruby, since RubyGems doesn't
# resolve gems based on the required ruby version.
gem 'async', '< 3' if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3')

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'
# relevant for the project or for other contributors, e.g. pry-byebug.
#
# We use `send` instead of calling `eval_gemfile` to work around an issue with
# how Dependabot parses projects: /~https://github.com/dependabot/dependabot-core/issues/1658.
send(:eval_gemfile, 'Gemfile-local') if File.exist? 'Gemfile-local'
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Spree
module Admin
class VolumePriceModelsController < ResourceController
before_action :load_volume_prices, only: [:new, :edit]
before_action :load_volume_prices, only: [:new, :edit] # rubocop:disable Rails/LexicallyScopedActionFilter

private

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ def self.prepended(base)
base.class_eval do
has_and_belongs_to_many :volume_price_models
has_many :volume_prices, -> { order(position: :asc) }, dependent: :destroy
has_many :model_volume_prices, -> { order(position: :asc) }, class_name: '::Spree::VolumePrice', through: :volume_price_models, source: :volume_prices
has_many :model_volume_prices, -> {
order(position: :asc)
}, class_name: '::Spree::VolumePrice', through: :volume_price_models, source: :volume_prices
accepts_nested_attributes_for :volume_prices, allow_destroy: true,
reject_if: proc { |volume_price|
volume_price[:amount].blank? && volume_price[:range].blank?
}
reject_if: proc { |volume_price|
volume_price[:amount].blank? && volume_price[:range].blank?
}
end
end

Expand Down
Loading

0 comments on commit bb3268f

Please sign in to comment.