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
62 changes: 0 additions & 62 deletions .circleci/config.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .gem_release.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
bump:
recurse: false
file: 'lib/solidus_act_as_tenant/version.rb'
message: Bump SolidusActAsTenant to %{version}
file: 'lib/solidus_acts_as_tenant/version.rb'
message: Bump SolidusActsAsTenant to %{version}
tag: true
25 changes: 25 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Lint

on: [pull_request]

concurrency:
group: lint-${{ github.ref_name }}
cancel-in-progress: ${{ github.ref_name != 'main' }}

permissions:
contents: read

jobs:
ruby:
name: Check Ruby
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Ruby and gems
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.2"
bundler-cache: true
- name: Lint Ruby files
run: bundle exec rubocop -ESP
71 changes: 71 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
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"
- "v4.5"
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:
CODECOV_COVERAGE_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.CODECOV_COVERAGE_PATH }}
19 changes: 19 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
require:
- solidus_dev_support/rubocop

FactoryBot/CreateList:
Enabled: false

FactoryBot/AssociationStyle:
Enabled: false

FactoryBot/FactoryNameStyle:
Enabled: false

FactoryBot/ConsistentParenthesesStyle:
Enabled: false

Capybara/RSpec/PredicateMatcher:
Enabled: false

Gemspec/RequiredRubyVersion:
Enabled: false

AllCops:
NewCops: disable
TargetRubyVersion: 3.2 # Matching the .github/workflow/lint.yml ruby version
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-contrib/solidus_act_as_tenant/releases or OLD_CHANGELOG.md for older versions.
See https://github.com/nebulab/solidus_acts_as_tenant/releases or OLD_CHANGELOG.md for older versions.
20 changes: 12 additions & 8 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,25 @@ 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'

# Provides basic authentication functionality for testing parts of your engine
gem 'solidus_auth_devise'
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
gem 'sqlite3', '~> 1.4'
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
Expand Down
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Solidus Act As Tenant
# Solidus Acts As Tenant

[![CircleCI](https://dl.circleci.com/status-badge/img/gh/nebulab/solidus_acts_as_tenant/tree/Add-acts_as_tenant-to-Solidus.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/nebulab/solidus_acts_as_tenant/tree/Add-acts_as_tenant-to-Solidus)
[![codecov](https://codecov.io/gh/solidusio-contrib/solidus_act_as_tenant/branch/main/graph/badge.svg)](https://codecov.io/gh/solidusio-contrib/solidus_act_as_tenant)
[![codecov](https://codecov.io/gh/nebulab/solidus_acts_as_tenant/branch/main/graph/badge.svg)](https://codecov.io/gh/nebulab/solidus_acts_as_tenant)


This extension adds multi-tenant support to solidus using the row-level tenancy [acts_as_tenant](https://github.com/ErwinM/acts_as_tenant/commits/master/) gem.
Expand All @@ -10,16 +9,16 @@ It adds tenant scoping to a configurabale set of models and adds a console utili

## Installation

Add solidus_act_as_tenant to your Gemfile:
Add solidus_acts_as_tenant to your Gemfile:

```ruby
gem 'solidus_act_as_tenant'
gem 'solidus_acts_as_tenant'
```

Bundle your dependencies and run the installation generator:

```shell
bin/rails generate solidus_act_as_tenant:install
bin/rails generate solidus_acts_as_tenant:install
```

## Usage
Expand All @@ -38,7 +37,7 @@ To use it, you can add it to your `~/.irbrc` file or `~/.pryrc` file:

```ruby
if defined?(Rails)
TS = SolidusActAsTenant::Utils::TenantSelector.new
TS = SolidusActsAsTenant::Utils::TenantSelector.new

IRB.conf[:IRB_RC] = proc do
# * TS.ask => anytime in console, to switch tenant from a list
Expand Down Expand Up @@ -72,7 +71,7 @@ When testing your application's integration with this extension you may use its
You can load Solidus core factories along with this extension's factories using this statement:

```ruby
SolidusDevSupport::TestingSupport::Factories.load_for(SolidusActAsTenant::Engine)
SolidusDevSupport::TestingSupport::Factories.load_for(SolidusActsAsTenant::Engine)
```

### Running the sandbox
Expand Down
12 changes: 12 additions & 0 deletions app/decorators/solidus_acts_as_tenant/store_credit_decorator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

module SolidusActsAsTenant::StoreCreditDecorator # rubocop:disable Style/ClassAndModuleChildren
# Fixes no method error related to validations added through acts_as_tenant
def payment_method_id
return if payment_method.nil?

super
end

::Spree::StoreCredit.prepend(self)
end
31 changes: 31 additions & 0 deletions app/decorators/solidus_acts_as_tenant/variant_decorator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# frozen_string_literal: true

module SolidusActsAsTenant::VariantDecorator # rubocop:disable Style/ClassAndModuleChildren
# Fixes errors related to validations added through acts_as_tenant

def product_shipping_category_id
return if product.nil?

super
end

def product_shipping_category
return if product.nil?

super
end

def product_tax_category_id
return if product.nil?

super
end

def product_tax_category
return if product.nil?

super
end

::Spree::Variant.prepend(self)
end
16 changes: 0 additions & 16 deletions app/decorators/spree/store_credit_decorator.rb

This file was deleted.

22 changes: 0 additions & 22 deletions app/decorators/spree/variant_decorator.rb

This file was deleted.

2 changes: 1 addition & 1 deletion app/models/spree/tenant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Spree
class Tenant < Spree::Base
if SolidusActAsTenant.config.class_name == 'Spree::Tenant'
if SolidusActsAsTenant.config.class_name == 'Spree::Tenant'
validates :name, presence: true, uniqueness: true
validates :subdomain, uniqueness: true
validates :domain, uniqueness: true
Expand Down
2 changes: 1 addition & 1 deletion bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# frozen_string_literal: true

require "bundler/setup"
require "solidus_act_as_tenant"
require "solidus_acts_as_tenant"

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
Expand Down
2 changes: 1 addition & 1 deletion bin/rails-engine
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# installed from the root of your application.

ENGINE_ROOT = File.expand_path('..', __dir__)
ENGINE_PATH = File.expand_path('../lib/solidus_act_as_tenant/engine', __dir__)
ENGINE_PATH = File.expand_path('../lib/solidus_acts_as_tenant/engine', __dir__)

# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
Expand Down
Loading