Compare commits
1 Commits
278faa7319
...
a43a2cc711
Author | SHA1 | Date | |
---|---|---|---|
|
a43a2cc711 |
2
Gemfile
2
Gemfile
@ -22,7 +22,6 @@ gem 'react-rails'
|
||||
gem 'rubytree'
|
||||
gem 'acts_as_tenant'
|
||||
gem 'httparty'
|
||||
gem 'rswag'
|
||||
|
||||
group :development, :test do
|
||||
gem 'annotaterb'
|
||||
@ -31,6 +30,7 @@ group :development, :test do
|
||||
gem 'license_finder'
|
||||
gem 'pry'
|
||||
gem 'rspec-rails', '~> 7.1.0'
|
||||
gem 'rswag'
|
||||
gem 'shoulda-matchers', '~> 6.0'
|
||||
end
|
||||
|
||||
|
@ -136,7 +136,7 @@ GEM
|
||||
actionpack (>= 6.0.0)
|
||||
activesupport (>= 6.0.0)
|
||||
railties (>= 6.0.0)
|
||||
io-console (0.8.0)
|
||||
io-console (0.7.2)
|
||||
irb (1.14.1)
|
||||
rdoc (>= 4.0.0)
|
||||
reline (>= 0.4.2)
|
||||
@ -273,7 +273,7 @@ GEM
|
||||
zeitwerk (~> 2.6)
|
||||
rainbow (3.1.1)
|
||||
rake (13.2.1)
|
||||
rdoc (6.8.1)
|
||||
rdoc (6.7.0)
|
||||
psych (>= 4.0.0)
|
||||
react-rails (3.2.1)
|
||||
babel-transpiler (>= 0.7.0)
|
||||
@ -340,10 +340,10 @@ GEM
|
||||
rubytree (2.1.0)
|
||||
json (~> 2.0, > 2.3.1)
|
||||
rubyzip (2.3.2)
|
||||
securerandom (0.4.0)
|
||||
securerandom (0.3.2)
|
||||
shoulda-matchers (6.4.0)
|
||||
activesupport (>= 5.2.0)
|
||||
solid_queue (1.1.0)
|
||||
solid_queue (1.0.2)
|
||||
activejob (>= 7.1)
|
||||
activerecord (>= 7.1)
|
||||
concurrent-ruby (>= 1.3.1)
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
class CaptchaController < ApplicationController
|
||||
skip_before_action :authenticate_user!
|
||||
skip_before_action :set_tenant
|
||||
|
||||
def create
|
||||
id = LibreCaptcha.new.get_id
|
||||
render json: {
|
||||
|
@ -7,7 +7,7 @@ class Users::RegistrationsController < Devise::RegistrationsController
|
||||
before_action :validate_captcha!, only: :create
|
||||
|
||||
def create
|
||||
wedding = Wedding.create(slug: params[:slug])
|
||||
wedding = Wedding.create(wedding_params)
|
||||
unless wedding.persisted?
|
||||
render json: { errors: wedding.errors.full_messages }, status: :unprocessable_entity
|
||||
return
|
||||
@ -22,7 +22,7 @@ class Users::RegistrationsController < Devise::RegistrationsController
|
||||
|
||||
private
|
||||
|
||||
def set_tenant
|
||||
set_current_tenant(nil)
|
||||
def wedding_params
|
||||
{ slug: params[:slug], **params.expect(wedding: :date) }
|
||||
end
|
||||
end
|
@ -5,6 +5,7 @@
|
||||
# Table name: weddings
|
||||
#
|
||||
# id :uuid not null, primary key
|
||||
# date :date not null
|
||||
# slug :string not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
@ -16,5 +17,6 @@
|
||||
class Wedding < ApplicationRecord
|
||||
SLUG_REGEX = /[a-z\d-]+/
|
||||
|
||||
validates :date, presence: true
|
||||
validates :slug, presence: true, uniqueness: true, format: { with: /\A#{SLUG_REGEX}\z/ }
|
||||
end
|
||||
|
@ -83,7 +83,6 @@ test:
|
||||
#
|
||||
production:
|
||||
<<: *default
|
||||
host: db
|
||||
database: wedding_planner_production
|
||||
username: wedding_planner
|
||||
password: <%= ENV["WEDDING_PLANNER_DATABASE_PASSWORD"] %>
|
||||
|
@ -21,8 +21,6 @@ Rails.application.routes.draw do
|
||||
get :summary, on: :collection
|
||||
end
|
||||
resources :tables_arrangements, only: %i[index show]
|
||||
|
||||
root to: redirect("/%{slug}")
|
||||
end
|
||||
|
||||
resources :captcha, only: :create do
|
||||
@ -33,4 +31,6 @@ Rails.application.routes.draw do
|
||||
mount Rswag::Api::Engine => '/api-docs'
|
||||
|
||||
get 'up' => 'rails/health#show', as: :rails_health_check
|
||||
|
||||
root to: redirect('/dashboard')
|
||||
end
|
||||
|
@ -1,7 +0,0 @@
|
||||
# Copyright (C) 2024 Manuel Bustillo
|
||||
|
||||
class RemoveWeddingDate < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
remove_column :weddings, :date, :date, null: false
|
||||
end
|
||||
end
|
3
db/schema.rb
generated
3
db/schema.rb
generated
@ -12,7 +12,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[8.0].define(version: 2024_12_07_112305) do
|
||||
ActiveRecord::Schema[8.0].define(version: 2024_11_30_185731) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "pg_catalog.plpgsql"
|
||||
|
||||
@ -222,6 +222,7 @@ ActiveRecord::Schema[8.0].define(version: 2024_12_07_112305) do
|
||||
|
||||
create_table "weddings", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.string "slug", null: false
|
||||
t.date "date", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["slug"], name: "index_weddings_on_slug", unique: true
|
||||
|
@ -11,7 +11,7 @@ ActsAsTenant.without_tenant do
|
||||
Wedding.delete_all
|
||||
end
|
||||
|
||||
wedding = Wedding.create!(slug: :default)
|
||||
wedding = Wedding.create!(slug: :default, date: 1.year.from_now)
|
||||
|
||||
ActsAsTenant.with_tenant(wedding) do
|
||||
Expense.create!(name: 'Photographer', amount: 3000, pricing_type: 'fixed')
|
||||
|
@ -3,5 +3,6 @@
|
||||
FactoryBot.define do
|
||||
factory :wedding do
|
||||
sequence(:slug) { |i| "wedding-#{i}" }
|
||||
date { 1.year.from_now }
|
||||
end
|
||||
end
|
||||
|
@ -24,6 +24,13 @@ RSpec.describe 'users/registrations', type: :request do
|
||||
password_confirmation: SwaggerResponseHelper::PASSWORD
|
||||
}
|
||||
},
|
||||
wedding: {
|
||||
type: :object,
|
||||
required: %i[date],
|
||||
properties: {
|
||||
date: { type: :string, format: :date},
|
||||
}
|
||||
},
|
||||
**Swagger::Schema::CAPTCHA
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user