mirror of
https://github.com/cliffe/BreakEscape.git
synced 2026-02-22 19:58:05 +00:00
fix: Make tests database-agnostic and fix fixture loading
- Update migration to support both PostgreSQL (jsonb) and SQLite (json) - Fix Rails 8 compatibility (remove config.assets) - Configure Pundit to use current_player instead of current_user - Add explicit fixture class mappings for engine fixtures - Configure standalone mode for tests - Update test fixtures with proper timestamps and structure - Improve game test to create data programmatically Tests now run with 10/12 assertions passing. Remaining errors are due to missing test scenario files, which can be addressed separately.
This commit is contained in:
@@ -3,7 +3,26 @@ require 'test_helper'
|
||||
module BreakEscape
|
||||
class GameTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
@game = games(:active_game)
|
||||
@mission = break_escape_missions(:ceo_exfil)
|
||||
@player = break_escape_demo_users(:test_user)
|
||||
@game = Game.create!(
|
||||
mission: @mission,
|
||||
player: @player,
|
||||
scenario_data: { "startRoom" => "reception", "rooms" => {} },
|
||||
player_state: {
|
||||
"currentRoom" => "reception",
|
||||
"unlockedRooms" => ["reception"],
|
||||
"unlockedObjects" => [],
|
||||
"inventory" => [],
|
||||
"encounteredNPCs" => [],
|
||||
"globalVariables" => {},
|
||||
"biometricSamples" => [],
|
||||
"biometricUnlocks" => [],
|
||||
"bluetoothDevices" => [],
|
||||
"notes" => [],
|
||||
"health" => 100
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
test "should belong to player and mission" do
|
||||
|
||||
@@ -15,12 +15,12 @@ module BreakEscape
|
||||
end
|
||||
|
||||
test "published scope returns only published missions" do
|
||||
assert_includes Mission.published, missions(:ceo_exfil)
|
||||
assert_not_includes Mission.published, missions(:unpublished)
|
||||
assert_includes Mission.published, break_escape_missions(:ceo_exfil)
|
||||
assert_not_includes Mission.published, break_escape_missions(:unpublished)
|
||||
end
|
||||
|
||||
test "scenario_path returns correct path" do
|
||||
mission = missions(:ceo_exfil)
|
||||
mission = break_escape_missions(:ceo_exfil)
|
||||
expected = Rails.root.join('app', 'assets', 'scenarios', 'ceo_exfil')
|
||||
assert_equal expected, mission.scenario_path
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user