From ed01262d88991cc9011f6dbb126bbd9c5ab02f2c Mon Sep 17 00:00:00 2001 From: Trevor Vallender Date: Sun, 26 May 2024 09:51:31 +0100 Subject: [PATCH] Add GameSystem model --- app/models/game_system.rb | 3 +++ db/migrate/20240526084840_create_game_systems.rb | 9 +++++++++ db/schema.rb | 8 +++++++- test/fixtures/game_systems.yml | 2 ++ test/models/game_system_test.rb | 7 +++++++ 5 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 app/models/game_system.rb create mode 100644 db/migrate/20240526084840_create_game_systems.rb create mode 100644 test/fixtures/game_systems.yml create mode 100644 test/models/game_system_test.rb diff --git a/app/models/game_system.rb b/app/models/game_system.rb new file mode 100644 index 0000000..0086c99 --- /dev/null +++ b/app/models/game_system.rb @@ -0,0 +1,3 @@ +class GameSystem < ApplicationRecord + validates :name, presence: true +end diff --git a/db/migrate/20240526084840_create_game_systems.rb b/db/migrate/20240526084840_create_game_systems.rb new file mode 100644 index 0000000..4388c09 --- /dev/null +++ b/db/migrate/20240526084840_create_game_systems.rb @@ -0,0 +1,9 @@ +class CreateGameSystems < ActiveRecord::Migration[7.1] + def change + create_table :game_systems do |t| + t.string :name, null: false + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 038bb9c..dd18ba3 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,10 +10,16 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2024_04_14_122652) do +ActiveRecord::Schema[7.1].define(version: 2024_05_26_084840) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" + create_table "game_systems", force: :cascade do |t| + t.string "name", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "users", force: :cascade do |t| t.string "username", limit: 20, null: false t.string "password_digest", limit: 200, null: false diff --git a/test/fixtures/game_systems.yml b/test/fixtures/game_systems.yml new file mode 100644 index 0000000..4f95233 --- /dev/null +++ b/test/fixtures/game_systems.yml @@ -0,0 +1,2 @@ +troika: + name: Troika diff --git a/test/models/game_system_test.rb b/test/models/game_system_test.rb new file mode 100644 index 0000000..114514c --- /dev/null +++ b/test/models/game_system_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class GameSystemTest < ActiveSupport::TestCase + test "name must exist" do + assert_must_exist(game_systems(:troika), :name) + end +end