Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
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-sqlite:
executor: solidusio_extensions/sqlite
steps:
- browser-tools/install-chrome
- solidusio_extensions/run-tests
run-specs-with-postgres:
executor: solidusio_extensions/postgres
steps:
- browser-tools/install-chrome
- solidusio_extensions/run-tests
run-specs-with-mysql:
executor: solidusio_extensions/mysql
steps:
- browser-tools/install-chrome
- solidusio_extensions/run-tests
lint-code:
executor: solidusio_extensions/sqlite-memory
steps:
- solidusio_extensions/lint-code

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

"Weekly run specs against main":
triggers:
- schedule:
cron: "0 0 * * 4" # every Thursday
filters:
branches:
only:
- main
jobs:
- run-specs-with-sqlite
- run-specs-with-postgres
- run-specs-with-mysql
5 changes: 5 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# See `git help blame` for more information.
# Use `git config blame.ignoreRevsFile .git-blame-ignore-revs` to enable.

# Reformat project
f94afca4
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: false
# Issues with these labels will never be considered stale
exemptLabels:
- pinned
- security
# Label to use when marking an issue as stale
staleLabel: stale
# 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 might 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
52 changes: 36 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
pull_request:
schedule:
- cron: "0 0 * * 4" # every Thursday
workflow_call:

concurrency:
group: test-${{ github.ref_name }}
Expand All @@ -23,36 +24,55 @@ jobs:
fail-fast: true
matrix:
rails-version:
- "7.0"
- "7.1"
- "7.2"
- "8.0"
ruby-version:
- "3.1"
- "3.4"
solidus-branch:
- "v4.1"
- "v4.2"
- "v4.3"
- "v4.4"
- "v4.5"
- "main"
database:
- "postgresql"
- "mysql"
- "sqlite"
exclude:
- solidus-branch: "main"
ruby-version: "3.1"
- 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
- ruby-version: "3.1"
rails-version: "8.0"
- solidus-branch: "v4.3"
rails-version: "8.0"
- solidus-branch: "v4.4"
rails-version: "8.0"
services:
postgres:
image: postgres:16
env:
POSTGRES_HOST_AUTH_METHOD: trust
options: >-
--health-cmd="pg_isready"
--health-interval=10s
--health-timeout=5s
--health-retries=5
ports:
- 5432:5432
mysql:
image: mysql:8
env:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=5
ports:
- 3306:3306
steps:
- uses: actions/checkout@v4
- name: Run extension tests
Expand All @@ -67,4 +87,4 @@ jobs:
continue-on-error: true
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ${{ env.TEST_RESULTS_PATH }}
files: ./coverage/coverage.xml
10 changes: 0 additions & 10 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
inherit_from: .rubocop_todo.yml

require:
- solidus_dev_support/rubocop

RSpec/DescribeClass:
Exclude:
- spec/requests/**/*
- spec/features/**/*

Rails/SkipsModelValidations:
Enabled: false

AllCops:
NewCops: disable
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Changelog

See https://github.com/solidusio/solidus_subscriptions/releases or [OLD_CHANGELOG.md](OLD_CHANGELOG.md) for older versions.
See https://github.com/solidusio/solidus_subscriptions/releases or OLD_CHANGELOG.md for older versions.
54 changes: 37 additions & 17 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,35 +1,55 @@
# frozen_string_literal: true

source 'https://rubygems.org'
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

branch = ENV.fetch('SOLIDUS_BRANCH', 'main')
gem 'solidus', github: 'solidusio/solidus', 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'
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

rails_version = ENV.fetch('RAILS_VERSION', '7.2')
gem 'rails', "~> #{rails_version}"
if branch <= "v4.5" || branch == "main"
gem "state_machines", "<= 0.6"
end

case ENV['DB']
when 'mysql'
gem 'mysql2'
when 'postgresql'
gem 'pg'
rails_version = ENV.fetch("RAILS_VERSION", "7.0")
gem "rails", "~> #{rails_version}"

case ENV.fetch("DB", nil)
when "mysql"
gem "mysql2"
when "postgresql"
gem "pg"
else
if rails_version <= "7.2"
gem 'sqlite3', "~> 1.7"
else
gem 'sqlite3', "~> 2.0"
end
gem "sqlite3", (rails_version < "7.2") ? "~> 1.4" : "~> 2.0"
end

if rails_version == "7.0"
gem "concurrent-ruby", "< 1.3.5"
end

if RUBY_VERSION >= "3.4"
# Solidus Promotions uses CSV but does not have it as dependency yet.
gem "csv"
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. 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'
send(:eval_gemfile, "Gemfile-local") if File.exist? "Gemfile-local"
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2016 Stembolt
Copyright (c) 2026 Solidus Team
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
Expand Down
6 changes: 3 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

require 'bundler/gem_tasks'
require "bundler/gem_tasks"

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

task default: 'extension:specs'
task default: "extension:specs"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Placeholder manifest file.
// the installer will append this file to the app vendored assets here: vendor/assets/javascripts/spree/frontend/all.js'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/*
Placeholder manifest file.
the installer will append this file to the app vendored assets here: 'vendor/assets/stylesheets/spree/backend/all.css'
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/*
Placeholder manifest file.
the installer will append this file to the app vendored assets here: 'vendor/assets/stylesheets/spree/frontend/all.css'
*/
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Api
module V1
class BaseController < ::Spree::Api::BaseController
def subscription_guest_token
request.headers['X-Spree-Subscription-Token']
request.headers["X-Spree-Subscription-Token"]
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ def create
render json: subscription.errors.to_json, status: :unprocessable_entity
end
else
error_message = I18n.t('solidus_subscriptions.subscription.invalid_payment_details')
error_message = I18n.t("solidus_subscriptions.subscription.invalid_payment_details")

render json: { payment_source_type: [error_message] }.to_json, status: :unprocessable_entity
render json: {payment_source_type: [error_message]}.to_json, status: :unprocessable_entity
end
end

Expand Down Expand Up @@ -93,7 +93,7 @@ def create_subscription_params

def subscription_params
params.require(:subscription).permit(SolidusSubscriptions.configuration.subscription_attributes | [
line_items_attributes: line_item_attributes,
line_items_attributes: line_item_attributes
])
end

Expand Down
10 changes: 5 additions & 5 deletions app/controllers/spree/admin/installments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
module Spree
module Admin
class InstallmentsController < ResourceController
belongs_to 'subscription', model_class: SolidusSubscriptions::Subscription
belongs_to "subscription", model_class: SolidusSubscriptions::Subscription

skip_before_action :load_resource, only: :index

def index
@search = collection.ransack((params[:q] || {}).reverse_merge(s: 'created_at desc'))
@search = collection.ransack((params[:q] || {}).reverse_merge(s: "created_at desc"))

@installments = @search.result(distinct: true).
page(params[:page]).
per(params[:per_page] || Spree::Config[:orders_per_page])
@installments = @search.result(distinct: true)
.page(params[:page])
.per(params[:per_page] || Spree::Config[:orders_per_page])
end

private
Expand Down
10 changes: 5 additions & 5 deletions app/controllers/spree/admin/subscription_events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
module Spree
module Admin
class SubscriptionEventsController < ResourceController
belongs_to 'subscription', model_class: SolidusSubscriptions::Subscription
belongs_to "subscription", model_class: SolidusSubscriptions::Subscription

skip_before_action :load_resource, only: :index

def index
@search = collection.ransack((params[:q] || {}).reverse_merge(s: 'created_at desc'))
@search = collection.ransack((params[:q] || {}).reverse_merge(s: "created_at desc"))

@subscription_events = @search.result(distinct: true).
page(params[:page]).
per(params[:per_page] || 20)
@subscription_events = @search.result(distinct: true)
.page(params[:page])
.per(params[:per_page] || 20)
end

private
Expand Down
10 changes: 5 additions & 5 deletions app/controllers/spree/admin/subscription_orders_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
module Spree
module Admin
class SubscriptionOrdersController < ResourceController
belongs_to 'subscription', model_class: SolidusSubscriptions::Subscription
belongs_to "subscription", model_class: SolidusSubscriptions::Subscription

def index
@search = collection.ransack((params[:q] || {}).reverse_merge(s: 'created_at desc'))
@search = collection.ransack((params[:q] || {}).reverse_merge(s: "created_at desc"))

@subscription_orders = @search.result(distinct: true).
page(params[:page]).
per(params[:per_page] || 20)
@subscription_orders = @search.result(distinct: true)
.page(params[:page])
.per(params[:per_page] || 20)
end

private
Expand Down
Loading