feat: Configure dummy app for development with engine migrations

- Add root route that redirects to missions list
- Fix ApplicationController to fallback to demo user when current_user unavailable
- Configure dummy app to load engine migrations in application.rb
- Create test/dummy/db/migrate directory
- Successfully migrated and seeded database with 26 missions

Now visiting http://localhost:3000 will show the missions selection page!
This commit is contained in:
Z. Cliffe Schreuders
2025-11-21 15:27:54 +00:00
parent 19b52cd826
commit e18950c6d7
5 changed files with 21 additions and 15 deletions

View File

@@ -7,8 +7,8 @@ module BreakEscape
# Helper method to get current player (polymorphic)
def current_player
if BreakEscape.standalone_mode?
# Standalone mode - get/create demo user
if BreakEscape.standalone_mode? || !respond_to?(:current_user, true)
# Standalone mode or no current_user available - get/create demo user
@current_player ||= DemoUser.first_or_create!(handle: 'demo_player')
else
# Mounted mode - use Hacktivity's current_user

View File

@@ -18,6 +18,9 @@ module Dummy
# Common ones are `templates`, `generators`, or `middleware`, for example.
config.autoload_lib(ignore: %w[assets tasks])
# Load engine migrations
config.paths['db/migrate'] << File.expand_path('../../../../db/migrate', __dir__)
# Configuration for the application, engines, and railties goes here.
#
# These settings can be overridden in specific environments using the files

View File

@@ -1,3 +1,6 @@
Rails.application.routes.draw do
mount BreakEscape::Engine => "/break_escape"
# Redirect root to missions list
root to: redirect('/break_escape/missions')
end

View File

@@ -10,26 +10,26 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[8.1].define(version: 2025_11_20_160000) do
ActiveRecord::Schema[7.2].define(version: 2025_11_20_160000) do
create_table "break_escape_demo_users", force: :cascade do |t|
t.datetime "created_at", null: false
t.string "handle", null: false
t.string "role", default: "user", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["handle"], name: "index_break_escape_demo_users_on_handle", unique: true
end
create_table "break_escape_games", force: :cascade do |t|
t.datetime "completed_at"
t.datetime "created_at", null: false
t.integer "mission_id", null: false
t.integer "player_id", null: false
t.json "player_state", default: "{\"currentRoom\":null,\"unlockedRooms\":[],\"unlockedObjects\":[],\"inventory\":[],\"encounteredNPCs\":[],\"globalVariables\":{},\"biometricSamples\":[],\"biometricUnlocks\":[],\"bluetoothDevices\":[],\"notes\":[],\"health\":100}", null: false
t.string "player_type", null: false
t.integer "player_id", null: false
t.integer "mission_id", null: false
t.json "scenario_data", null: false
t.integer "score", default: 0, null: false
t.datetime "started_at"
t.json "player_state", default: "{\"currentRoom\":null,\"unlockedRooms\":[],\"unlockedObjects\":[],\"inventory\":[],\"encounteredNPCs\":[],\"globalVariables\":{},\"biometricSamples\":[],\"biometricUnlocks\":[],\"bluetoothDevices\":[],\"notes\":[],\"health\":100}", null: false
t.string "status", default: "in_progress", null: false
t.datetime "started_at"
t.datetime "completed_at"
t.integer "score", default: 0, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["mission_id"], name: "index_break_escape_games_on_mission_id"
t.index ["player_type", "player_id", "mission_id"], name: "index_games_on_player_and_mission", unique: true
@@ -38,12 +38,12 @@ ActiveRecord::Schema[8.1].define(version: 2025_11_20_160000) do
end
create_table "break_escape_missions", force: :cascade do |t|
t.datetime "created_at", null: false
t.text "description"
t.integer "difficulty_level", default: 1, null: false
t.string "display_name", null: false
t.string "name", null: false
t.string "display_name", null: false
t.text "description"
t.boolean "published", default: false, null: false
t.integer "difficulty_level", default: 1, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["name"], name: "index_break_escape_missions_on_name", unique: true
t.index ["published"], name: "index_break_escape_missions_on_published"

Binary file not shown.