diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 8032e579..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,67 +0,0 @@ -version: 2.1 - -orbs: - # 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: - 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: - - checkout - - solidusio_extensions/run-tests-solidus-<< parameters.solidus >> - lint-code: - executor: - name: solidusio_extensions/sqlite-memory - ruby_version: 2.5 - steps: - - solidusio_extensions/lint-code - -workflows: - "Run specs on supported Solidus versions": - jobs: - - 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"] } - - "Weekly run specs against main": - triggers: - - schedule: - cron: "0 0 * * 4" # every Thursday - filters: - branches: - only: - - main - jobs: - - 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"] } diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..308f16ef --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,70 @@ +name: Test + +on: + push: + branches: + - main + pull_request: + schedule: + - cron: "0 0 * * 4" # every Thursday + +concurrency: + group: test-${{ github.ref_name }} + cancel-in-progress: ${{ github.ref_name != 'main' }} + +permissions: + contents: read + +jobs: + rspec: + name: Solidus ${{ matrix.solidus-branch }}, Rails ${{ matrix.rails-version }} and Ruby ${{ matrix.ruby-version }} on ${{ matrix.database }} + runs-on: ubuntu-24.04 + strategy: + fail-fast: true + matrix: + rails-version: + - "7.0" + - "7.1" + - "7.2" + ruby-version: + - "3.1" + - "3.4" + solidus-branch: + - "v4.1" + - "v4.2" + - "v4.3" + - "v4.4" + database: + - "postgresql" + - "mysql" + - "sqlite" + exclude: + - rails-version: "7.2" + solidus-branch: "v4.3" + - rails-version: "7.2" + solidus-branch: "v4.2" + - rails-version: "7.2" + solidus-branch: "v4.1" + - rails-version: "7.1" + solidus-branch: "v4.2" + - rails-version: "7.1" + solidus-branch: "v4.1" + - ruby-version: "3.4" + rails-version: "7.0" + env: + TEST_RESULTS_PATH: coverage/coverage.xml + steps: + - uses: actions/checkout@v4 + - name: Run extension tests + uses: solidusio/test-solidus-extension@main + with: + database: ${{ matrix.database }} + rails-version: ${{ matrix.rails-version }} + ruby-version: ${{ matrix.ruby-version }} + solidus-branch: ${{ matrix.solidus-branch }} + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v5 + continue-on-error: true + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ${{ env.TEST_RESULTS_PATH }} diff --git a/Gemfile b/Gemfile index ba4aac4f..30cfa727 100644 --- a/Gemfile +++ b/Gemfile @@ -7,21 +7,10 @@ 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' -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 'solidus_frontend' -# Provides basic authentication functionality for testing parts of your engine -gem 'solidus_auth_devise' +rails_version = ENV.fetch('RAILS_VERSION', '7.2') +gem 'rails', "~> #{rails_version}" case ENV['DB'] when 'mysql' @@ -29,18 +18,15 @@ when 'mysql' when 'postgresql' gem 'pg' else - gem 'sqlite3' + if rails_version <= "7.2" + gem 'sqlite3', "~> 1.7" + else + gem 'sqlite3', "~> 2.0" + end end gemspec -if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3') - # Fix for Rails 7+ / Ruby 3+, see https://stackoverflow.com/a/72474475 - gem 'net-imap', require: false - gem 'net-pop', require: false - gem 'net-smtp', require: false -end - # Use a local Gemfile to include development dependencies that might not be # relevant for the project or for other contributors, e.g. pry-byebug. # diff --git a/app/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions.rb b/app/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions.rb index 1fb4cdf6..9fee356a 100644 --- a/app/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions.rb +++ b/app/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions.rb @@ -16,8 +16,8 @@ def self.prepended(base) end def subscriptions_attributes=(params) - ::Spree::Deprecation.warn( - 'Creating or updating subscriptions through Spree::User nested attributes is deprecated. ' \ + ::Spree.deprecator.warn( + "Creating or updating subscriptions through #{::Spree.user_class} nested attributes is deprecated. " \ 'Please use subscriptions APIs directly.' ) super @@ -27,4 +27,4 @@ def subscriptions_attributes=(params) end end -Spree.user_class.prepend(SolidusSubscriptions::Spree::User::HaveManySubscriptions) +::Spree.user_class.prepend(SolidusSubscriptions::Spree::User::HaveManySubscriptions) diff --git a/lib/generators/solidus_subscriptions/install/install_generator.rb b/lib/generators/solidus_subscriptions/install/install_generator.rb index 2081deab..faa11391 100644 --- a/lib/generators/solidus_subscriptions/install/install_generator.rb +++ b/lib/generators/solidus_subscriptions/install/install_generator.rb @@ -19,6 +19,7 @@ def add_javascripts def copy_starter_frontend_files return if options[:frontend] != 'starter' + return unless File.exist?(Rails.root.join('app/views/cart_line_items/_product_submit.html.erb')) copy_file 'app/views/cart_line_items/_subscription_fields.html.erb' prepend_to_file 'app/views/cart_line_items/_product_submit.html.erb', "<%= render 'cart_line_items/subscription_fields' %>\n" diff --git a/spec/controllers/spree/api/users_controller_spec.rb b/spec/controllers/spree/api/users_controller_spec.rb index 0a7d6141..f4bf4844 100644 --- a/spec/controllers/spree/api/users_controller_spec.rb +++ b/spec/controllers/spree/api/users_controller_spec.rb @@ -40,7 +40,7 @@ it 'updates the subscription line items' do allow(::Spree::Deprecation).to receive(:warn).with(a_string_matching( - 'Creating or updating subscriptions through Spree::User nested attributes is deprecated' + "Creating or updating subscriptions through #{Spree.user_class} nested attributes is deprecated" )) update_user line_item = subscription.line_items.reload.first diff --git a/spec/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions_spec.rb b/spec/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions_spec.rb index 4047b010..ed8aea0f 100644 --- a/spec/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions_spec.rb +++ b/spec/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe SolidusSubscriptions::Spree::User::HaveManySubscriptions, type: :model do - subject(:user) { Spree::User.new } + subject(:user) { Spree.user_class.new } it { is_expected.to have_many :subscriptions } it { is_expected.to accept_nested_attributes_for :subscriptions } @@ -16,7 +16,7 @@ expect(::Spree::Deprecation) .to have_received(:warn) - .with(/Creating or updating subscriptions through Spree::User nested attributes is deprecated/) + .with(/Creating or updating subscriptions through #{Spree.user_class} nested attributes is deprecated/) end end end