Skip to content

Commit

Permalink
Merge branch 'main' into HER-61-Create-Events-Controller
Browse files Browse the repository at this point in the history
  • Loading branch information
mhope21 authored Jan 4, 2025
2 parents c0be268 + 36a10e2 commit 9c1896b
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 0 deletions.
13 changes: 13 additions & 0 deletions app/models/booking.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class Booking < ApplicationRecord
belongs_to :event

has_one :speaker, through: :event
has_one :order, as: :product
has_one :user, through: :order

enum status: { pending: 0, confirmed: 1, denied: 2 }

validates :start_time, presence: true
validates :end_time, presence: true
validates :status, presence: true
end
12 changes: 12 additions & 0 deletions db/migrate/20250102052721_create_bookings.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class CreateBookings < ActiveRecord::Migration[7.2]
def change
create_table :bookings do |t|
t.references :event, null: false, foreign_key: true
t.datetime :start_time, null: false
t.datetime :end_time, null: false
t.integer :status, null: false, default: 0

t.timestamps
end
end
end
12 changes: 12 additions & 0 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions spec/factories/bookings.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FactoryBot.define do
factory :booking do
event { nil }
start_time { "2025-01-01 23:27:21" }
end_time { "2025-01-01 23:27:21" }
status { 1 }
end
end
5 changes: 5 additions & 0 deletions spec/models/booking_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'rails_helper'

RSpec.describe Booking, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end

0 comments on commit 9c1896b

Please sign in to comment.