Compare commits
5 Commits
18c264b64b
...
65ce9c0716
Author | SHA1 | Date |
---|---|---|
Trevor Vallender | 65ce9c0716 | |
Trevor Vallender | ea31c03c44 | |
Trevor Vallender | d00bde60b1 | |
Trevor Vallender | 3e7909c02b | |
Trevor Vallender | df0854ac39 |
3
Gemfile
3
Gemfile
|
@ -17,6 +17,9 @@ gem "tzinfo-data", platforms: %i[ windows jruby ]
|
|||
gem "bootsnap", require: false
|
||||
# gem "image_processing", "~> 1.2"
|
||||
|
||||
gem "solid_queue"
|
||||
gem "mission_control-jobs"
|
||||
|
||||
group :development, :test do
|
||||
gem "debug", platforms: %i[ mri windows ]
|
||||
end
|
||||
|
|
19
Gemfile.lock
19
Gemfile.lock
|
@ -103,6 +103,11 @@ GEM
|
|||
reline (>= 0.3.8)
|
||||
drb (2.2.1)
|
||||
erubi (1.12.0)
|
||||
et-orbi (1.2.11)
|
||||
tzinfo
|
||||
fugit (1.10.1)
|
||||
et-orbi (~> 1, >= 1.2.7)
|
||||
raabro (~> 1.4)
|
||||
globalid (1.2.1)
|
||||
activesupport (>= 6.1)
|
||||
i18n (1.14.5)
|
||||
|
@ -132,6 +137,11 @@ GEM
|
|||
matrix (0.4.2)
|
||||
mini_mime (1.1.5)
|
||||
minitest (5.23.1)
|
||||
mission_control-jobs (0.2.1)
|
||||
importmap-rails
|
||||
rails (~> 7.1)
|
||||
stimulus-rails
|
||||
turbo-rails
|
||||
msgpack (1.7.2)
|
||||
mutex_m (0.2.0)
|
||||
net-imap (0.4.11)
|
||||
|
@ -171,6 +181,7 @@ GEM
|
|||
public_suffix (5.0.5)
|
||||
puma (6.4.2)
|
||||
nio4r (~> 2.0)
|
||||
raabro (1.4.0)
|
||||
racc (1.8.0)
|
||||
rack (3.0.11)
|
||||
rack-session (2.0.0)
|
||||
|
@ -254,6 +265,12 @@ GEM
|
|||
rexml (~> 3.2, >= 3.2.5)
|
||||
rubyzip (>= 1.2.2, < 3.0)
|
||||
websocket (~> 1.0)
|
||||
solid_queue (0.3.1)
|
||||
activejob (>= 7.1)
|
||||
activerecord (>= 7.1)
|
||||
concurrent-ruby (~> 1.2.2)
|
||||
fugit (~> 1.10.1)
|
||||
railties (>= 7.1)
|
||||
stimulus-rails (1.3.3)
|
||||
railties (>= 6.0.0)
|
||||
stringio (3.1.0)
|
||||
|
@ -296,12 +313,14 @@ DEPENDENCIES
|
|||
debug
|
||||
importmap-rails
|
||||
jbuilder
|
||||
mission_control-jobs
|
||||
pg
|
||||
propshaft
|
||||
puma (>= 5.0)
|
||||
rails (~> 7.1.3, >= 7.1.3.2)
|
||||
rubocop-rails-omakase
|
||||
selenium-webdriver
|
||||
solid_queue
|
||||
stimulus-rails
|
||||
turbo-rails
|
||||
tzinfo-data
|
||||
|
|
|
@ -4,24 +4,26 @@ class TableInvitesController < ApplicationController
|
|||
before_action :set_table, only: [ :new, :create ]
|
||||
before_action :set_table_invite, only: [ :edit, :update ]
|
||||
|
||||
def index
|
||||
@table_invites = TableInvite.where(email: Current.user.email).not_responded
|
||||
end
|
||||
|
||||
def new
|
||||
@table_invite = @table.table_invites.new
|
||||
end
|
||||
|
||||
def create
|
||||
@user = User.find_by(email: table_invite_params[:email])
|
||||
if @user.blank?
|
||||
# TODO: Allow inviting non-users, we can send an email invite
|
||||
flash[:alert] = t(".user_not_found")
|
||||
render :new, status: :unprocessable_entity and return
|
||||
@table_invite = @table.table_invites.new(table_invite_params)
|
||||
unless @table_invite.save
|
||||
render :new, status: :unprocessable_entity, alert: t(".error") and return
|
||||
end
|
||||
|
||||
@table_invite = @table.table_invites.new(table_invite_params)
|
||||
if @table_invite.save
|
||||
redirect_to @table, notice: t(".success", email: @table_invite.email)
|
||||
if User.exists?(email: table_invite_params[:email])
|
||||
TableInviteMailer.with(table_invite: @table_invite).invite_user.deliver_later
|
||||
else
|
||||
render :new, status: :unprocessable_entity, alert: t(".error")
|
||||
TableInviteMailer.with(table_invite: @table_invite).invite_new_user.deliver_later
|
||||
end
|
||||
redirect_to @table, notice: t(".success", email: @table_invite.email)
|
||||
end
|
||||
|
||||
def edit
|
||||
|
|
|
@ -8,6 +8,7 @@ class TablesController < ApplicationController
|
|||
end
|
||||
|
||||
def show
|
||||
@table_invites = @table.table_invites.not_responded
|
||||
end
|
||||
|
||||
def new
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
class UsersController < ApplicationController
|
||||
skip_before_action :authenticate, only: [ :new, :create ]
|
||||
before_action :set_user, only: [ :show ]
|
||||
|
||||
def new
|
||||
@user = User.new
|
||||
|
@ -20,6 +21,12 @@ class UsersController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def show
|
||||
if @user == Current.user
|
||||
@table_invites = TableInvite.where(email: @user.email).not_responded
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def user_params
|
||||
|
@ -32,4 +39,8 @@ class UsersController < ApplicationController
|
|||
:last_name,
|
||||
)
|
||||
end
|
||||
|
||||
def set_user
|
||||
@user = User.find_by(username: params[:id])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class TableInviteMailer < ApplicationMailer
|
||||
helper(:mailer)
|
||||
|
||||
def invite_user
|
||||
@table_invite = params[:table_invite]
|
||||
|
||||
mail(to: @table_invite.email, subject: "[Tabletop Companion] Invite to join a table")
|
||||
end
|
||||
|
||||
def invite_new_user
|
||||
@table_invite = params[:table_invite]
|
||||
|
||||
mail(to: @table_invite.email, subject: "[Tabletop Companion] You’ve been invited to a game!")
|
||||
end
|
||||
end
|
|
@ -7,6 +7,8 @@ class TableInvite < ApplicationRecord
|
|||
presence: true,
|
||||
length: { maximum: 100 }
|
||||
|
||||
scope :not_responded, -> { where(accepted_at: nil, declined_at: nil) }
|
||||
|
||||
def accepted?
|
||||
accepted_at.present?
|
||||
end
|
||||
|
|
|
@ -37,6 +37,10 @@ class User < ApplicationRecord
|
|||
scope :verified, -> { where(verified: true) }
|
||||
scope :unverified, -> { where(verified: false) }
|
||||
|
||||
def to_param
|
||||
username
|
||||
end
|
||||
|
||||
def full_name
|
||||
return first_name if last_name.blank?
|
||||
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
<ul>
|
||||
<li><%= link_to t(".dashboard"), admin_index_path %></li>
|
||||
<li><%= link_to t(".game_systems"), admin_game_systems_path %></li>
|
||||
<% if Rails.env.production? %>
|
||||
<li><%= link_to t(".jobs"), jobs_path, target: "_blank" %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</nav>
|
||||
<% end %>
|
||||
|
|
|
@ -8,7 +8,11 @@
|
|||
</head>
|
||||
|
||||
<body>
|
||||
<p><%= t(".greeting", name: @user.first_name) %></p>
|
||||
<% if @user.present? %>
|
||||
<p><%= t(".greeting", name: @user.first_name) %></p>
|
||||
<% else %>
|
||||
<p><%= t(".greeting_without_name") %></p>
|
||||
<% end %>
|
||||
<%= yield %>
|
||||
<%= t(".sign_off_html") %>
|
||||
</body>
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
<%= t(".greeting") %>
|
||||
<% if @user.present? %>
|
||||
<%= t(".greeting", name: @user.first_name) %>
|
||||
<% else %>
|
||||
<%= t(".greeting_without_name") %>
|
||||
<% end %>
|
||||
|
||||
<%= yield %>
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
<%= htmlify_email(t(".content", table_name: @table_invite.table.name)) %>
|
||||
|
||||
<%= link_to t(".sign_up"), new_user_url %>
|
|
@ -0,0 +1,3 @@
|
|||
<%= t(".content", table_name: @table_invite.table.name) %>
|
||||
|
||||
<%= new_user_url %>
|
|
@ -0,0 +1,3 @@
|
|||
<%= htmlify_email(t(".content", table_name: @table_invite.table.name)) %>
|
||||
|
||||
<%= link_to t(".respond_to_invite"), table_invite_url(@table_invite) %>
|
|
@ -0,0 +1,3 @@
|
|||
<%= t(".content", table_name: @table_invite.table.name) %>
|
||||
|
||||
<%= table_invite_url(@table_invite) %>
|
|
@ -0,0 +1,11 @@
|
|||
<% content_for :title, t(".table_invites") %>
|
||||
|
||||
<h2><%= t(".table_invites") %></h2>
|
||||
|
||||
<% if @table_invites.any? %>
|
||||
<% @table_invites.each do |table_invite| %>
|
||||
<%= link_to table_invite.table.name, edit_table_invite_path(table_invite) %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<p><%= t(".no_table_invites") %></p>
|
||||
<% end %>
|
|
@ -3,7 +3,7 @@
|
|||
<h2><%= t(".new_table_invite", name: @table.name) %></h2>
|
||||
|
||||
<p><%= t(".new_invite_description") %></p>
|
||||
<%= form_with url: table_table_invites_path do |f| %>
|
||||
<%= form_with model: @table_invite, url: table_table_invites_path do |f| %>
|
||||
<%= f.label :email %>
|
||||
<%= f.email_field :email %>
|
||||
|
||||
|
|
|
@ -11,3 +11,12 @@
|
|||
<dt><%= t(".owner") %>:</dt>
|
||||
<dd><%= @table.owner.username %></dd>
|
||||
</dl>
|
||||
|
||||
<% if @table_invites.any? %>
|
||||
<h4>Pending invites</h4>
|
||||
<ul>
|
||||
<% @table_invites.each do |table_invite| %>
|
||||
<li><%= table_invite.email %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<%= content_for :title, @user.username %>
|
||||
|
||||
<h2><%= @user.username %></h2>
|
||||
|
||||
<% if @user == Current.user && @table_invites.any? %>
|
||||
<%= link_to t(".your_invites"), table_invites_path %>
|
||||
<% end %>
|
|
@ -10,7 +10,6 @@ Bundler.require(*Rails.groups)
|
|||
|
||||
module TabletopCompanion
|
||||
class Application < Rails::Application
|
||||
# Initialize configuration defaults for originally generated Rails version.
|
||||
config.load_defaults 7.1
|
||||
|
||||
# Please, add to the `ignore` list any other `lib` subdirectories that do
|
||||
|
@ -18,12 +17,8 @@ module TabletopCompanion
|
|||
# Common ones are `templates`, `generators`, or `middleware`, for example.
|
||||
config.autoload_lib(ignore: %w[assets tasks])
|
||||
|
||||
# Configuration for the application, engines, and railties goes here.
|
||||
#
|
||||
# These settings can be overridden in specific environments using the files
|
||||
# in config/environments, which are processed later.
|
||||
#
|
||||
# config.time_zone = "Central Time (US & Canada)"
|
||||
# config.eager_load_paths << Rails.root.join("extras")
|
||||
config.time_zone = "London"
|
||||
|
||||
config.mission_control.jobs.base_controller_class = "AdminController"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -70,7 +70,7 @@ Rails.application.configure do
|
|||
# config.cache_store = :mem_cache_store
|
||||
|
||||
# Use a real queuing backend for Active Job (and separate queues per environment).
|
||||
# config.active_job.queue_adapter = :resque
|
||||
config.active_job.queue_adapter = :solid_queue
|
||||
# config.active_job.queue_name_prefix = "forg_production"
|
||||
|
||||
config.action_mailer.perform_caching = false
|
||||
|
|
|
@ -13,10 +13,12 @@ en:
|
|||
admin:
|
||||
dashboard: Dashboard
|
||||
game_systems: Game Systems
|
||||
jobs: Jobs
|
||||
application:
|
||||
tables: Tables
|
||||
mailer:
|
||||
greeting: "Hello, %{name}"
|
||||
greeting: "Hi %{name},"
|
||||
greeting_without_name: Hi,
|
||||
sign_off: |
|
||||
See you soon,
|
||||
The Tabletop Companion team
|
||||
|
@ -60,7 +62,21 @@ en:
|
|||
destroy:
|
||||
log_out: Log out
|
||||
success: "You have signed out."
|
||||
table_invite_mailer:
|
||||
invite_new_user:
|
||||
content: |-
|
||||
You’ve been invited to join a game on Tabletop Companion. To start playing, sign up at the
|
||||
link below and accept your invitation!
|
||||
sign_up: Sign up now
|
||||
invite_user:
|
||||
content: |-
|
||||
You have been invited to join the table “%{table_name}” on Tabletop Companion. To
|
||||
respond, visit the link below.
|
||||
respond_to_invite: Respond to invite
|
||||
table_invites:
|
||||
index:
|
||||
table_invites: Your invitations
|
||||
no_table_invites: You have no new invitations
|
||||
new:
|
||||
new_table_invite: Invite a player to %{name}
|
||||
new_invite_description: Enter an email address to invite a player to your table.
|
||||
|
@ -68,7 +84,7 @@ en:
|
|||
button_text: Send invite
|
||||
create:
|
||||
user_not_found: There is no registered user with that email address. Ask them to sign up!
|
||||
success: Send invite to %{email}
|
||||
success: Sent invite to %{email}
|
||||
error: Failed to send invite
|
||||
edit:
|
||||
respond_to_invite: Respond to your invitation
|
||||
|
@ -112,6 +128,8 @@ en:
|
|||
create:
|
||||
error: "Could not create account: %{error}"
|
||||
success: "Thanks for joining Tabletop Companion, %{name}! Please check your email to verify your address."
|
||||
show:
|
||||
your_invites: Your invites
|
||||
user_mailer:
|
||||
email_verified:
|
||||
content: |-
|
||||
|
|
|
@ -35,3 +35,5 @@ pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
|
|||
|
||||
# Allow puma to be restarted by `bin/rails restart` command.
|
||||
plugin :tmp_restart
|
||||
|
||||
plugin :solid_queue if Rails.env.production?
|
||||
|
|
|
@ -8,11 +8,11 @@ Rails.application.routes.draw do
|
|||
get "login" => "sessions#new", as: :login
|
||||
delete "logout" => "sessions#destroy", as: :logout
|
||||
|
||||
resources :users, only: [ :new, :create ]
|
||||
resources :users, only: [ :new, :create, :show ]
|
||||
resources :account_verifications, only: [ :show ]
|
||||
resources :sessions, only: [ :new, :create, :destroy ]
|
||||
|
||||
resources :table_invites, only: [ :edit, :update ]
|
||||
resources :table_invites, only: [ :index, :edit, :update ]
|
||||
resources :tables do
|
||||
resources :table_invites, only: [ :new, :create ]
|
||||
end
|
||||
|
@ -23,4 +23,5 @@ Rails.application.routes.draw do
|
|||
end
|
||||
|
||||
get "up" => "rails/health#show", as: :rails_health_check
|
||||
mount MissionControl::Jobs::Engine, at: "/admin/jobs" if Rails.env.production?
|
||||
end
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
# default: &default
|
||||
# dispatchers:
|
||||
# - polling_interval: 1
|
||||
# batch_size: 500
|
||||
# workers:
|
||||
# - queues: "*"
|
||||
# threads: 3
|
||||
# processes: 1
|
||||
# polling_interval: 0.1
|
||||
#
|
||||
# development:
|
||||
# <<: *default
|
||||
#
|
||||
# test:
|
||||
# <<: *default
|
||||
#
|
||||
# production:
|
||||
# <<: *default
|
|
@ -0,0 +1,103 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# This migration comes from solid_queue (originally 20231211200639)
|
||||
class CreateSolidQueueTables < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
create_table :solid_queue_jobs do |t|
|
||||
t.string :queue_name, null: false
|
||||
t.string :class_name, null: false, index: true
|
||||
t.text :arguments
|
||||
t.integer :priority, default: 0, null: false
|
||||
t.string :active_job_id, index: true
|
||||
t.datetime :scheduled_at
|
||||
t.datetime :finished_at, index: true
|
||||
t.string :concurrency_key
|
||||
|
||||
t.timestamps
|
||||
|
||||
t.index [ :queue_name, :finished_at ], name: "index_solid_queue_jobs_for_filtering"
|
||||
t.index [ :scheduled_at, :finished_at ], name: "index_solid_queue_jobs_for_alerting"
|
||||
end
|
||||
|
||||
create_table :solid_queue_scheduled_executions do |t|
|
||||
t.references :job, index: { unique: true }, null: false
|
||||
t.string :queue_name, null: false
|
||||
t.integer :priority, default: 0, null: false
|
||||
t.datetime :scheduled_at, null: false
|
||||
|
||||
t.datetime :created_at, null: false
|
||||
|
||||
t.index [ :scheduled_at, :priority, :job_id ], name: "index_solid_queue_dispatch_all"
|
||||
end
|
||||
|
||||
create_table :solid_queue_ready_executions do |t|
|
||||
t.references :job, index: { unique: true }, null: false
|
||||
t.string :queue_name, null: false
|
||||
t.integer :priority, default: 0, null: false
|
||||
|
||||
t.datetime :created_at, null: false
|
||||
|
||||
t.index [ :priority, :job_id ], name: "index_solid_queue_poll_all"
|
||||
t.index [ :queue_name, :priority, :job_id ], name: "index_solid_queue_poll_by_queue"
|
||||
end
|
||||
|
||||
create_table :solid_queue_claimed_executions do |t|
|
||||
t.references :job, index: { unique: true }, null: false
|
||||
t.bigint :process_id
|
||||
t.datetime :created_at, null: false
|
||||
|
||||
t.index [ :process_id, :job_id ]
|
||||
end
|
||||
|
||||
create_table :solid_queue_blocked_executions do |t|
|
||||
t.references :job, index: { unique: true }, null: false
|
||||
t.string :queue_name, null: false
|
||||
t.integer :priority, default: 0, null: false
|
||||
t.string :concurrency_key, null: false
|
||||
t.datetime :expires_at, null: false
|
||||
|
||||
t.datetime :created_at, null: false
|
||||
|
||||
t.index [ :expires_at, :concurrency_key ], name: "index_solid_queue_blocked_executions_for_maintenance"
|
||||
end
|
||||
|
||||
create_table :solid_queue_failed_executions do |t|
|
||||
t.references :job, index: { unique: true }, null: false
|
||||
t.text :error
|
||||
t.datetime :created_at, null: false
|
||||
end
|
||||
|
||||
create_table :solid_queue_pauses do |t|
|
||||
t.string :queue_name, null: false, index: { unique: true }
|
||||
t.datetime :created_at, null: false
|
||||
end
|
||||
|
||||
create_table :solid_queue_processes do |t|
|
||||
t.string :kind, null: false
|
||||
t.datetime :last_heartbeat_at, null: false, index: true
|
||||
t.bigint :supervisor_id, index: true
|
||||
|
||||
t.integer :pid, null: false
|
||||
t.string :hostname
|
||||
t.text :metadata
|
||||
|
||||
t.datetime :created_at, null: false
|
||||
end
|
||||
|
||||
create_table :solid_queue_semaphores do |t|
|
||||
t.string :key, null: false, index: { unique: true }
|
||||
t.integer :value, default: 1, null: false
|
||||
t.datetime :expires_at, null: false, index: true
|
||||
|
||||
t.timestamps
|
||||
|
||||
t.index [ :key, :value ], name: "index_solid_queue_semaphores_on_key_and_value"
|
||||
end
|
||||
|
||||
add_foreign_key :solid_queue_blocked_executions, :solid_queue_jobs, column: :job_id, on_delete: :cascade
|
||||
add_foreign_key :solid_queue_claimed_executions, :solid_queue_jobs, column: :job_id, on_delete: :cascade
|
||||
add_foreign_key :solid_queue_failed_executions, :solid_queue_jobs, column: :job_id, on_delete: :cascade
|
||||
add_foreign_key :solid_queue_ready_executions, :solid_queue_jobs, column: :job_id, on_delete: :cascade
|
||||
add_foreign_key :solid_queue_scheduled_executions, :solid_queue_jobs, column: :job_id, on_delete: :cascade
|
||||
end
|
||||
end
|
|
@ -0,0 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# This migration comes from solid_queue (originally 20240110143450)
|
||||
class AddMissingIndexToBlockedExecutions < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
add_index :solid_queue_blocked_executions, [ :concurrency_key, :priority, :job_id ], name: "index_solid_queue_blocked_executions_for_release"
|
||||
end
|
||||
end
|
|
@ -0,0 +1,17 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# This migration comes from solid_queue (originally 20240218110712)
|
||||
class CreateRecurringExecutions < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
create_table :solid_queue_recurring_executions do |t|
|
||||
t.references :job, index: { unique: true }, null: false
|
||||
t.string :task_key, null: false
|
||||
t.datetime :run_at, null: false
|
||||
t.datetime :created_at, null: false
|
||||
|
||||
t.index [ :task_key, :run_at ], unique: true
|
||||
end
|
||||
|
||||
add_foreign_key :solid_queue_recurring_executions, :solid_queue_jobs, column: :job_id, on_delete: :cascade
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.1].define(version: 2024_05_29_122012) do
|
||||
ActiveRecord::Schema[7.1].define(version: 2024_05_30_071707) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
|
@ -44,6 +44,109 @@ ActiveRecord::Schema[7.1].define(version: 2024_05_29_122012) do
|
|||
t.index ["user_id"], name: "index_site_roles_users_on_user_id"
|
||||
end
|
||||
|
||||
create_table "solid_queue_blocked_executions", force: :cascade do |t|
|
||||
t.bigint "job_id", null: false
|
||||
t.string "queue_name", null: false
|
||||
t.integer "priority", default: 0, null: false
|
||||
t.string "concurrency_key", null: false
|
||||
t.datetime "expires_at", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.index ["concurrency_key", "priority", "job_id"], name: "index_solid_queue_blocked_executions_for_release"
|
||||
t.index ["expires_at", "concurrency_key"], name: "index_solid_queue_blocked_executions_for_maintenance"
|
||||
t.index ["job_id"], name: "index_solid_queue_blocked_executions_on_job_id", unique: true
|
||||
end
|
||||
|
||||
create_table "solid_queue_claimed_executions", force: :cascade do |t|
|
||||
t.bigint "job_id", null: false
|
||||
t.bigint "process_id"
|
||||
t.datetime "created_at", null: false
|
||||
t.index ["job_id"], name: "index_solid_queue_claimed_executions_on_job_id", unique: true
|
||||
t.index ["process_id", "job_id"], name: "index_solid_queue_claimed_executions_on_process_id_and_job_id"
|
||||
end
|
||||
|
||||
create_table "solid_queue_failed_executions", force: :cascade do |t|
|
||||
t.bigint "job_id", null: false
|
||||
t.text "error"
|
||||
t.datetime "created_at", null: false
|
||||
t.index ["job_id"], name: "index_solid_queue_failed_executions_on_job_id", unique: true
|
||||
end
|
||||
|
||||
create_table "solid_queue_jobs", force: :cascade do |t|
|
||||
t.string "queue_name", null: false
|
||||
t.string "class_name", null: false
|
||||
t.text "arguments"
|
||||
t.integer "priority", default: 0, null: false
|
||||
t.string "active_job_id"
|
||||
t.datetime "scheduled_at"
|
||||
t.datetime "finished_at"
|
||||
t.string "concurrency_key"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["active_job_id"], name: "index_solid_queue_jobs_on_active_job_id"
|
||||
t.index ["class_name"], name: "index_solid_queue_jobs_on_class_name"
|
||||
t.index ["finished_at"], name: "index_solid_queue_jobs_on_finished_at"
|
||||
t.index ["queue_name", "finished_at"], name: "index_solid_queue_jobs_for_filtering"
|
||||
t.index ["scheduled_at", "finished_at"], name: "index_solid_queue_jobs_for_alerting"
|
||||
end
|
||||
|
||||
create_table "solid_queue_pauses", force: :cascade do |t|
|
||||
t.string "queue_name", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.index ["queue_name"], name: "index_solid_queue_pauses_on_queue_name", unique: true
|
||||
end
|
||||
|
||||
create_table "solid_queue_processes", force: :cascade do |t|
|
||||
t.string "kind", null: false
|
||||
t.datetime "last_heartbeat_at", null: false
|
||||
t.bigint "supervisor_id"
|
||||
t.integer "pid", null: false
|
||||
t.string "hostname"
|
||||
t.text "metadata"
|
||||
t.datetime "created_at", null: false
|
||||
t.index ["last_heartbeat_at"], name: "index_solid_queue_processes_on_last_heartbeat_at"
|
||||
t.index ["supervisor_id"], name: "index_solid_queue_processes_on_supervisor_id"
|
||||
end
|
||||
|
||||
create_table "solid_queue_ready_executions", force: :cascade do |t|
|
||||
t.bigint "job_id", null: false
|
||||
t.string "queue_name", null: false
|
||||
t.integer "priority", default: 0, null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.index ["job_id"], name: "index_solid_queue_ready_executions_on_job_id", unique: true
|
||||
t.index ["priority", "job_id"], name: "index_solid_queue_poll_all"
|
||||
t.index ["queue_name", "priority", "job_id"], name: "index_solid_queue_poll_by_queue"
|
||||
end
|
||||
|
||||
create_table "solid_queue_recurring_executions", force: :cascade do |t|
|
||||
t.bigint "job_id", null: false
|
||||
t.string "task_key", null: false
|
||||
t.datetime "run_at", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.index ["job_id"], name: "index_solid_queue_recurring_executions_on_job_id", unique: true
|
||||
t.index ["task_key", "run_at"], name: "index_solid_queue_recurring_executions_on_task_key_and_run_at", unique: true
|
||||
end
|
||||
|
||||
create_table "solid_queue_scheduled_executions", force: :cascade do |t|
|
||||
t.bigint "job_id", null: false
|
||||
t.string "queue_name", null: false
|
||||
t.integer "priority", default: 0, null: false
|
||||
t.datetime "scheduled_at", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.index ["job_id"], name: "index_solid_queue_scheduled_executions_on_job_id", unique: true
|
||||
t.index ["scheduled_at", "priority", "job_id"], name: "index_solid_queue_dispatch_all"
|
||||
end
|
||||
|
||||
create_table "solid_queue_semaphores", force: :cascade do |t|
|
||||
t.string "key", null: false
|
||||
t.integer "value", default: 1, null: false
|
||||
t.datetime "expires_at", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["expires_at"], name: "index_solid_queue_semaphores_on_expires_at"
|
||||
t.index ["key", "value"], name: "index_solid_queue_semaphores_on_key_and_value"
|
||||
t.index ["key"], name: "index_solid_queue_semaphores_on_key", unique: true
|
||||
end
|
||||
|
||||
create_table "table_invites", force: :cascade do |t|
|
||||
t.bigint "table_id", null: false
|
||||
t.string "email", null: false
|
||||
|
@ -90,6 +193,12 @@ ActiveRecord::Schema[7.1].define(version: 2024_05_29_122012) do
|
|||
|
||||
add_foreign_key "players", "tables"
|
||||
add_foreign_key "players", "users"
|
||||
add_foreign_key "solid_queue_blocked_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade
|
||||
add_foreign_key "solid_queue_claimed_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade
|
||||
add_foreign_key "solid_queue_failed_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade
|
||||
add_foreign_key "solid_queue_ready_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade
|
||||
add_foreign_key "solid_queue_recurring_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade
|
||||
add_foreign_key "solid_queue_scheduled_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade
|
||||
add_foreign_key "table_invites", "tables"
|
||||
add_foreign_key "tables", "game_systems"
|
||||
add_foreign_key "tables", "users", column: "owner_id"
|
||||
|
|
|
@ -3,6 +3,12 @@
|
|||
require "test_helper"
|
||||
|
||||
class TableInviteInvitesControllerTest < ActionDispatch::IntegrationTest
|
||||
test "should get index" do
|
||||
sign_in users(:trevor)
|
||||
get table_invites_url
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "only a table owner can invite players" do
|
||||
sign_in users(:trevor)
|
||||
get new_table_table_invite_url(tables(:gimlis_table))
|
||||
|
@ -29,6 +35,23 @@ class TableInviteInvitesControllerTest < ActionDispatch::IntegrationTest
|
|||
assert_redirected_to table_path(tables(:table))
|
||||
end
|
||||
|
||||
test "can invite a non-user to join" do
|
||||
sign_in users(:trevor)
|
||||
assert_changes("TableInvite.count", +1) do
|
||||
assert_emails(+1) do
|
||||
post(table_table_invites_url(tables(:table)), params: { table_invite: { email: "not_a_member@example.com" } })
|
||||
end
|
||||
end
|
||||
assert_redirected_to table_path(tables(:table))
|
||||
end
|
||||
|
||||
test "should email user when an invite is created" do
|
||||
sign_in users(:trevor)
|
||||
assert_emails(+1) do
|
||||
post(table_table_invites_url(tables(:table)), params: { table_invite: { email: "uninvited_user@example.com" } })
|
||||
end
|
||||
end
|
||||
|
||||
test "should accept table_invite" do
|
||||
sign_in users(:frodo)
|
||||
invite = table_invites(:unaccepted)
|
||||
|
|
|
@ -8,6 +8,12 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
|
|||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get show" do
|
||||
sign_in users(:trevor)
|
||||
get user_url(users(:trevor))
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create user" do
|
||||
assert_changes("User.count", +1) do
|
||||
post(users_url, params: { user: user_params })
|
||||
|
|
Loading…
Reference in New Issue