require "rack/attack"
require "redis-store"
class Rack::Attack
cache.store = Redis::Store.new(url: ENV.fetch("REDIS_URL", "redis://localhost:6379/1"))
# spec/factories/users.rb
FactoryBot.define do
factory :user do
sequence(:email) { |n| "user#{n}@example.com" }
name { Faker::Name.name }
password { 'password123' }
class Order < ApplicationRecord
has_many :line_items, inverse_of: :order, dependent: :destroy
accepts_nested_attributes_for :line_items,
allow_destroy: true,
reject_if: ->(attrs) { attrs["product_id"].blank? && attrs["quantity"].blank? }
require 'swagger_helper'
RSpec.describe 'Api::V1::Posts', type: :request do
path '/api/v1/posts' do
get 'Retrieves all posts' do
tags 'Posts'
class OverdueInvoicesQuery
def initialize(relation: Invoice.all, as_of: Time.current)
@relation = relation
@as_of = as_of
end
class AddVersionsToArticles < ActiveRecord::Migration[7.1]
def change
add_column :articles, :versions, :jsonb, null: false, default: []
add_index :articles, :versions, using: :gin
end
end
class SubscriptionsController < ApplicationController
before_action :set_subscription, only: %i[show destroy]
def new
@subscription = Subscription.new
end
class Order < ApplicationRecord
include TransactionalEnqueue
belongs_to :customer
has_many :line_items, dependent: :destroy
module DomainEvents
class Registry
def initialize
@subscribers = Hash.new { |h, k| h[k] = [] }
end
import * as Turbo from "@hotwired/turbo";
function metaContent(name) {
const el = document.querySelector(`meta[name="${name}"]`);
return el ? el.getAttribute("content") : null;
}
class HealthController < ApplicationController
skip_before_action :verify_authenticity_token
def liveness
render json: { status: 'ok' }, status: :ok
end
class CreateAuditLogs < ActiveRecord::Migration[7.1]
def change
create_table :audit_logs do |t|
t.references :auditable, polymorphic: true, null: false
t.string :actor
t.string :action, null: false