diff --git a/app/models/boost.rb b/app/models/boost.rb new file mode 100644 index 000000000..b368ec116 --- /dev/null +++ b/app/models/boost.rb @@ -0,0 +1,4 @@ +class Boost < ApplicationRecord + belongs_to :splat + belongs_to :creator, class_name: "User", default: -> { Current.user } +end diff --git a/app/models/splat.rb b/app/models/splat.rb index 9a068bae0..342f392d3 100644 --- a/app/models/splat.rb +++ b/app/models/splat.rb @@ -1,4 +1,5 @@ class Splat < ApplicationRecord + has_many :boosts, dependent: :destroy has_many :categorizations has_many :categories, through: :categorizations, dependent: :destroy has_many :comments, dependent: :destroy diff --git a/db/migrate/20240819192804_create_boosts.rb b/db/migrate/20240819192804_create_boosts.rb new file mode 100644 index 000000000..ea5139c92 --- /dev/null +++ b/db/migrate/20240819192804_create_boosts.rb @@ -0,0 +1,11 @@ +class CreateBoosts < ActiveRecord::Migration[8.0] + def change + create_table :boosts do |t| + t.string :content + t.integer :creator_id, null: false + t.references :splat, null: false + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 8f10843ac..b449e654c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.0].define(version: 2024_08_14_214252) do +ActiveRecord::Schema[8.0].define(version: 2024_08_19_192804) do create_table "accounts", force: :cascade do |t| t.string "name", null: false t.datetime "created_at", null: false @@ -18,6 +18,15 @@ ActiveRecord::Schema[8.0].define(version: 2024_08_14_214252) do t.index ["name"], name: "index_accounts_on_name", unique: true end + create_table "boosts", force: :cascade do |t| + t.string "content" + t.integer "creator_id", null: false + t.integer "splat_id", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["splat_id"], name: "index_boosts_on_splat_id" + end + create_table "categories", force: :cascade do |t| t.string "title" t.datetime "created_at", null: false diff --git a/test/fixtures/boosts.yml b/test/fixtures/boosts.yml new file mode 100644 index 000000000..9e2ec75c2 --- /dev/null +++ b/test/fixtures/boosts.yml @@ -0,0 +1,21 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + content: "" + creator: :jz + splat: one + +two: + content: "" + creator: :kevin + splat: two + +three: + content: "" + creator: :kevin + splat: one + +four: + content: "" + creator: :jz + splat: one diff --git a/test/models/boost_test.rb b/test/models/boost_test.rb new file mode 100644 index 000000000..8c31db440 --- /dev/null +++ b/test/models/boost_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class BoostTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end