From e18950c6d76ff89a71448580d320a15e7eb28410 Mon Sep 17 00:00:00 2001 From: "Z. Cliffe Schreuders" Date: Fri, 21 Nov 2025 15:27:54 +0000 Subject: [PATCH] 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! --- .../break_escape/application_controller.rb | 4 +-- test/dummy/config/application.rb | 3 ++ test/dummy/config/routes.rb | 3 ++ test/dummy/db/schema.rb | 26 +++++++++--------- test/dummy/storage/test.sqlite3 | Bin 65536 -> 4096 bytes 5 files changed, 21 insertions(+), 15 deletions(-) diff --git a/app/controllers/break_escape/application_controller.rb b/app/controllers/break_escape/application_controller.rb index 4ada373..c3703e8 100644 --- a/app/controllers/break_escape/application_controller.rb +++ b/app/controllers/break_escape/application_controller.rb @@ -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 diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb index 6e61f6b..46ba10e 100644 --- a/test/dummy/config/application.rb +++ b/test/dummy/config/application.rb @@ -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 diff --git a/test/dummy/config/routes.rb b/test/dummy/config/routes.rb index 9bf62f3..835baac 100644 --- a/test/dummy/config/routes.rb +++ b/test/dummy/config/routes.rb @@ -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 diff --git a/test/dummy/db/schema.rb b/test/dummy/db/schema.rb index 52bf4c0..2f775c7 100644 --- a/test/dummy/db/schema.rb +++ b/test/dummy/db/schema.rb @@ -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" diff --git a/test/dummy/storage/test.sqlite3 b/test/dummy/storage/test.sqlite3 index 500ee2fecdab0d9422939afb4b9bfb1eefb0ba94..b4f7039cca4987c7c9ed4dfa0f4511818eb75ba1 100644 GIT binary patch delta 26 gcmZo@U};d8AkE6iz`(#baiTqtq1XFklfxW-09Ew|4gdfE literal 65536 zcmeI*&2QW09S3kylr77xLnmFJVJI4gUg2_Q6k1aM7 z>5`NYqbo4E+pxo4(0`z(qQJ1ju*)vH?b4#VuZOh*av6|fXuDn30Xyt@s25TeWyJwH z#OPOmZ0q6kJp4T$J?f1IN`9K0n|Le!kNCy-Zv;{J z`>-mI4uSuhKx_SlL@Jl#_iuW7#U#3;8J0&JOE}-&-z8 za#R*sIwwCMd$P2vJJq`GNadAvsl2hgEZtsRx>a1=lx~(b&r9;IZZ=6T7fq--ME6Kd z(>+f%Mdb;jp$t98=QwT7|n=$>I)?m)s+Kg_^(rm{;Mmlp1|x!1C=j8Z%`p4zxL ztO)}ZYwAGKiPq`qMCy*pw{m{F+l{YK-Uk|StNISnw)F;aHQUl$PxqSc;I?F^Jxk@Q zr5{N0=qhAsr7X#V6|si5cOomT?>v`C-Oux_Tf^dN7%n67L)&RqOv9~{T3@Bz9M6vo zu$z-LvsYI{nB9CV(jcGGk|z_XH5%;oCkfV~ppkJt*NJnZymV)yBn|iMhQY#RwT+0> z&!X)AD49s*^ZZX!em{+jATn{XzrRN2VIW3Lme|a&O`LEqm5LkdD@$cs$*oeE4)4wo zf3i_rqn*$(cGy6YC67GxXtA2HwPjSBrnje=WS5x1Uayv}6*rdGB{jU4n&Ix4`d$a> z;7mj7YYRqf2;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