Install acts_as_tenant gem and update documentation

This commit is contained in:
Manuel Bustillo 2024-11-30 19:57:08 +01:00
parent cf6ca5aa17
commit 988e158d99
11 changed files with 53 additions and 26 deletions

View File

@ -20,6 +20,7 @@ gem 'jsonapi-rails'
gem 'rack-cors' gem 'rack-cors'
gem 'react-rails' gem 'react-rails'
gem 'rubytree' gem 'rubytree'
gem 'acts_as_tenant'
group :development, :test do group :development, :test do
gem 'annotaterb' gem 'annotaterb'

View File

@ -72,6 +72,8 @@ GEM
securerandom (>= 0.3) securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5) tzinfo (~> 2.0, >= 2.0.5)
uri (>= 0.13.1) uri (>= 0.13.1)
acts_as_tenant (1.0.1)
rails (>= 6.0)
addressable (2.8.7) addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0) public_suffix (>= 2.0.2, < 7.0)
annotaterb (4.13.0) annotaterb (4.13.0)
@ -387,6 +389,7 @@ PLATFORMS
x86_64-linux x86_64-linux
DEPENDENCIES DEPENDENCIES
acts_as_tenant
annotaterb annotaterb
bootsnap bootsnap
chroma chroma

View File

@ -2,26 +2,30 @@
Rails.application.routes.draw do Rails.application.routes.draw do
mount LetterOpenerWeb::Engine, at: "/letter_opener" if Rails.env.development? mount LetterOpenerWeb::Engine, at: "/letter_opener" if Rails.env.development?
devise_for :users, skip: [:registration, :session, :confirmation] scope ":slug", constraints: {slug: /[a-z]+/} do
devise_scope :user do devise_for :users, skip: [:registration, :session, :confirmation]
post 'users', to: 'users/registrations#create' devise_scope :user do
post 'users', to: 'users/registrations#create'
post '/users/sign_in', to: 'users/sessions#create' post '/users/sign_in', to: 'users/sessions#create'
delete '/users/sign_out', to: 'users/sessions#destroy' delete '/users/sign_out', to: 'users/sessions#destroy'
get '/users/confirmation', to: 'users/confirmations#show', as: :confirmation get '/users/confirmation', to: 'users/confirmations#show', as: :confirmation
end
resources :groups, only: :index
resources :guests, only: %i[index create update destroy] do
post :bulk_update, on: :collection
end
resources :expenses, only: %i[index update] do
get :summary, on: :collection
end
resources :tables_arrangements, only: %i[index show]
end end
mount Rswag::Ui::Engine => '/api-docs' mount Rswag::Ui::Engine => '/api-docs'
mount Rswag::Api::Engine => '/api-docs' mount Rswag::Api::Engine => '/api-docs'
resources :groups, only: :index
resources :guests, only: %i[index create update destroy] do
post :bulk_update, on: :collection
end
resources :expenses, only: %i[index update] do
get :summary, on: :collection
end
resources :tables_arrangements, only: %i[index show]
get 'up' => 'rails/health#show', as: :rails_health_check get 'up' => 'rails/health#show', as: :rails_health_check

View File

@ -9,7 +9,7 @@ Group.delete_all
Wedding.delete_all Wedding.delete_all
Wedding.create!(date: 1.year.from_now) Wedding.create!(slug: :default, date: 1.year.from_now)
Expense.create!(name: 'Photographer', amount: 3000, pricing_type: 'fixed') Expense.create!(name: 'Photographer', amount: 3000, pricing_type: 'fixed')
Expense.create!(name: 'Country house', amount: 6000, pricing_type: 'fixed') Expense.create!(name: 'Country house', amount: 6000, pricing_type: 'fixed')

View File

@ -3,10 +3,12 @@
require 'swagger_helper' require 'swagger_helper'
RSpec.describe 'expenses', type: :request do RSpec.describe 'expenses', type: :request do
path '/expenses' do path '/{slug}/expenses' do
get('list expenses') do get('list expenses') do
tags 'Expenses' tags 'Expenses'
produces 'application/json' produces 'application/json'
parameter Swagger::Schema::SLUG
response(200, 'successful') do response(200, 'successful') do
schema type: :array, schema type: :array,
items: { items: {
@ -26,12 +28,13 @@ RSpec.describe 'expenses', type: :request do
end end
end end
path '/expenses/{id}' do path '/{slug}/expenses/{id}' do
patch('update expense') do patch('update expense') do
tags 'Expenses' tags 'Expenses'
consumes 'application/json' consumes 'application/json'
produces 'application/json' produces 'application/json'
parameter Swagger::Schema::SLUG
parameter name: 'id', in: :path, type: :string, format: :uuid, description: 'id' parameter name: 'id', in: :path, type: :string, format: :uuid, description: 'id'
parameter name: :body, in: :body, schema: { parameter name: :body, in: :body, schema: {
type: :object, type: :object,

View File

@ -3,10 +3,11 @@
require 'swagger_helper' require 'swagger_helper'
RSpec.describe 'groups', type: :request do RSpec.describe 'groups', type: :request do
path '/groups' do path '/{slug}/groups' do
get('list groups') do get('list groups') do
tags 'Groups' tags 'Groups'
produces 'application/json' produces 'application/json'
parameter Swagger::Schema::SLUG
response(200, 'successful') do response(200, 'successful') do
schema type: :array, schema type: :array,
items: { items: {

View File

@ -3,10 +3,11 @@
require 'swagger_helper' require 'swagger_helper'
RSpec.describe 'guests', type: :request do RSpec.describe 'guests', type: :request do
path '/guests' do path '/{slug}/guests' do
get('list guests') do get('list guests') do
tags 'Guests' tags 'Guests'
produces 'application/json' produces 'application/json'
parameter Swagger::Schema::SLUG
response(200, 'successful') do response(200, 'successful') do
schema type: :array, schema type: :array,
items: { items: {
@ -33,6 +34,7 @@ RSpec.describe 'guests', type: :request do
tags 'Guests' tags 'Guests'
consumes 'application/json' consumes 'application/json'
produces 'application/json' produces 'application/json'
parameter Swagger::Schema::SLUG
parameter name: :body, in: :body, schema: { parameter name: :body, in: :body, schema: {
type: :object, type: :object,
required: %i[guest], required: %i[guest],
@ -55,11 +57,12 @@ RSpec.describe 'guests', type: :request do
end end
end end
path '/guests/{id}' do path '/{slug}/guests/{id}' do
patch('update guest') do patch('update guest') do
tags 'Guests' tags 'Guests'
consumes 'application/json' consumes 'application/json'
produces 'application/json' produces 'application/json'
parameter Swagger::Schema::SLUG
parameter name: 'id', in: :path, type: :string, format: :uuid parameter name: 'id', in: :path, type: :string, format: :uuid
parameter name: :body, in: :body, schema: { parameter name: :body, in: :body, schema: {
type: :object, type: :object,
@ -85,6 +88,7 @@ RSpec.describe 'guests', type: :request do
delete('delete guest') do delete('delete guest') do
tags 'Guests' tags 'Guests'
produces 'application/json' produces 'application/json'
parameter Swagger::Schema::SLUG
parameter name: 'id', in: :path, type: :string, format: :uuid parameter name: 'id', in: :path, type: :string, format: :uuid
response_empty_200 response_empty_200

View File

@ -9,5 +9,13 @@ module Swagger
updated_at: SwaggerResponseHelper::TIMESTAMP updated_at: SwaggerResponseHelper::TIMESTAMP
} }
SLUG = {
name: 'slug',
in: :path,
type: :string,
example: :default,
description: 'Wedding slug'
}
end end
end end

View File

@ -4,11 +4,12 @@ require 'swagger_helper'
RSpec.describe 'users/confirmations', type: :request do RSpec.describe 'users/confirmations', type: :request do
path '/users/confirmation' do path '/{slug}/users/confirmation' do
get('confirm user email') do get('confirm user email') do
tags 'Users' tags 'Users'
produces 'application/json' produces 'application/json'
parameter Swagger::Schema::SLUG
parameter name: :confirmation_token, in: :query, type: :string, required: true parameter name: :confirmation_token, in: :query, type: :string, required: true
response(200, 'confirmed') do response(200, 'confirmed') do

View File

@ -4,12 +4,13 @@ require 'swagger_helper'
RSpec.describe 'users/registrations', type: :request do RSpec.describe 'users/registrations', type: :request do
path '/users' do path '/{slug}/users' do
post('create registration') do post('create registration') do
tags 'Users Registrations' tags 'Users Registrations'
consumes 'application/json' consumes 'application/json'
produces 'application/json' produces 'application/json'
parameter Swagger::Schema::SLUG
parameter name: :body, in: :body, schema: { parameter name: :body, in: :body, schema: {
type: :object, type: :object,
required: [:user], required: [:user],

View File

@ -4,13 +4,14 @@ require 'swagger_helper'
RSpec.describe 'users/sessions', type: :request do RSpec.describe 'users/sessions', type: :request do
path '/users/sign_in' do path '/{slug}/users/sign_in' do
post('create session') do post('create session') do
tags 'Users Sessions' tags 'Users Sessions'
consumes 'application/json' consumes 'application/json'
produces 'application/json' produces 'application/json'
parameter Swagger::Schema::SLUG
parameter name: :body, in: :body, schema: { parameter name: :body, in: :body, schema: {
type: :object, type: :object,
required: %i[user], required: %i[user],
@ -35,8 +36,8 @@ RSpec.describe 'users/sessions', type: :request do
end end
end end
path '/users/sign_out' do path '/{slug}/users/sign_out' do
parameter Swagger::Schema::SLUG
delete('delete session') do delete('delete session') do
tags 'Users Sessions' tags 'Users Sessions'
consumes 'application/json' consumes 'application/json'