fix-tenant-scope #159

Merged
bustikiller merged 4 commits from fix-tenant-scope into main 2024-12-02 19:35:36 +00:00
3 changed files with 15 additions and 6 deletions

View File

@ -1,6 +1,7 @@
# Copyright (C) 2024 Manuel Bustillo # Copyright (C) 2024 Manuel Bustillo
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
set_current_tenant_through_filter
before_action :set_tenant before_action :set_tenant
before_action :authenticate_user! before_action :authenticate_user!
after_action :set_csrf_cookie after_action :set_csrf_cookie
@ -47,7 +48,7 @@ class ApplicationController < ActionController::Base
end end
def set_tenant def set_tenant
ActsAsTenant.current_tenant = Wedding.find_by(slug: params[:slug]) set_current_tenant(Wedding.find_by!(slug: params[:slug]))
end end
def development_swagger? def development_swagger?

View File

@ -0,0 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
ActsAsTenant.configure do |config|
config.require_tenant = !Rails.env.test?
end

View File

@ -2,12 +2,15 @@
NUMBER_OF_GUESTS = 50 NUMBER_OF_GUESTS = 50
ActsAsTenant.without_tenant do
TablesArrangement.delete_all TablesArrangement.delete_all
Expense.delete_all Expense.delete_all
Guest.delete_all Guest.delete_all
Group.delete_all Group.delete_all
Wedding.delete_all Wedding.delete_all
end
wedding = Wedding.create!(slug: :default, date: 1.year.from_now) wedding = Wedding.create!(slug: :default, date: 1.year.from_now)
ActsAsTenant.with_tenant(wedding) do ActsAsTenant.with_tenant(wedding) do