From 3ee686b64004235cac03294145648e6e3421579d Mon Sep 17 00:00:00 2001 From: Riccardo Graziosi <31478034+riggraz@users.noreply.github.com> Date: Wed, 29 May 2024 10:22:22 +0200 Subject: [PATCH] Hotfix: self-hosted tenant must always have active subscription (#358) --- app/models/tenant_billing.rb | 2 +- spec/models/tenant_billing_spec.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/tenant_billing.rb b/app/models/tenant_billing.rb index a51b5048..b3bf59e0 100644 --- a/app/models/tenant_billing.rb +++ b/app/models/tenant_billing.rb @@ -17,7 +17,7 @@ class TenantBilling < ApplicationRecord ] def has_active_subscription? - perpetual? || (active? && subscription_ends_at+1.day > Time.current) || (canceled? && subscription_ends_at > Time.current) || (trial? && trial_ends_at > Time.current) + perpetual? || (active? && subscription_ends_at+1.day > Time.current) || (canceled? && subscription_ends_at > Time.current) || (trial? && trial_ends_at > Time.current) || Rails.application.multi_tenancy? == false end def generate_auth_token diff --git a/spec/models/tenant_billing_spec.rb b/spec/models/tenant_billing_spec.rb index fc614785..37867f0d 100644 --- a/spec/models/tenant_billing_spec.rb +++ b/spec/models/tenant_billing_spec.rb @@ -3,6 +3,11 @@ require 'rails_helper' RSpec.describe TenantBilling, type: :model do let(:tenant_billing) { FactoryBot.build(:tenant_billing) } + # Tenant Billing subscription works only in multi_tenancy mode + before do + allow(Rails.application).to receive(:multi_tenancy?).and_return(true) + end + it 'should be valid' do expect(tenant_billing).to be_valid end