Hotfix: self-hosted tenant must always have active subscription (#358)

This commit is contained in:
Riccardo Graziosi
2024-05-29 10:22:22 +02:00
committed by GitHub
parent 5e885d77ff
commit 3ee686b640
2 changed files with 6 additions and 1 deletions

View File

@@ -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

View File

@@ -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