Skip to content

Commit f82c66c

Browse files
authored
Merge pull request #321 from solidusio/github-action
Use GitHub Action to test extension
2 parents 4b73159 + 7fd0425 commit f82c66c

7 files changed

Lines changed: 85 additions & 95 deletions

File tree

.circleci/config.yml

Lines changed: 0 additions & 67 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
schedule:
9+
- cron: "0 0 * * 4" # every Thursday
10+
11+
concurrency:
12+
group: test-${{ github.ref_name }}
13+
cancel-in-progress: ${{ github.ref_name != 'main' }}
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
rspec:
20+
name: Solidus ${{ matrix.solidus-branch }}, Rails ${{ matrix.rails-version }} and Ruby ${{ matrix.ruby-version }} on ${{ matrix.database }}
21+
runs-on: ubuntu-24.04
22+
strategy:
23+
fail-fast: true
24+
matrix:
25+
rails-version:
26+
- "7.0"
27+
- "7.1"
28+
- "7.2"
29+
ruby-version:
30+
- "3.1"
31+
- "3.4"
32+
solidus-branch:
33+
- "v4.1"
34+
- "v4.2"
35+
- "v4.3"
36+
- "v4.4"
37+
database:
38+
- "postgresql"
39+
- "mysql"
40+
- "sqlite"
41+
exclude:
42+
- rails-version: "7.2"
43+
solidus-branch: "v4.3"
44+
- rails-version: "7.2"
45+
solidus-branch: "v4.2"
46+
- rails-version: "7.2"
47+
solidus-branch: "v4.1"
48+
- rails-version: "7.1"
49+
solidus-branch: "v4.2"
50+
- rails-version: "7.1"
51+
solidus-branch: "v4.1"
52+
- ruby-version: "3.4"
53+
rails-version: "7.0"
54+
env:
55+
TEST_RESULTS_PATH: coverage/coverage.xml
56+
steps:
57+
- uses: actions/checkout@v4
58+
- name: Run extension tests
59+
uses: solidusio/test-solidus-extension@main
60+
with:
61+
database: ${{ matrix.database }}
62+
rails-version: ${{ matrix.rails-version }}
63+
ruby-version: ${{ matrix.ruby-version }}
64+
solidus-branch: ${{ matrix.solidus-branch }}
65+
- name: Upload coverage reports to Codecov
66+
uses: codecov/codecov-action@v5
67+
continue-on-error: true
68+
with:
69+
token: ${{ secrets.CODECOV_TOKEN }}
70+
files: ${{ env.TEST_RESULTS_PATH }}

Gemfile

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,26 @@ branch = ENV.fetch('SOLIDUS_BRANCH', 'main')
77
gem 'solidus', github: 'solidusio/solidus', branch: branch
88

99
# The solidus_frontend gem has been pulled out since v3.2
10-
if branch >= 'v3.2'
11-
gem 'solidus_frontend'
12-
elsif branch == 'main'
13-
gem 'solidus_frontend', github: 'solidusio/solidus_frontend'
14-
else
15-
gem 'solidus_frontend', github: 'solidusio/solidus', branch: branch
16-
end
17-
18-
# Needed to help Bundler figure out how to resolve dependencies,
19-
# otherwise it takes forever to resolve them.
20-
# See https://github.com/bundler/bundler/issues/6677
21-
gem 'rails', '>0.a'
10+
gem 'solidus_frontend'
2211

23-
# Provides basic authentication functionality for testing parts of your engine
24-
gem 'solidus_auth_devise'
12+
rails_version = ENV.fetch('RAILS_VERSION', '7.2')
13+
gem 'rails', "~> #{rails_version}"
2514

2615
case ENV['DB']
2716
when 'mysql'
2817
gem 'mysql2'
2918
when 'postgresql'
3019
gem 'pg'
3120
else
32-
gem 'sqlite3'
21+
if rails_version <= "7.2"
22+
gem 'sqlite3', "~> 1.7"
23+
else
24+
gem 'sqlite3', "~> 2.0"
25+
end
3326
end
3427

3528
gemspec
3629

37-
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3')
38-
# Fix for Rails 7+ / Ruby 3+, see https://stackoverflow.com/a/72474475
39-
gem 'net-imap', require: false
40-
gem 'net-pop', require: false
41-
gem 'net-smtp', require: false
42-
end
43-
4430
# Use a local Gemfile to include development dependencies that might not be
4531
# relevant for the project or for other contributors, e.g. pry-byebug.
4632
#

app/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ def self.prepended(base)
1616
end
1717

1818
def subscriptions_attributes=(params)
19-
::Spree::Deprecation.warn(
20-
'Creating or updating subscriptions through Spree::User nested attributes is deprecated. ' \
19+
::Spree.deprecator.warn(
20+
"Creating or updating subscriptions through #{::Spree.user_class} nested attributes is deprecated. " \
2121
'Please use subscriptions APIs directly.'
2222
)
2323
super
@@ -27,4 +27,4 @@ def subscriptions_attributes=(params)
2727
end
2828
end
2929

30-
Spree.user_class.prepend(SolidusSubscriptions::Spree::User::HaveManySubscriptions)
30+
::Spree.user_class.prepend(SolidusSubscriptions::Spree::User::HaveManySubscriptions)

lib/generators/solidus_subscriptions/install/install_generator.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def add_javascripts
1919

2020
def copy_starter_frontend_files
2121
return if options[:frontend] != 'starter'
22+
return unless File.exist?(Rails.root.join('app/views/cart_line_items/_product_submit.html.erb'))
2223

2324
copy_file 'app/views/cart_line_items/_subscription_fields.html.erb'
2425
prepend_to_file 'app/views/cart_line_items/_product_submit.html.erb', "<%= render 'cart_line_items/subscription_fields' %>\n"

spec/controllers/spree/api/users_controller_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
it 'updates the subscription line items' do
4242
allow(::Spree::Deprecation).to receive(:warn).with(a_string_matching(
43-
'Creating or updating subscriptions through Spree::User nested attributes is deprecated'
43+
"Creating or updating subscriptions through #{Spree.user_class} nested attributes is deprecated"
4444
))
4545
update_user
4646
line_item = subscription.line_items.reload.first

spec/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
require 'spec_helper'
44

55
RSpec.describe SolidusSubscriptions::Spree::User::HaveManySubscriptions, type: :model do
6-
subject(:user) { Spree::User.new }
6+
subject(:user) { Spree.user_class.new }
77

88
it { is_expected.to have_many :subscriptions }
99
it { is_expected.to accept_nested_attributes_for :subscriptions }
@@ -16,7 +16,7 @@
1616

1717
expect(::Spree::Deprecation)
1818
.to have_received(:warn)
19-
.with(/Creating or updating subscriptions through Spree::User nested attributes is deprecated/)
19+
.with(/Creating or updating subscriptions through #{Spree.user_class} nested attributes is deprecated/)
2020
end
2121
end
2222
end

0 commit comments

Comments
 (0)